generated from Three-taile-dragon/KernelSU_Action
-
Notifications
You must be signed in to change notification settings - Fork 0
102 lines (100 loc) · 5.79 KB
/
build-kernel-NoSu.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
name: Build Kernel Without Su
on:
watch:
types: [started]
workflow_dispatch:
inputs:
KERNEL_SOURCE:
description: 'Kernel Source'
required: true
default: 'https://github.com/Terminator-J/crdroid_kernel_oneplus_sdm845'
KERNEL_SOURCE_BRANCH:
description: 'Branch'
required: true
default: '13.0-m00'
KERNEL_DEFCONFIG:
description: 'Defconfig'
required: true
default: 'arch/arm64/configs/enchilada_defconfig'
KERNEL_FILE:
description: 'Your kernel out image name'
required: true
default: 'Image.gz-dtb'
CLANG_VERSION:
description: 'Clang version'
required: true
default: 'r475365b'
BUILD_EXTRA_COMMAND:
description: 'Extra build commands(e.g. LLVM=1 LLVM_IAS=1)'
required: false
default: 'LD=ld.lld LLVM=1 LLVM_IAS=1'
USE_KPROBES:
description: 'If you want to use kprobes, please type "true"'
required: true
default: 'true'
jobs:
build:
runs-on: ubuntu-latest
if: github.event.repository.owner.id == github.event.sender.id
steps:
- uses: actions/checkout@v3
- name: Setup Configuration
run: |
if [ $(cat config.env | grep "USE_CONFIG" | head -n 1 | cut -d "=" -f 2) = true ];then
echo "KERNEL_SOURCE=$(cat config.env | grep "KERNEL_SOURCE" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV
echo "KERNEL_SOURCE_BRANCH=$(cat config.env | grep "KERNEL_SOURCE_BRANCH" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV
echo "KERNEL_DEFCONFIG=$(cat config.env | grep "KERNEL_DEFCONFIG" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV
echo "KERNEL_FILE=$(cat config.env | grep "KERNEL_FILE" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV
echo "CLANG_VERSION=$(cat config.env | grep "CLANG_VERSION" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV
echo "BUILD_EXTRA_COMMAND=$(cat config.env | grep "EXTRA_BUILD_COMMAND" | head -n 1 | cut -d ":" -f 2)" >> $GITHUB_ENV
echo "USE_KPROBES=$(cat config.env | grep "USE_KPROBES" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV
else
echo "KERNEL_SOURCE=${{ github.event.inputs.KERNEL_SOURCE }}" >> $GITHUB_ENV
echo "KERNEL_SOURCE_BRANCH=${{ github.event.inputs.KERNEL_SOURCE_BRANCH }}" >> $GITHUB_ENV
echo "KERNEL_DEFCONFIG=${{ github.event.inputs.KERNEL_DEFCONFIG }}" >> $GITHUB_ENV
echo "KERNEL_FILE=${{ github.event.inputs.KERNEL_FILE }}" >> $GITHUB_ENV
echo "CLANG_VERSION=${{ github.event.inputs.CLANG_VERSION }}" >> $GITHUB_ENV
echo "BUILD_EXTRA_COMMAND=${{ github.event.inputs.BUILD_EXTRA_COMMAND }}" >> $GITHUB_ENV
echo "USE_KPROBES=${{ github.event.inputs.USE_KPROBES }}" >> $GITHUB_ENV
fi
- name: Setup build kernel environment
run: |
echo "BUILD_TIME=$(TZ=Asia/Shanghai date "+%Y%m%d%H%M")" >> $GITHUB_ENV
echo "DEVICE=$(echo ${{ env.KERNEL_DEFCONFIG }} | sed 's!vendor/!!;s/_defconfig//;s/_user//;s/-perf//')" >> $GITHUB_ENV
sudo apt-get update
sudo apt-get install git ccache automake flex lzop bison gperf build-essential zip curl zlib1g-dev g++-multilib libxml2-utils bzip2 libbz2-dev libbz2-1.0 libghc-bzlib-dev squashfs-tools pngcrush schedtool dpkg-dev liblz4-tool make optipng maven libssl-dev pwgen libswitch-perl policycoreutils minicom libxml-sax-base-perl libxml-simple-perl bc libc6-dev-i386 lib32ncurses5-dev libx11-dev lib32z-dev libgl1-mesa-dev xsltproc unzip device-tree-compiler python2 python3
- name: Download Clang-aosp and Gcc-aosp
run: |
cd $GITHUB_WORKSPACE && mkdir kernel_workspace && cd kernel_workspace
mkdir clang-aosp
wget https://android.googlesource.com/platform/prebuilts/clang/host/linux-x86/+archive/0a65f9d32d1d7131a3697af08320cc0d890395c1/clang-r475365b.tar.gz
tar -C clang-aosp/ -zxvf clang-${{ env.CLANG_VERSION }}.tar.gz
mkdir gcc-aosp
wget https://github.com/LineageOS/android_prebuilts_gcc_linux-x86_aarch64_aarch64-linux-android-4.9/archive/refs/heads/lineage-19.1.zip
unzip -o lineage-19.1.zip -d gcc-aosp/
- name: Download kernel source
run: |
cd $GITHUB_WORKSPACE/kernel_workspace
git clone ${{ env.KERNEL_SOURCE }} -b ${{ env.KERNEL_SOURCE_BRANCH }} android-kernel --depth=1
- name: Build kernel
run: |
cd $GITHUB_WORKSPACE/kernel_workspace/android-kernel
export PATH=$GITHUB_WORKSPACE/kernel_workspace/clang-aosp/bin:$PATH
export KBUILD_BUILD_HOST=Github-Action
export KBUILD_BUILD_USER=$(echo ${{ github.actor }} | tr A-Z a-z)
make -j$(nproc --all) O=out ARCH=arm64 CLANG_TRIPLE=aarch64-linux-gnu- CROSS_COMPILE=$GITHUB_WORKSPACE/kernel_workspace/gcc-aosp/bin/aarch64-linux-android- CC=clang ${{ env.BUILD_EXTRA_COMMAND }} ${{ env.KERNEL_DEFCONFIG }}
make -j$(nproc --all) O=out ARCH=arm64 CLANG_TRIPLE=aarch64-linux-gnu- CROSS_COMPILE=$GITHUB_WORKSPACE/kernel_workspace/gcc-aosp/bin/aarch64-linux-android- CC=clang ${{ env.BUILD_EXTRA_COMMAND }}
- name: Make Anykernel for your kernel
run: |
cd $GITHUB_WORKSPACE/kernel_workspace
git clone https://github.com/osm0sis/AnyKernel3
sed -i 's/do.devicecheck=1/do.devicecheck=0/g' AnyKernel3/anykernel.sh
sed -i 's!block=/dev/block/platform/omap/omap_hsmmc.0/by-name/boot;!block=auto;!g' AnyKernel3/anykernel.sh
sed -i 's/is_slot_device=0;/is_slot_device=auto;/g' AnyKernel3/anykernel.sh
cp android-kernel/out/arch/arm64/boot/${{ env.KERNEL_FILE }} AnyKernel3/
rm -rf AnyKernel3/.git* AnyKernel3/README.md
- name: Upload AnyKernel3
uses: actions/upload-artifact@v3
with:
name: AnyKernel3-KernelSU-${{ env.DEVICE }}-${{ env.BUILD_TIME }}
path: kernel_workspace/AnyKernel3/*