forked from Fyg369/Kernel-Action
-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
623 lines (585 loc) · 28.1 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
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
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'
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: true
default: 12
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
kprobes:
description: 'Enable kprobes for ksu'
required: false
default: false
disable_fst:
description: 'Disable FST configs for configs.'
required: false
default: false
disable_cc_werror:
description: 'Disable CC_WERROR configs for configs.'
required: false
default: false
bbrplus:
description: 'Enable bbrplus and docker configs for configs.'
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: true
default: true
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
android-ndk:
description: 'Use Android NDK to build kernrl (Experimental features)'
required: false
default: false
android-ndk-version:
description: 'Please press nember instead of r(e.g. : 26).'
required: false
default: r21b
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/[email protected]
with:
key: ${{ inputs.config }}-0cb68f9cbcbb3de9c966cf66ed51471fbe51419e
max-size: 4G
- 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
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 $SWAP_FILE
"$SU" fallocate -l 16G $SWAP_FILE
"$SU" chmod 600 $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}
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"
;;
*)
git clone "$url" "$extract_dir" --depth=${{ inputs.depth }} -b "$branch"
;;
esac
}
if [ ${{ inputs.aosp-clang }} = false ] && [ ${{ inputs.android-ndk }} = false ]; then
echo "::group:: Downloading 3rd clang"
export OTHER_CLANG_URL=${{ inputs.other-clang-url }}
mkdir -p -v $HOME/clang
download_and_extract "$OTHER_CLANG_URL" "clang" "$HOME/clang" "${{ inputs.other-clang-branch }}"
if [ ! -d $HOME/clang/bin/ ]; then
mv $HOME/clang/*/* $HOME/clang/
fi
fi
echo "::endgroup::"
if [ ${{ inputs.android-ndk }} = true ]; then
echo "::group:: Downloading Android NDK"
if [ ${{ inputs.aosp-gcc }} = false ]; then
export NDKVER=$(echo "${{ inputs.android-ndk-version }}" | sed 's/r\([0-9]\+\)[a-zA-Z]\?/\1/g')
if [ "$NDKVER" -lt "23" ]; then
aria2c -o android-ndk.zip https://dl.google.com/android/repository/android-ndk-${{ inputs.android-ndk-version }}-linux-x86_64.zip
unzip -d $HOME android-ndk.zip
else
aria2c -o android-ndk.zip https://dl.google.com/android/repository/android-ndk-${{ inputs.android-ndk-version }}-linux.zip
unzip -d $HOME android-ndk.zip
fi
else
echo "Please disable aosp-gcc and aosp-clang."
exit 127
fi
echo "::endgroup::"
export HOMES=$(pwd)
export LLVMS=$HOME/android-ndk-${{ inputs.android-ndk-version }}/toolchains/llvm/prebuilt/linux-x86_64/bin
cd $LLVMS
for file in $(ls llvm-*); do
ln -s -v "$file" "aarch64-linux-android$(( ${{ inputs.android-version }} + 19 ))-${file#llvm-}"
done
cd $HOMES
fi
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
echo "::endgroup::"
fi
if [ ${{ inputs.aosp-gcc }} = true ]; then
if [ ! -z ${{ inputs.other-gcc64-url }} ] || [ ! -z ${{ inputs.other-gcc32-url }} ]; then
echo "::group:: Downloading 3rd gcc"
if [ ! -z ${{ inputs.other-gcc64-url }} ] && [ ! -z ${{ inputs.other-gcc32-url }} ]; then
if [ -d $HOME/clang ]; then
export OTHER_GCC64_URL=${{ inputs.other-gcc64-url }}
export OTHER_GCC32_URL=${{ inputs.other-gcc32-url }}
mkdir -p -v $HOME/gcc-64
download_and_extract "$OTHER_GCC64_URL" "gcc-aarch64" "$HOME/gcc-64" "${{ inputs.other-gcc64-branch }}"
mkdir -p -v $HOME/gcc-32
download_and_extract "$OTHER_GCC32_URL" "gcc-arm" "$HOME/gcc-32" "${{ inputs.other-gcc32-branch }}"
fi
else
echo "Error: Please enable 3rd other-gcc32-url and other-gcc64-url." && exit 15
fi
else
echo "::group:: Downloading AOSP GCC"
if [ -d $HOME/clang ]; then
mkdir -p -v $HOME/gcc-64
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
mkdir -p -v $HOME/gcc-32
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
elif [ ${{ inputs.aosp-clang }} = true ] && [ ${{ inputs.android-ndk }} = true ]; then
echo "Error: The two options aosp-clang and android-ndk will conflict with each other, please turn off one." && exit 15
else
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
fi
fi
if [ ! -d $HOME/gcc-64/bin/ ] || [ ! -d $HOME/gcc-32/bin/ ]; then
[ ! -d $HOME/gcc-64/bin/ ] && mv $HOME/gcc-64/*/* $HOME/gcc-64/
[ ! -d $HOME/gcc-32/bin/ ] && mv $HOME/gcc-32/*/* $HOME/gcc-32/
fi
fi
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 ! grep -qsi "LD *= *ld.lld" Makefile && [ -f "$HOME/clang/bin/ld" ]; then
rm -f "$HOME/clang/bin/ld"
fi
if [ ! -z ${{ inputs.other-gcc64-url }} ] && [ ! -z ${{ inputs.other-gcc32-url }} ]; then
[ ! -d $HOME/gcc-64/aarch64-elf ] || [ ! -d $HOME/gcc-32/arm-eabi ] || {
for gcc_dir in "$HOME/gcc-64" "$HOME/gcc-32"; do
gcc_name="${gcc_dir}/$([ "$gcc_dir" == "$HOME/gcc-64" ] && echo "aarch64-elf" || echo "arm-eabi")"
if [ ! -d "$gcc_name" ]; then
find "$gcc_dir"/*/*/ -type d -name bin -exec dirname {} \; -exec mv {} "$gcc_dir/$gcc_name" \; -quit
[ ! -d "$gcc_name" ] && find "$gcc_dir"/*/ -type d -name bin -exec dirname {} \; -exec mv {} "$gcc_name" \; -quit
fi
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
touch nongki.txt
fi
if [ ${{ inputs.ksu }} = true ]; then
echo "::group:: Initializing KernelSU"
if grep -qsi "path = .*KernelSU" .gitmodules || [ -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
curl -SsL https://github.com/Fyg369/Kernel-Action/raw/main/patch.sh | bash
fi
fi
echo "::endgroup::"
fi
if [ -f scripts/dtc/libfdt/mkdtboimg.py ]; then
if grep python2 scripts/Makefile.lib >/dev/null; then
echo "::group:: Uning mkdtboimg Python3 version instead of Python2 version"
rm -rf -v scripts/dtc/libfdt/mkdtboimg.py && aria2c https://github.com/Fyg369/Kernel-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/Fyg369/Kernel-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
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 --whitespace=nowarn add-wifi-injection.patch
aria2c https://github.com/dabao1955/kernel_build_action/raw/main/nethunter/fix-ath9k-naming-conflict.patch && git apply --whitespace=nowarn fix-ath9k-naming-conflict.patch
aria2c https://raw.githubusercontent.com/dabao1955/kernel_build_action/main/nethunter/add-rtl88xxau-5.6.4.2-drivers.patch && git apply --whitespace=nowarn add-rtl88xxau-5.6.4.2-drivers.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 --whitespace=nowarn add-wifi-injection-4.14.patch
fi
else
echo "skip patch"
fi
echo "::endgroup::"
fi
if [ ${{ inputs.bbrplus }} = true ]; then
echo "::group:: Initializing bbrplus"
aria2c https://raw.githubusercontent.com/UJX6N/bbrplus-4.9/main/convert_official_linux-4.9.x_src_to_bbrplus.patch && git apply --whitespace=nowarn convert_official_linux-4.9.x_src_to_bbrplus.patch
echo "::endgroup::"
fi
if [ ${{ inputs.disable_fst }} = true ]; then
grep -q "CONFIG_CC_STACKPROTECTOR_STRONG=y" "arch/${{ inputs.arch }}/configs/${{ inputs.config }}" || sed -i 's/CONFIG_CC_STACKPROTECTOR_STRONG=y/# CONFIG_CC_STACKPROTECTOR_STRONG is not set/g' arch/${{ inputs.arch }}/configs/${{ inputs.config }}
fi
if [ ${{ inputs.disable_cc_werror }} = true ]; then
grep -q "CONFIG_CC_WERROR=n" "arch/${{ inputs.arch }}/configs/${{ inputs.config }}" || echo "CONFIG_CC_WERROR=n" | tee -a arch/${{ inputs.arch }}/configs/${{ inputs.config }} >/dev/null
fi
if [ ${{ inputs.kprobes }} = true ]; then
grep -q "CONFIG_MODULES=y" "arch/${{ inputs.arch }}/configs/${{ inputs.config }}" || echo "CONFIG_MODULES=y" | tee -a arch/${{ inputs.arch }}/configs/${{ inputs.config }} >/dev/null
grep -q "CONFIG_KPROBES=y" "arch/${{ inputs.arch }}/configs/${{ inputs.config }}" || echo "CONFIG_KPROBES=y" | tee -a arch/${{ inputs.arch }}/configs/${{ inputs.config }} >/dev/null
grep -q "CONFIG_HAVE_KPROBES=y" "arch/${{ inputs.arch }}/configs/${{ inputs.config }}" || echo "CONFIG_HAVE_KPROBES=y" | tee -a arch/${{ inputs.arch }}/configs/${{ inputs.config }} >/dev/null
grep -q "CONFIG_KPROBE_EVENTS=y" "arch/${{ inputs.arch }}/configs/${{ inputs.config }}" || echo "CONFIG_KPROBE_EVENTS=y" | tee -a arch/${{ inputs.arch }}/configs/${{ inputs.config }} >/dev/null
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
aria2c https://github.com/dabao1955/kernel_build_action/raw/main/lxc/xt_qtaguid.patch
aria2c https://github.com/dabao1955/kernel_build_action/raw/main/lxc/cgroup.patch
patch kernel/cgroup/cgroup.c < cgroup.patch
patch net/netfilter/xt_qtaguid.c < xt_qtaguid.patch
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
COMMAND+=" PATH=$HOME/clang/bin:$PATH"
elif [ ${{ inputs.android-ndk }} = true ]; then
export PATH=$CLANG_PATH/bin:$PATH
COMMAND+=" CLANG_PATH=$HOME/android-ndk-${{ inputs.android-ndk-version }}/toolchains/llvm/prebuilt/linux-x86_64"
fi
if [ ${{ inputs.aosp-gcc }} = true ]; then
if [ -d $HOME/gcc-64/aarch64-elf ] && [ -d $HOME/gcc-32/arm-eabi ]; then
COMMAND+=" CROSS_COMPILE=$HOME/gcc-64/aarch64-elf/bin/aarch64-elf- CROSS_COMPILE_ARM32=$HOME/gcc-32/arm-eabi/bin/arm-eabi- CLANG_TRIPLE=aarch64-linux-gnu-"
elif [ -d $HOME/gcc-64 ] && [ -d $HOME/gcc-32 ]; then
COMMAND+=" CROSS_COMPILE=$HOME/gcc-64/bin/aarch64-linux-android- CROSS_COMPILE_ARM32=$HOME/gcc-32/bin/arm-linux-androideabi- CLANG_TRIPLE=aarch64-linux-gnu-"
fi
elif [ ${{ inputs.android-ndk }} = true ]; then
COMMAND+=" CROSS_COMPILE=$CLANG_PATH/bin/llvm- CROSS_COMPILE_ARM32=$CLANG_PATH/bin/llvm-"
fi
if [ -d $HOME/clang ]; then
if [ ${{ inputs.ccache }} = true ]; then
COMMAND+=" CC='ccache clang'"
else
COMMAND+=" CC=clang"
fi
else
if [ ${{ inputs.ccache }} = true ]; then
if [ -d $HOME/gcc-64/aarch64-elf ]; then
COMMAND+=" CC='ccache $HOME/gcc-64/aarch64-elf/bin/aarch64-elf-gcc'"
elif [ -d $HOME/gcc-64 ]; then
COMMAND+=" CC='ccache $HOME/gcc-64/bin/aarch64-linux-android-gcc'"
fi
else
if [ -d $HOME/gcc-32/arm-eabi ]; then
COMMAND+=" CC='ccache $HOME/gcc-32/arm-eabi/bin/arm-eabi-gcc'"
elif [ -d $HOME/gcc-32 ]; then
COMMAND+=" CC='ccache $HOME/gcc-32/bin/arm-linux-androidabeihf-gcc'"
fi
fi
fi
echo "using command: ${COMMAND}"
eval ${COMMAND}
echo "::endgroup::"
unset USE_CCACHE CLANG_TRIPLE CROSS_COMPILE_ARM32 CROSS_COMPILE CLANG_PATH HOMES KVER COMMAND SWAP_FILE SUBLEVEL PATCHLEVEL VERSION
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/
rm -rf -v AnyKernel3/.git* AnyKernel3/README.md
if [ ${{ inputs.release }} = false ]; then
cp AnyKernel3 ../../build -r -v
else
zip Anykernel3-flasher.zip AnyKernel3/*
mv Anykernel3-flasher.zip ../../build -v
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 }}