-
Notifications
You must be signed in to change notification settings - Fork 1
252 lines (224 loc) · 11.6 KB
/
build.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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
name: Build GKI
on:
workflow_dispatch:
inputs:
KSU:
description: "KSU?"
required: true
default: "true"
type: boolean
SUSFS:
description: "SUSFS?"
required: true
default: "true"
type: boolean
jobs:
build:
name: Build GKI by ${{ github.actor }}
runs-on: ubuntu-22.04
steps:
- name: Check out
uses: actions/checkout@v4
- name: Read the configuration
run: |
CONFIG_ENV=$GITHUB_WORKSPACE/config.properties.gki_12510
grep -v '^#' "$CONFIG_ENV" | grep '=' | while IFS= read -r line; do
key=$(echo "$line" | cut -d'=' -f1)
value=$(echo "$line" | cut -d'=' -f2-)
echo "$key=$value" >> $GITHUB_ENV
done
- name: Setting up the kernel compilation environment
run: |
echo "BUILD_TIME=$(TZ=Asia/Makassar date "+%Y%m%d-%H%M")" >> $GITHUB_ENV
sudo apt update
sudo apt install -y 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 rename libelf-dev dwarves zstd
sudo apt list --upgradable
sudo apt upgrade
mkdir -p $GITHUB_WORKSPACE/kernel_workspace
chmod +x $GITHUB_WORKSPACE/*.sh
- name: Set Swap
uses: pierotofy/set-swap-space@master
with:
swap-size-gb: 12
- name: Download AOSP Clang
if: env.USE_AOSP_CLANG == 'true' && env.USE_CUSTOM_CLANG == 'false'
run: |
cd $GITHUB_WORKSPACE/kernel_workspace
mkdir clang
wget https://android.googlesource.com/platform/prebuilts/clang/host/${{ env.AOSP_CLANG_SYSTEM }}/+archive/refs/heads/${{ env.AOSP_CLANG_BRANCH }}/clang-${{ env.AOSP_CLANG_VERSION }}.tar.gz
tar -C clang/ -zxf clang-${{ env.AOSP_CLANG_VERSION }}.tar.gz
rm -rf clang-${{ env.AOSP_CLANG_VERSION }}.tar.gz
- name: Download Custom Clang
if: env.USE_AOSP_CLANG == 'false' && env.USE_CUSTOM_CLANG == 'true'
run: |
cd $GITHUB_WORKSPACE/kernel_workspace
if [[ ${{ env.CUSTOM_CLANG_SOURCE }} =~ git ]]; then
if [[ ${{ env.CUSTOM_CLANG_SOURCE }} == *'.tar.'* ]]; then
wget ${{ env.CUSTOM_CLANG_SOURCE }}
mkdir clang
tar -C clang/ -xf *.tar.*
rm -f *.tar.*
else
git clone ${{ env.CUSTOM_CLANG_SOURCE }} -b ${{ env.CUSTOM_CLANG_BRANCH }} clang --depth=1
fi
else
if [[ -n "${{ env.CUSTOM_CLANG_COMMAND }}" ]]; then
bash -c "${{ env.CUSTOM_CLANG_COMMAND }}"
else
echo "[ERROR] You must specify CUSTOM_CLANG_COMMAND in config file!"
exit 1
fi
fi
- name: Download AOSP GCC
if: env.USE_CUSTOM_GCC_64 == 'false' && env.USE_CUSTOM_GCC_32 == 'false' && env.ENABLE_AOSP_GCC_ARM64 == 'true' || env.ENABLE_AOSP_GCC_ARM32 == 'true'
run: |
cd $GITHUB_WORKSPACE/kernel_workspace
if [ ${{ env.ENABLE_AOSP_GCC_ARM64 }} = true ]; then
mkdir gcc-64
wget https://android.googlesource.com/platform/prebuilts/gcc/${{ env.AOSP_GCC_SYSTEM }}/aarch64/${{ env.AOSP_GCC_ARM64_VERSION }}/+archive/refs/tags/android-${{ env.AOSP_GCC_ANDROID_VERSION }}_${{ env.AOSP_GCC_RELEASE }}.tar.gz
tar -C ./gcc-64/ -zxf *.tar.gz
echo "GCC_64=CROSS_COMPILE=$GITHUB_WORKSPACE/kernel_workspace/gcc-64/bin/aarch64-linux-android-" >> $GITHUB_ENV
fi
if [ ${{ env.ENABLE_AOSP_GCC_ARM32 }} = true ]; then
mkdir gcc-32
wget https://android.googlesource.com/platform/prebuilts/gcc/${{ env.AOSP_GCC_SYSTEM }}/arm/${{ env.AOSP_GCC_ARM32_VERSION }}/+archive/refs/tags/android-${{ env.AOSP_GCC_ANDROID_VERSION }}_${{ env.AOSP_GCC_RELEASE }}.tar.gz
tar -C ./gcc-32/ -zxf *.tar.gz
echo "GCC_32=CROSS_COMPILE_ARM32=$GITHUB_WORKSPACE/kernel_workspace/gcc-32/bin/arm-linux-androideabi-" >> $GITHUB_ENV
fi
rm -f *.tar.gz
- name: Download Custom Gcc
if: env.USE_CUSTOM_GCC_64 == 'true' || env.USE_CUSTOM_GCC_32 == 'true' && env.ENABLE_AOSP_GCC_ARM32 == 'false' && env.ENABLE_AOSP_GCC_ARM64 == 'false'
run: |
cd $GITHUB_WORKSPACE/kernel_workspace
if [ ${{ env.USE_CUSTOM_GCC_64 }} = true ]; then
if [[ ${{ env.CUSTOM_GCC_64_SOURCE }} =~ git ]]; then
if [[ ${{ env.CUSTOM_GCC_64_SOURCE }} == *'.tar.'* ]]; then
wget ${{ env.CUSTOM_CLANG_SOURCE }}
mkdir gcc-64
tar -C gcc-64/ -xf *.tar.*
else
git clone ${{ env.CUSTOM_GCC_64_SOURCE }} -b ${{ env.CUSTOM_GCC_64_BRANCH }} gcc-64 --depth=1
fi
else
wget -O gcc-64.zip ${{ env.CUSTOM_GCC_64_SOURCE }}
mkdir gcc-64
unzip gcc-64.zip -d gcc-64/
fi
echo "GCC_64=CROSS_COMPILE=$GITHUB_WORKSPACE/kernel_workspace/gcc-64/bin/${{ env.CUSTOM_GCC_64_BIN }}" >> $GITHUB_ENV
fi
if [ ${{ env.USE_CUSTOM_GCC_32 }} = true ]; then
if [[ ${{ env.CUSTOM_GCC_32_SOURCE }} =~ git ]]; then
if [[ ${{ env.CUSTOM_GCC_32_SOURCE }} == *'.tar.'* ]]; then
wget ${{ env.CUSTOM_CLANG_SOURCE }}
mkdir gcc-32
tar -C gcc-32/ -xf *.tar.*
else
git clone ${{ env.CUSTOM_GCC_32_SOURCE }} -b ${{ env.CUSTOM_GCC_32_BRANCH }} gcc-32 --depth=1
fi
else
wget -O gcc-32.zip ${{ env.CUSTOM_GCC_32_SOURCE }}
mkdir gcc-32
unzip gcc-32.zip -d gcc-32/
fi
echo "GCC_32=CROSS_COMPILE_ARM32=$GITHUB_WORKSPACE/kernel_workspace/gcc-32/bin/${{ env.CUSTOM_GCC_32_BIN }}" >> $GITHUB_ENV
fi
rm -f *.tar.*
rm -f *.zip
- name: Download the kernel source code
run: |
cd $GITHUB_WORKSPACE/kernel_workspace
git clone ${{ env.KERNEL_SOURCE }} -b ${{ env.KERNEL_SOURCE_BRANCH }} android-kernel --depth=1
cd $GITHUB_WORKSPACE/kernel_workspace/android-kernel
echo "KVER=$(make kernelversion 2>/dev/null)" >> $GITHUB_ENV
- name: Download the AnyKernel
run: |
git clone --depth=1 ${{ env.ANYKERNEL_REPO }} -b ${{ env.ANYKERNEL_BRANCH }} $GITHUB_WORKSPACE/kernel_workspace/anykernel
- name: Setup KernelSU
if: inputs.KSU == true
run: |
cd $GITHUB_WORKSPACE/kernel_workspace/android-kernel
curl -LSs "https://raw.githubusercontent.com/tiann/KernelSU/main/kernel/setup.sh" | bash -
echo "ZIP_NAME=$(echo "${{ env.ZIP_NAME }}" | sed "s/OPTION1/KSU/g")" >> $GITHUB_ENV
- name: Setup SUSFS for KSU
if: inputs.KSU == true && inputs.SUSFS == true
run: |
cd $GITHUB_WORKSPACE/kernel_workspace
git clone --depth=1 "https://gitlab.com/simonpunk/susfs4ksu" -b "gki-android12-5.10"
SUSFS_PATCHES="$GITHUB_WORKSPACE/kernel_workspace/susfs4ksu/kernel_patches"
SUSFS_MODULE="$GITHUB_WORKSPACE/kernel_workspace/susfs4ksu/ksu_module_susfs"
cd "$GITHUB_WORKSPACE/kernel_workspace/android-kernel"
cp "$SUSFS_PATCHES/50_add_susfs_in_gki-android12-5.10.patch" .
cp "$SUSFS_PATCHES/fs/susfs.c" ./fs/
cp "$SUSFS_PATCHES/include/linux/susfs.h" ./include/linux/
cp "$SUSFS_PATCHES/fs/sus_su.c" ./fs/
cp "$SUSFS_PATCHES/include/linux/sus_su.h" ./include/linux/
cd "$GITHUB_WORKSPACE/kernel_workspace/android-kernel/KernelSU"
cp "$SUSFS_PATCHES/KernelSU/10_enable_susfs_for_ksu.patch" .
patch -p1 <10_enable_susfs_for_ksu.patch || exit 1
cd "$GITHUB_WORKSPACE/kernel_workspace/android-kernel"
patch -p1 <50_add_susfs_in_gki-android12-5.10.patch || exit 1
echo "SUSFS_MODULE=$GITHUB_WORKSPACE/kernel_workspace/susfs4ksu/ksu_module_susfs" >> $GITHUB_ENV
echo "SUSFS_MODULE_ZIP=ksu_module_susfs.zip" >> $GITHUB_ENV
echo "ZIP_NAME=$(echo "${{ env.ZIP_NAME }}" | sed "s/KSU/KSUxSUSFS/g")" >> $GITHUB_ENV
- name: Build kernel
run: |
cd $GITHUB_WORKSPACE/kernel_workspace/android-kernel
export PATH="$GITHUB_WORKSPACE/kernel_workspace/clang/bin:$GITHUB_WORKSPACE/kernel_workspace/gcc-64/bin:$GITHUB_WORKSPACE/kernel_workspace/gcc-32/bin:$PATH"
export KBUILD_BUILD_HOST=gacorprjkt
export KBUILD_BUILD_USER=${{ github.actor }}
make -j$(nproc --all) CC=clang O=out ARCH=${{ env.ARCH }} ${{ env.TC_CUSTOM_CMDS }} ${{ env.EXTRA_CMDS }} ${{ env.GCC_64 }} ${{ env.GCC_32 }} ${{ env.KERNEL_CONFIG }}
make -j$(nproc --all) CC=clang O=out ARCH=${{ env.ARCH }} ${{ env.TC_CUSTOM_CMDS }} ${{ env.EXTRA_CMDS }} ${{ env.GCC_64 }} ${{ env.GCC_32 }} 2>&1 | tee $GITHUB_WORKSPACE/kernel_workspace/build.log
- name: Checking the kernel compilation product
run: |
cd $GITHUB_WORKSPACE/kernel_workspace
if [ ! -f android-kernel/out/arch/${{ env.ARCH }}/boot/${{ env.KERNEL_IMAGE_NAME }} ]; then
export TOKEN="${{ secrets.TOKEN }}"
export CHAT_ID="${{ secrets.CHAT_ID }}"
$GITHUB_WORKSPACE/upload_to_tg.sh "$GITHUB_WORKSPACE/kernel_workspace/build.log"
exit 1
fi
- name: Replace Placeholder
run: |
set -x
if [[ "${{ inputs.KSU }}" == "false" ]]; then
echo "ZIP_NAME=$(echo "${{ env.ZIP_NAME }}" | sed "s/OPTION1-//g")" >> $GITHUB_ENV
fi
echo "ZIP_NAME=$(echo "${{ env.ZIP_NAME }}" | sed "s/OPTION2/${{ env.BUILD_TIME }}/g; s/KVER/${{ env.KVER }}/g")" >> $GITHUB_ENV
cd $GITHUB_WORKSPACE/kernel_workspace/anykernel
sed -i "s/DUMMY1/${{ env.KVER }}/g" anykernel.sh
if [[ "${{ inputs.KSU }}" == "false" ]]; then
sed -i "s/KSUDUMMY2 //g" anykernel.sh
elif [[ "${{ inputs.SUSFS }}" == "true" ]]; then
sed -i "s/DUMMY2/xSUSFS/g" anykernel.sh
elif [[ "${{ inputs.SUSFS }}" == "false" ]]; then
sed -i "s/DUMMY2//g" anykernel.sh
fi
sed -i "s/DUMMY3/${{ env.BUILD_TIME }}/g" anykernel.sh
set +x
- name: Zipping Kernel
run: |
set -x
cp $GITHUB_WORKSPACE/kernel_workspace/android-kernel/out/arch/${{ env.ARCH }}/boot/${{ env.KERNEL_IMAGE_NAME }} $GITHUB_WORKSPACE/kernel_workspace/anykernel
cd $GITHUB_WORKSPACE/kernel_workspace/anykernel
zip -r9 "${{ env.ZIP_NAME }}" * -x LICENSE
mv "${{ env.ZIP_NAME }}" $GITHUB_WORKSPACE/kernel_workspace
set +x
- name: Zipping SUSFS module
if: inputs.SUSFS == true && inputs.KSU == true
run: |
cd ${{ env.SUSFS_MODULE }}
zip -r9 ${{ env.SUSFS_MODULE_ZIP }} *
mv ${{ env.SUSFS_MODULE_ZIP }} $GITHUB_WORKSPACE/kernel_workspace
- name: Upload to Telegram (Kernel)
run: |
ls -lh $GITHUB_WORKSPACE/kernel_workspace
export TOKEN="${{ secrets.TOKEN }}"
export CHAT_ID="${{ secrets.CHAT_ID }}"
$GITHUB_WORKSPACE/upload_to_tg.sh "$GITHUB_WORKSPACE/kernel_workspace/${{ env.ZIP_NAME }}"
$GITHUB_WORKSPACE/upload_to_tg.sh "$GITHUB_WORKSPACE/kernel_workspace/build.log"
- name: Upload to Telegram (susfs module)
if: inputs.SUSFS == true && inputs.KSU == true
run: |
export TOKEN="${{ secrets.TOKEN }}"
export CHAT_ID="${{ secrets.CHAT_ID }}"
$GITHUB_WORKSPACE/upload_to_tg.sh "$GITHUB_WORKSPACE/kernel_workspace/${{ env.SUSFS_MODULE_ZIP }}"