Skip to content

Commit 39a886d

Browse files
committed
build: abstract build types/ksu variants
Signed-off-by: TheSillyOk <priv.ld@proton.me>
1 parent 0025940 commit 39a886d

1 file changed

Lines changed: 67 additions & 46 deletions

File tree

.github/workflows/build_kernels.yml

Lines changed: 67 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ jobs:
2727
config: "vendor/xiaomi-trinket.config vendor/laurel_sprout.config"
2828
patches_folder: "sm6125"
2929
IN_DTBO: "out/arch/arm64/boot/dts/xiaomi/laurel_sprout-trinket-overlay.dtbo"
30+
3031
- kernel_name: "SM6125 - Ginkgo"
3132
device: Ginkgo
3233
kernel_url: "https://github.com/LineageOS/android_kernel_xiaomi_sm6125"
@@ -36,20 +37,47 @@ jobs:
3637
config: "vendor/xiaomi-trinket.config vendor/ginkgo.config"
3738
patches_folder: "sm6125"
3839
IN_DTBO: "out/arch/arm64/boot/dts/xiaomi/ginkgo-trinket-overlay.dtbo"
40+
3941
- kernel_name: "N18.1"
4042
kernel_url: "https://github.com/TheSillyOk/kernel_laurel_sprout"
4143
kernel_branch: "lineage-18.1"
4244
tag: "NoName-18.1"
4345
python3_patch: true
46+
4447
- kernel_name: "N-VIC"
4548
kernel_url: "https://github.com/TheSillyOk/kernel_laurel_sprout"
4649
kernel_branch: "vic"
4750
tag: "NoName-VIC"
4851
python3_patch: true
49-
build_type: ["Normal", "RKSU", "KSUN"]
52+
53+
build:
54+
- type: Normal
55+
ksu: false
56+
ak3_suffix: ""
57+
58+
- type: KSUN
59+
ksu: true
60+
repo: "KernelSU-Next/KernelSU-Next"
61+
branch: "next"
62+
ksu_patches: "KSUN/WildJames-Manager.patch"
63+
kernel_patches: "KSUN/syscall_hooks.patch seccomp.patch"
64+
manual_hook_config: "KSU_KPROBES_HOOK=n"
65+
susfs_patch: "KSUN/KSUN-SUSFS-1.5.9.patch"
66+
ak3_suffix: "-KSUNext"
67+
68+
- type: RKSU
69+
ksu: true
70+
repo: "rsuntk/KernelSU"
71+
branch: "main"
72+
kernel_patches: "path_unmount.patch get_cred_rcu.patch strncpy_from_user_nofault.patch KSUN/syscall_hooks.patch"
73+
manual_hook_config: "KSU_MANUAL_HOOK=y"
74+
susfs_patch: "RKSU/RKSU-SUSFS-1.5.9.patch"
75+
ak3_suffix: "-RKSU"
76+
5077
susfs: [false, true]
5178
exclude:
52-
- build_type: "Normal"
79+
- build:
80+
type: "Normal"
5381
susfs: true
5482

5583
permissions:
@@ -104,10 +132,10 @@ jobs:
104132
uses: actions/cache@v4
105133
with:
106134
path: ~/.ccache
107-
key: ${{ env.device }}-${{ matrix.build_type }}-${{ matrix.kernel_config.tag }}-SUSFS_${{ matrix.susfs }}-ccache-${{ github.sha }}-${{ github.run_number }}
135+
key: ${{ env.device }}-${{ matrix.build.type }}-${{ matrix.kernel_config.tag }}-SUSFS_${{ matrix.susfs }}-ccache-${{ github.sha }}-${{ github.run_number }}
108136
restore-keys: |
109-
${{ env.device }}-${{ matrix.build_type }}-${{ matrix.kernel_config.tag }}-SUSFS_${{ matrix.susfs }}-ccache-${{ github.sha }}
110-
${{ env.device }}-${{ matrix.build_type }}-${{ matrix.kernel_config.tag }}-SUSFS_${{ matrix.susfs }}-ccache-
137+
${{ env.device }}-${{ matrix.build.type }}-${{ matrix.kernel_config.tag }}-SUSFS_${{ matrix.susfs }}-ccache-${{ github.sha }}
138+
${{ env.device }}-${{ matrix.build.type }}-${{ matrix.kernel_config.tag }}-SUSFS_${{ matrix.susfs }}-ccache-
111139
112140
- name: Prepare Kernel Source
113141
run: |
@@ -119,11 +147,13 @@ jobs:
119147
git clone --depth=1 "${{ env.patches_url }}" ${{ env.patches_branch_arg }} "${{ env.workspace_folder }}/kernel_patches"
120148
121149
cd "${{ env.workspace_folder }}/kernel_tree"
150+
122151
if ${{ env.python3 }}; then
123-
patch -p1 -F 3 -N < "${{ env.workspace_folder }}/kernel_patches/python3.patch" || true
152+
patch -p1 < "${{ env.workspace_folder }}/kernel_patches/python3.patch" || true
124153
fi
125154
126-
for patch_name in fix_lto ptrace_fix; do
155+
for patch_name in fix_lto ptrace_fix;
156+
do
127157
patch -p1 < "${{ env.workspace_folder }}/kernel_patches/${patch_name}.patch" || true
128158
done
129159
@@ -133,35 +163,29 @@ jobs:
133163
echo -e "\n\n# Workflow added configs #\nCONFIG_LTO_CLANG=y\nCONFIG_LTO_CLANG_THIN=y\nCONFIG_HAVE_LTO_CLANG=y\nCONFIG_CC_OPTIMIZE_FOR_PERFORMANCE=y\nCONFIG_MODVERSIONS=n" >> "arch/arm64/configs/${{ env.defconfig }}"
134164
135165
- name: Apply KernelSU / Forks
136-
if: matrix.build_type != 'Normal'
166+
if: matrix.build.ksu
137167
working-directory: ${{ env.kernel_folder }}
138168
run: |
139169
set -e
140-
case "${{ matrix.build_type }}" in
141-
KSU)
142-
curl -LSs "https://raw.githubusercontent.com/tiann/KernelSU/main/kernel/setup.sh" | bash -s v0.9.5
143-
for patch_name in path_unmount get_cred_rcu strncpy_from_user_nofault ${{ env.patches_folder }}/manual_hooks; do
144-
patch -p1 -F 3 -N < "${{ env.patches_dir }}/${patch_name}.patch"
145-
done
146-
;;
147-
KSUN)
148-
curl -LSs "https://raw.githubusercontent.com/rifsxd/KernelSU-Next/next/kernel/setup.sh" | bash -s next
149-
patch -p1 -F 3 -N < "${{ env.patches_dir }}/KSUN/syscall_hooks.patch"
150-
patch -p1 < "${{ env.patches_dir }}/seccomp.patch"
151-
cd KernelSU-Next
152-
patch -p1 -F 3 -N < "${{ env.patches_dir }}/KSUN/WildJames-Manager.patch"
153-
;;
154-
RKSU)
155-
curl -LSs "https://raw.githubusercontent.com/rsuntk/KernelSU/main/kernel/setup.sh" | bash -s main
156-
for patch_name in path_unmount get_cred_rcu strncpy_from_user_nofault KSUN/syscall_hooks; do
157-
patch -p1 -F 3 -N < "${{ env.patches_dir }}/${patch_name}.patch"
158-
done
159-
;;
160-
esac
170+
curl -LSs "https://raw.githubusercontent.com/${{ matrix.build.repo }}/${{ matrix.build.branch }}/kernel/setup.sh" | bash -s ${{ matrix.build.branch }}
171+
172+
if [[ -n "${{ matrix.build.kernel_patches }}" ]]; then
173+
for patch in ${{ matrix.build.kernel_patches }}; do
174+
patch -p1 -N < "${{ env.patches_dir }}/${patch}"
175+
done
176+
fi
177+
178+
if [[ -n "${{ matrix.build.ksu_patches }}" ]]; then
179+
cd KernelSU*
180+
for patch in ${{ matrix.build.ksu_patches }}; do
181+
patch -p1 -N < "${{ env.patches_dir }}/${patch}"
182+
done
183+
fi
161184
162185
cd ${{ env.kernel_folder }}
163186
sed -i -E 's/^CONFIG_(KPROBES|TMPFS_XATTR|KSU[^=]*)=(y|n)/# CONFIG_\1=\2/g' "arch/arm64/configs/${{ env.defconfig }}"
164-
echo -e "\nCONFIG_KPROBES=n\nCONFIG_KSU=y\nCONFIG_TMPFS_XATTR=y\n" >> "arch/arm64/configs/${{ env.defconfig }}"
187+
echo -e "\nCONFIG_KPROBES=n\nCONFIG_KSU=y\nCONFIG_TMPFS_XATTR=y" >> "arch/arm64/configs/${{ env.defconfig }}"
188+
echo "${{ matrix.build.manual_hook_config }}" >> "arch/arm64/configs/${{ env.defconfig }}"
165189
166190
- name: Apply SUSFS
167191
if: matrix.susfs
@@ -171,19 +195,19 @@ jobs:
171195
SUSFS_FOLDER="${{ env.workspace_folder }}/susfs4ksu"
172196
git clone --depth=1 https://gitlab.com/simonpunk/susfs4ksu.git -b "${{ env.susfs_branch }}" "$SUSFS_FOLDER"
173197
174-
case "${{ matrix.build_type }}" in
198+
case "${{ matrix.build.type }}" in
175199
KSU)
176-
patch -p1 -F 3 -N < "$SUSFS_FOLDER/kernel_patches/50_add_susfs_in_${{ env.susfs_branch }}.patch" || true
177-
patch -p1 -F 3 -N < "${{ env.patches_dir }}/${{ env.patches_folder }}/fix_susfs_rejects.patch" || true
200+
patch -p1 -N < "$SUSFS_FOLDER/kernel_patches/50_add_susfs_in_${{ env.susfs_branch }}.patch" || true
201+
patch -p1 -N < "${{ env.patches_dir }}/${{ env.patches_folder }}/fix_susfs_rejects.patch" || true
178202
cp -r $SUSFS_FOLDER/kernel_patches/fs/* fs/
179203
cp -r $SUSFS_FOLDER/kernel_patches/include/linux/* include/linux
180204
cd KernelSU
181-
patch -p1 -F 3 -N < "$SUSFS_FOLDER/kernel_patches/KernelSU/10_enable_susfs_for_ksu.patch"
205+
patch -p1 -N < "$SUSFS_FOLDER/kernel_patches/KernelSU/10_enable_susfs_for_ksu.patch"
182206
;;
183207
RKSU|KSUN)
184-
patch -p1 -F 3 -N < "${{ env.patches_dir }}/susfs-1.5.9.patch" || true
208+
patch -p1 -N < "${{ env.patches_dir }}/susfs-1.5.9.patch" || true
185209
cd KernelSU*
186-
patch -p1 -F 3 -N < "${{ env.patches_dir }}/${{ matrix.build_type }}/${{ matrix.build_type }}-SUSFS-1.5.9.patch"
210+
patch -p1 -N < "${{ env.patches_dir }}/${{ matrix.build.susfs_patch }}"
187211
;;
188212
esac
189213
@@ -218,20 +242,17 @@ jobs:
218242
219243
cp -f "$BOOT_FOLDER/Image.gz-dtb" "$AK3_FOLDER" 2>/dev/null || cp -f "$BOOT_FOLDER/Image.gz" "$AK3_FOLDER"
220244
221-
if [ -e "$BOOT_FOLDER/dtbo.img" ]; then
245+
if [ -e "$BOOT_FOLDER/dtbo.img" ];
246+
then
222247
cp -f "$BOOT_FOLDER/dtbo.img" "$AK3_FOLDER"
223-
elif [ "${{ env.in_dtbo }}" != "none" ]; then
248+
elif [ "${{ env.in_dtbo }}" != "none" ];
249+
then
224250
python3 "${{ env.kernel_folder }}/extra/mkdtboimg.py" create "$AK3_FOLDER/dtbo.img" --custom0=0x00000000 --custom1=0x00000000 --page_size=4096 "${{ env.kernel_folder }}/${{ env.in_dtbo }}"
225251
fi
226252
227-
BUILD_SUFFIX=""
228-
case "${{ matrix.build_type }}" in
229-
KSUN) BUILD_SUFFIX="-KSUNext" ;;
230-
KSU) BUILD_SUFFIX="-KSU" ;;
231-
RKSU) BUILD_SUFFIX="-RKSU" ;;
232-
esac
233-
234-
if [ "${{ matrix.susfs }}" == "true" ]; then
253+
BUILD_SUFFIX="${{ matrix.build.ak3_suffix }}"
254+
if [ "${{ matrix.susfs }}" == "true" ];
255+
then
235256
BUILD_SUFFIX="$BUILD_SUFFIX.SUSFS"
236257
fi
237258

0 commit comments

Comments
 (0)