-
Notifications
You must be signed in to change notification settings - Fork 114
/
Copy pathaction.yml
557 lines (521 loc) · 24 KB
/
action.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
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
name: 'Android Kernel Build Action'
description: "A action to built android kernel."
branding:
icon: 'activity'
color: 'blue'
inputs:
kernel-url:
description: 'Kernel Source Url'
required: true
depth:
required: false
default: 1
vendor:
required: false
default: false
vendor-url:
description: 'Kernel Vendor Source Url'
required: false
kernel-dir:
required: false
default: kernel
vendor-dir:
required: false
default: vendor
kernel-branch:
description: 'Branch name for kernel source'
required: false
default: main
vendor-branch:
required: false
default: main
config:
description: 'configuration for building android kernel'
required: true
default: defconfig
arch:
required: true
default: arm64
android-version:
description: 'Android version.'
required: false
default: ""
ksu:
description: 'KernelSU function support'
required: false
default: false
ksu-version:
description: 'KernelSU default branch'
required: false
default: "main"
ksu-other:
required: false
default: false
ksu-url:
description: "Use 3rd KernelSU"
required: false
default: ""
ksu-lkm:
description: "Build KernelSU as a loadable kernel module"
required: false
default: false
disable-lto:
description: 'Disable LTO configs for configs.'
required: false
default: false
lxc:
description: 'Enable lxc and docker configs for configs.'
required: false
default: false
lxc-patch:
description: 'Apply lxc patch aviod not booting'
required: false
default: false
nethunter:
description: 'Enable Kali nethunter'
required: false
default: false
nethunter-patch:
description: 'patch config'
required: false
default: false
kvm:
description: 'Enable KVM for configs.'
required: false
default: false
ccache:
description: 'Enable Ccache for compiling kernel'
required: false
default: false
aosp-gcc:
description: 'Use gcc from aosp project.'
required: false
default: false
other-gcc32-url:
required: false
default: ''
other-gcc32-branch:
required: false
default: main
other-gcc64-url:
required: false
default: ''
other-gcc64-branch:
required: false
default: main
aosp-clang:
description: 'Use clang from aosp project.'
required: false
default: false
aosp-clang-version:
required: false
default: "r383902"
other-clang-url:
required: false
default: ''
other-clang-branch:
required: false
default: main
anykernel3:
description: 'Package kernel use anykernel3.'
required: false
default: false
anykernel3-url:
description: '3rdparty anykernrl3 url path'
required: false
default: ""
bootimg-url:
description: "boot.img path"
required: false
default: ""
release:
description: "After the kernel compilation is completed, it will be automatically published to the releases page"
required: false
default: false
access-token:
description: 'PAT with repository scope (https://github.com/settings/tokens)'
required: false
extra-cmd:
description: 'Extra options of building kernel.'
required: false
default: ""
runs:
using: 'composite'
steps:
- name: Setup ccache
if: inputs.ccache == 'true'
uses: hendrikmuhs/ccache-action@v1.2
with:
key: ${{ inputs.config }}-0cb68f9cbcbb3de9c966cf66ed51471fbe51419e
max-size: 4G
create-symlink: true
- name: Build Kernel
shell: bash
run: |
########
if [[ ${GITHUB_ACTIONS} != "true" || ${OSTYPE} != "linux-gnu" || ! -f /bin/apt ]]; then
printf "This Action Is Intended For Debian-based Runner.\n"
exit 127
fi
if [ "$(id -u)" -eq 0 ]; then
export SU=
else
export SU=sudo
fi
if [ -f /usr/bin/docker ]; then
echo "::group:: Cleaning necessary disk space"
echo "id: ${{ github.sha }}"
"$SU" docker image prune --all --force
fi
echo "::endgroup::"
echo "::group:: Installing Building Depend Packages"
"$SU" apt-get update
"$SU" apt-get install --no-install-recommends -y binutils git make bc bison openssl curl zip kmod cpio flex libelf-dev libssl-dev libtfm-dev libc6-dev device-tree-compiler ca-certificates python3 xz-utils libc6-dev aria2 build-essential ccache pigz
aria2c -q https://raw.githubusercontent.com/Homebrew/install/master/uninstall.sh && NONINTERACTIVE=1 bash ./uninstall.sh -f -q
echo "::endgroup::"
export SWAP_FILE=$(swapon --show=NAME | tail -n 1)
if [ -f /bin/swapon ]; then
echo "::group:: Setting Up Swap"
"$SU" swapoff $SWAP_FILE
"$SU" rm -v $SWAP_FILE
"$SU" fallocate -l 16G $SWAP_FILE
"$SU" chmod 600 -v $SWAP_FILE
"$SU" mkswap $SWAP_FILE
"$SU" swapon $SWAP_FILE
echo "::endgroup::"
fi
download_and_extract() {
local url=$1
local output_name=$2
local extract_dir=$3
local branch=${4:-main}
mkdir -p -v "$extract_dir"
case "$url" in
*.tar.gz)
aria2c -o "${output_name}.tar.gz" "$url"
tar -C "$extract_dir" -zxf "${output_name}.tar.gz"
;;
*.zip)
aria2c -o "${output_name}.zip" "$url"
unzip -q "${output_name}.zip" -d "$extract_dir"
;;
*.tar.xz)
aria2c -o "${output_name}.tar.xz" "$url"
tar -C "$extract_dir" -xf "${output_name}.tar.xz"
;;
*.xz)
aria2c -o "${output_name}.xz" "$url"
tar -C "$extract_dir" -xf "${output_name}.xz"
;;
*)
git clone "$url" "$extract_dir" --depth=${{ inputs.depth }} -b "$branch"
;;
esac
}
if [ ${{ inputs.aosp-clang }} = true ]; then
echo "::group:: Downloading AOSP clang"
if [ ${{ inputs.aosp-gcc }} = true ]; then
mkdir $HOME/clang -p -v
if [ ! -z ${{ inputs.android-version }} ]; then
aria2c -o aosp-clang.tar.gz https://android.googlesource.com/platform/prebuilts/clang/host/linux-x86/+archive/refs/heads/android${{ inputs.android-version }}-release/clang-${{ inputs.aosp-clang-version }}.tar.gz
else
aria2c -o aosp-clang.tar.gz https://android.googlesource.com/platform/prebuilts/clang/host/linux-x86/+archive/refs/heads/main/clang-${{ inputs.aosp-clang-version }}.tar.gz
fi
tar -C $HOME/clang -zxf aosp-clang.tar.gz
else
echo "Please enable aosp-gcc."
exit 127
fi
elif [ ! -z ${{ inputs.other-clang-url }} ]; then
echo "::group:: Downloading Third party clang"
export OTHER_CLANG_URL=${{ inputs.other-clang-url }}
download_and_extract "$OTHER_CLANG_URL" "clang" "$HOME/clang" "${{ inputs.other-clang-branch }}"
[ ! -d $HOME/clang/bin/ ] && mv $HOME/clang/*/* $HOME/clang/
if ! ls "$HOME/clang/*-linux-*" &>/dev/null; then
echo "Binutils not found in clang directory. Downloading AOSP GCC"
export NEED_GCC=1
fi
fi
echo "::endgroup::"
if [ ${{ inputs.aosp-gcc }} = true ] || [ ! -z "$NEED_GCC" ]; then
echo "::group:: Downloading AOSP GCC"
if [ ! -z ${{ inputs.android-version }} ]; then
git clone https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/ --depth=1 -b android${{ inputs.android-version }}-release $HOME/gcc-64
git clone https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9/ --depth=1 -b android${{ inputs.android-version }}-release $HOME/gcc-32
else
mkdir -p -v $HOME/gcc-64 $HOME/gcc-32
aria2c -o gcc-aarch64.tar.gz https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/+archive/refs/tags/android-12.1.0_r27.tar.gz
tar -C $HOME/gcc-64 -zxf gcc-aarch64.tar.gz
aria2c -o gcc-arm.tar.gz https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9/+archive/refs/tags/android-12.1.0_r27.tar.gz
tar -C $HOME/gcc-32 -zxf gcc-arm.tar.gz
fi
elif [ ! -z ${{ inputs.other-gcc64-url }} ] || [ ! -z ${{ inputs.other-gcc32-url }} ]; then
echo "::group:: Downloading Third party GCC"
export OTHER_GCC64_URL=${{ inputs.other-gcc64-url }}
export OTHER_GCC32_URL=${{ inputs.other-gcc32-url }}
download_and_extract "$OTHER_GCC64_URL" "gcc-aarch64" "$HOME/gcc-64" "${{ inputs.other-gcc64-branch }}"
download_and_extract "$OTHER_GCC32_URL" "gcc-arm" "$HOME/gcc-32" "${{ inputs.other-gcc32-branch }}"
fi
[ ! -d $HOME/gcc-64/bin/ ] && mv $HOME/gcc-64/*/* $HOME/gcc-64/
[ ! -d $HOME/gcc-32/bin/ ] && mv $HOME/gcc-32/*/* $HOME/gcc-32/
echo "::endgroup::"
echo "::group:: Pulling Kernel Source"
git clone --recursive ${{ inputs.kernel-url }} -b "${{ inputs.kernel-branch }}" --depth=${{ inputs.depth }} kernel/${{ inputs.kernel-dir }}
echo "::endgroup::"
if [ "${{ inputs.vendor }}" = true ]; then
echo "::group:: Pulling Kernel vendor source"
git clone ${{ inputs.vendor-url }} --depth=${{ inputs.depth }} kernel/${{ inputs.vendor-dir }} -b ${{ inputs.vendor-branch }}
test -d kernel/${{ inputs.vendor-dir }}/vendor && cp -rv kernel/${{ inputs.vendor-dir }}/vendor kernel
test -d kernel/${{ inputs.vendor-dir }}/vendor && cp -rv kernel/${{ inputs.vendor-dir }}/vendor ./
echo "::endgroup::"
fi
cd kernel/${{ inputs.kernel-dir }}
if [ -d $HOME/gcc-64/bin/ ] || [ -d $HOME/gcc-32/bin/ ]; then
for GCC_DIR in "$HOME/gcc-64" "$HOME/gcc-32"; do
find "$GCC_DIR"/*/*/bin -type d -exec sh -c 'mv "$(dirname "{}")"/* "$GCC_DIR"/' _ {} \; -quit >/dev/null 2>&1 || true
for FILE in "$GCC_DIR/bin"/*; do
FILE_NAME=$(basename "$FILE")
MATCHED_DIR=""
for FOLDER in $(find "$GCC_DIR" -mindepth 1 -maxdepth 1 -type d | sort -r); do
FOLDER_NAME=$(basename "$FOLDER")
[[ "$FILE_NAME" == "$FOLDER_NAME"* ]] && MATCHED_DIR="$FOLDER_NAME" && break
done
[ -n "$MATCHED_DIR" ] && case "$GCC_DIR" in
"$HOME/gcc-64") GCC64="$MATCHED_DIR" ;;
"$HOME/gcc-32") GCC32="$MATCHED_DIR" ;;
esac
done
done
fi
function version_gt() { test "$(echo -e "$1\n$2" | sort -V | tail -n1)" == "$1"; }
VERSION=$(grep -E '^VERSION = ' Makefile | awk '{print $3}')
PATCHLEVEL=$(grep -E '^PATCHLEVEL = ' Makefile | awk '{print $3}')
SUBLEVEL=$(grep -E '^SUBLEVEL = ' Makefile | awk '{print $3}')
if [ "$VERSION" -lt 5 ]; then
touch nongki.txt
elif [ "$PATCHLEVEL" -lt 10 ]; then
echo false > nongki.txt
fi
if [ ${{ inputs.ksu }} = true ]; then
echo "::group:: Initializing KernelSU"
if [ -f KernelSU/kernel/Kconfig ]; then
echo "KernelSU has been initialized,skipped."
else
if [ ${{ inputs.ksu-other }} = true ]; then
curl -SsL "${{ inputs.ksu-url }}/raw/${{ inputs.ksu-version }}/kernel/setup.sh" | bash -s ${{ inputs.ksu-version }}
else
echo "Kernel version: $VERSION.$PATCHLEVEL.$SUBLEVEL"
if [ -f nongki.txt ]; then
printf "Warning: The KernelSU version you selected was detected to be ${{ inputs.ksu-version }}, but KernelSU has dropped support for the non-gki kernel since 0.9.5. \n This will force switch to v0.9.5.\n"
export KVER=v0.9.5
else
export KVER=${{ inputs.ksu-version }}
fi
curl -LSs "https://raw.githubusercontent.com/tiann/KernelSU/main/kernel/setup.sh" | bash -s "$KVER"
fi
fi
if [ ${{ inputs.ksu-lkm }} = true ]; then
if grep -q "CONFIG_KPROBES=y" "arch/${{ inputs.arch }}/configs/${{ inputs.config }}" ; then
sed -i 's/CONFIG_KSU=y/CONFIG_KSU=m/g' "arch/${{ inputs.arch }}/configs/${{ inputs.config }}"
else
#echo "CONFIG_KSU=m" | tee -a arch/${{ inputs.arch }}/configs/${{ inputs.config }}
sed -i '/config KSU/,/help/{s/default y/default m/}' drivers/kernelsu/Kconfig
fi
elif [ -f nongki.txt ]; then
if grep -q "CONFIG_KPROBES=y" "arch/${{ inputs.arch }}/configs/${{ inputs.config }}" ; then
echo "CONFIG_KPROBES is enabled, skip patch."
else
aria2c -q https://github.com/dabao1955/kernel_build_action/raw/main/kernelsu/patch.sh
grep -qs "may_mandlock(void)" fs/namespace.c || sed -i '110s|}}||' patch.sh; bash patch.sh
fi
fi
echo "::endgroup::"
fi
if [ -f scripts/dtc/libfdt/mkdtboimg.py ]; then
if grep python2 scripts/Makefile.lib >/dev/null; then
echo "::group:: Using mkdtboimg Python3 version instead of Python2 version"
rm -rf -v scripts/dtc/libfdt/mkdtboimg.py && aria2c https://github.com/dabao1955/kernel_build_action/raw/main/mkdtboimg.py -o scripts/dtc/libfdt/mkdtboimg.py
elif grep scripts/ufdt && test ! -d scripts/ufdt >/dev/null; then
aria2c https://github.com/dabao1955/kernel_build_action/raw/main/mkdtboimg.py -o ufdt/libufdt/utils/src/mkdtboimg.py
fi
test -f /usr/bin/python2 || "$SU" ln -s -f -v /usr/bin/python3 /usr/bin/python2
else
echo "::group:: Downloading mkdtboimg to /usr/local/bin"
sudo aria2c https://github.com/dabao1955/kernel_build_action/raw/main/mkdtboimg.py -o mkdtboimg
sudo chmod +x -v mkdtboimg
sudo mv mkdtboimg -v /usr/local/bin/mkdtboimg
fi
echo "::endgroup::"
if [ ${{ inputs.nethunter }} = true ]; then
echo "::group:: Initializing Kali nethunter"
aria2c https://github.com/dabao1955/kernel_build_action/raw/main/nethunter/config.sh -o nconfig.sh && bash nconfig.sh arch/${{ inputs.arch }}/configs/${{ inputs.config }} -w
if [ ${{ inputs.nethunter-patch }} = true ]; then
aria2c https://github.com/dabao1955/kernel_build_action/raw/main/nethunter/add-wifi-injection.patch && git apply add-wifi-injection.patch
aria2c apply https://github.com/dabao1955/kernel_build_action/raw/main/nethunter/fix-ath9k-naming-conflict.patch && git apply fix-ath9k-naming-confict.patch
if [ "$PATCHLEVEL" -lt "19" ]; then
aria2c https://github.com/dabao1955/kernel_build_action/raw/main/nethunter/add-wifi-injection-4.14.patch && git apply add-wifi-injection-4.14.patch
fi
else
echo "skip patch"
fi
echo "::endgroup::"
fi
if [ ${{ inputs.disable-lto }} = true ]; then
if grep -q "LTO" "arch/${{ inputs.arch }}/configs/${{ inputs.config }}"
then
sed -i 's/CONFIG_LTO=y/CONFIG_LTO=n/' arch/${{ inputs.arch }}/configs/${{ inputs.config }}
sed -i 's/CONFIG_LTO_CLANG=y/CONFIG_LTO_CLANG=n/' arch/${{ inputs.arch }}/configs/${{ inputs.config }}
sed -i 's/CONFIG_THINLTO=y/CONFIG_THINLTO=n/' arch/${{ inputs.arch }}/configs/${{ inputs.config }}
echo "CONFIG_LTO_NONE=y" | tee -a arch/${{ inputs.arch }}/configs/${{ inputs.config }} >/dev/null
fi
fi
if [ ${{ inputs.kvm }} = true ]; then
echo "CONFIG_VIRTUALIZATION=y" | tee -a arch/${{ inputs.arch }}/configs/${{ inputs.config }} >/dev/null
echo "CONFIG_KVM=y" | tee -a arch/${{ inputs.arch }}/configs/${{ inputs.config }} >/dev/null
echo "CONFIG_KVM_MMIO=y" | tee -a arch/${{ inputs.arch }}/configs/${{ inputs.config }} >/dev/null
echo "CONFIG_KVM_ARM_HOST=y" | tee -a arch/${{ inputs.arch }}/configs/${{ inputs.config }} >/dev/null
fi
if [ ${{ inputs.lxc }} = true ]; then
echo "::group:: Enabling LXC"
aria2c https://github.com/dabao1955/kernel_build_action/raw/main/lxc/config.sh && bash config.sh arch/${{ inputs.arch }}/configs/${{ inputs.config }} -w
if [ ${{ inputs.lxc-patch }} = true ]; then
curl -SsL https://github.com/dabao1955/kernel_build_action/raw/main/lxc/patch.sh | bash
else
echo skip lxc patching
fi
echo "::endgroup::"
fi
echo "::group:: Building Kernel with selected cross compiler"
mkdir out -p -v
COMMAND="make -j$(nproc --all) ${{ inputs.config }} ARCH=${{ inputs.arch }} all ${{ inputs.extra-cmd }} O=out"
if [ -d "$HOME/clang" ]; then
CMD_PATH="$HOME/clang/bin"
CMD_CC="clang"
if [ -d "$HOME/gcc-64/bin" ] || [ -d "$HOME/gcc-32/bin" ]; then
CMD_CROSS_COMPILE="$HOME/gcc-64/bin/${GCC64}-"
CMD_CROSS_COMPILE_ARM32="$HOME/gcc-32/bin/${GCC32}-"
CMD_CLANG_TRIPLE="aarch64-linux-gnu-"
fi
elif [ -d "$HOME/gcc-64/bin" ] || [ -d "$HOME/gcc-32/bin" ]; then
CMD_PATH="$HOME/gcc-64/bin:$HOME/gcc-32/bin"
if [ -n "${GCC64}" ]; then
CMD_CC="$HOME/gcc-64/bin/${GCC64}-gcc"
else
CMD_CC="$HOME/gcc-32/bin/${GCC32}-gcc"
fi
CMD_CROSS_COMPILE="${GCC64}-"
CMD_CROSS_COMPILE_ARM32="${GCC32}-"
CMD_CLANG_TRIPLE="aarch64-linux-gnu-"
fi
if [ ${{ inputs.ccache }} = true ]; then
# enable ccache
export USE_CCACHE=1
# ensure /usr/lib/ccache is first inside CMD_PATH
CMD_PATH="/usr/lib/ccache:${CMD_PATH}"
# verify compiler exist in /usr/lib/ccache
if [ -d "${HOME}/clang" ]; then
[ ! -e /usr/lib/clang ] && \
ln -s /usr/lib/clang /usr/bin/ccache
else
if [ -n "${GCC64}" ]; then
[ ! -e "/usr/lib/${GCC64}-gcc" ] && \
ln -s "/usr/lib/${GCC64}-gcc" /usr/bin/ccache
else
[ ! -e "/usr/lib/${GCC32}-gcc" ] && \
ln -s "/usr/lib/${GCC32}-gcc" /usr/bin/ccache
fi
fi
fi
# setup additional commands
COMMAND+=" PATH=${CMD_PATH}:${PATH} CROSS_COMPILE=${CMD_CROSS_COMPILE} CROSS_COMPILE_ARM32=${CMD_CROSS_COMPILE_ARM32} CLANG_TRIPLE=${CMD_CLANG_TRIPLE} CC=${CMD_CC}"
# run the command
${COMMAND}
echo "::endgroup::"
unset CMD_PATH CMD_CC CMD_CLANG_TRIPLE CMD_CROSS_COMPILE CMD_CROSS_COMPILE_ARM32 USE_CCACHE CLANG_TRIPLE CROSS_COMPILE_ARM32 CROSS_COMPILE CLANG_PATH HOMES KVER COMMAND SWAP_FILE SUBLEVEL PATCHLEVEL VERSION GCC_DIR FILE FILE_NAME MATCHED_DIR FOLDER FOLDER_NAME GCC64 GCC32 NEED_GCC
if [ ${{ inputs.anykernel3 }} = false ]; then
echo "::group:: Preparing to Upload boot.img"
mkdir split
cd split
export HOST_ARCH=$(dpkg --print-architecture)
case ${HOST_ARCH} in
armv7* | armv8l | arm64 | armhf | arm) aria2c https://github.com/Shubhamvis98/AIK/raw/4ac321dfd48e16344e6146c505708aa720ff0bb3/bin/magiskboot_arm -o magiskboot && chmod 755 magiskboot ;;
i*86 | x86 | amd64 | x86_64) aria2c https://github.com/Shubhamvis98/AIK/raw/4ac321dfd48e16344e6146c505708aa720ff0bb3/bin/magiskboot_x86 -o magiskboot && chmod 755 magiskboot ;;
*) echo "Unknow cpu architecture for this device !" && exit 1 ;;
esac
aria2c ${{ inputs.bootimg-url }} -o boot.img
nohup ./magiskboot unpack boot.img
export FMT=$(cat nohup.out | grep "KERNEL_FMT" | awk '{gsub("\\[", "", $2); gsub("\\]", "", $2); print $2}')
if [ "$FMT" = "raw" ] ; then
cp -v ../out/arch/${{ inputs.arch }}/boot/Image kernel
else
if ls dtb >/dev/null ; then
cp -v ../out/arch/${{ inputs.arch }}/boot/Image.*-dtb kernel
else
cp -v ../out/arch/${{ inputs.arch }}/boot/Image.* kernel
fi
fi
./magiskboot repack boot.img
rm -rf boot.img
mkdir -p -v ../../../build
mv *.img ../../../build/boot.img -v
cd ..
echo "::endgroup::"
else
echo "::group:: Packaging Anykernel3 flasher"
if [ ! -z ${{ inputs.anykernel3-url }} ]; then
git clone ${{ inputs.anykernel3-url }} AnyKernel3
else
git clone https://github.com/osm0sis/AnyKernel3
sed -i 's!BLOCK=/dev/block/platform/omap/omap_hsmmc.0/by-name/boot;!BLOCK=auto;!g' AnyKernel3/anykernel.sh
sed -i 's/do.devicecheck=1/do.devicecheck=0/g' AnyKernel3/anykernel.sh
sed -i 's/IS_SLOT_DEVICE=0;/IS_SLOT_DEVICE=auto;/g' AnyKernel3/anykernel.sh
fi
if [ -f out/arch/${{ inputs.arch }}/boot/Image.*-dtb ]; then
cp out/arch/${{ inputs.arch }}/boot/Image.*-dtb AnyKernel3/ -rv
elif [ -f out/arch/${{ inputs.arch }}/boot/Image.* ]; then
cp out/arch/${{ inputs.arch }}/boot/Image.* AnyKernel3/ -rv
else
cp out/arch/${{ inputs.arch }}/boot/Image AnyKernel3/ -rv
fi
test -f out/arch/${{ inputs.arch }}/boot/dtbo.img && cp -v out/arch/${{ inputs.arch }}/boot/dtbo.img AnyKernel3/
test -f out/arch/${{ inputs.arch }}/boot/dtb && cp -v out/arch/${{ inputs.arch }}/boot/dtb AnyKernel3/
rm -rf -v AnyKernel3/.git* AnyKernel3/README.md
mkdir -p -v ../../build
if [ ${{ inputs.release }} = false ]; then
cp -r -v AnyKernel3/* ../../build
else
zip Anykernel3-flasher.zip AnyKernel3/*
mv -v Anykernel3-flasher.zip ../../build/
fi
echo "::endgroup::"
fi
- id: uploadi
if: ${{ inputs.release == 'false' && inputs.anykernel3 == 'false' }}
uses: actions/upload-artifact@v4
with:
name: kernel-built-bootimg
path: build/*
if-no-files-found: error
overwrite: true
- id: uploada
if: ${{ inputs.release == 'false' && inputs.anykernel3 == 'true' }}
uses: actions/upload-artifact@v4
with:
name: Anykernel3-flasher
path: build/*
if-no-files-found: error
overwrite: true
- id: release
if: inputs.release == 'true'
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ inputs.access-token }}
with:
name: Last CI build kernel
tag_name: last-ci-${{ github.sha }}
files: build/*
make_latest: true
body: |
config: ${{ inputs.config }}
branch: ${{ inputs.kernel-branch }}
source: ${{ inputs.kernel-url }}