Skip to content

Commit 8d9bcd4

Browse files
authored
Create custom.yml
1 parent 3d43507 commit 8d9bcd4

File tree

1 file changed

+165
-0
lines changed

1 file changed

+165
-0
lines changed

.github/workflows/custom.yml

Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
name: Build kernel with optional SUSFS and KernelSU
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
kernel_repo_url:
7+
description: 'Kernel git repository URL'
8+
required: true
9+
default: 'https://github.com/LineageOS/android_kernel_oneplus_sm8150'
10+
kernel_branch:
11+
description: 'Kernel branch'
12+
required: true
13+
default: 'lineage-22.1'
14+
defconfig_file:
15+
description: 'Kernel defconfig filename'
16+
required: true
17+
default: 'lineage_sm8150_defconfig'
18+
use_kernelsu:
19+
description: 'Use KernelSU (true) or KernelSU-Next (false)'
20+
required: true
21+
default: 'true'
22+
enable_susfs:
23+
description: 'Enable SUSFS patches'
24+
required: true
25+
default: 'false'
26+
release_name:
27+
description: 'Final release ZIP base name'
28+
required: true
29+
default: 'OP7_custom_kernel'
30+
31+
jobs:
32+
build:
33+
runs-on: ubuntu-latest
34+
env:
35+
CCACHE_HARDLINK: true
36+
CCACHE_NOHASHDIR: true
37+
CCACHE_MAXSIZE: 3G
38+
CCACHE_COMPILERCHECK: '%compiler% -dumpmachine; %compiler% -dumpversion'
39+
PATH: /usr/lib/llvm-18/bin:${{ env.PATH }}
40+
41+
steps:
42+
- name: Checkout repository
43+
uses: actions/checkout@v4
44+
with:
45+
fetch-depth: 0
46+
47+
- name: Prepare workspace and clone kernel
48+
run: |
49+
set -euo pipefail
50+
rm -rf kernel builds || true
51+
mkdir -p builds
52+
git clone --depth=1 --branch ${{ github.event.inputs.kernel_branch }} ${{ github.event.inputs.kernel_repo_url }} kernel
53+
cd kernel
54+
git submodule update --init --recursive
55+
56+
- name: Setup dependencies
57+
run: |
58+
sudo apt-get update -y
59+
sudo apt-get install -y clang-18 llvm-18 lld-18 \
60+
gcc-aarch64-linux-gnu gcc-arm-linux-gnueabi \
61+
binutils make python3 libssl-dev bc bison flex unzip \
62+
ca-certificates xz-utils mkbootimg cpio device-tree-compiler git git-lfs zip
63+
64+
- name: Prepare KernelSU
65+
if: ${{ github.event.inputs.use_kernelsu == 'true' }}
66+
working-directory: kernel
67+
run: |
68+
curl -LSs "https://raw.githubusercontent.com/tiann/KernelSU/main/kernel/setup.sh" | bash -s stable
69+
70+
- name: Prepare KernelSU-Next
71+
if: ${{ github.event.inputs.use_kernelsu == 'false' }}
72+
working-directory: kernel
73+
run: |
74+
curl -LSs "https://raw.githubusercontent.com/KernelSU-Next/KernelSU-Next/next/kernel/setup.sh" | bash -
75+
76+
- name: Apply SUSFS patches
77+
if: ${{ github.event.inputs.enable_susfs == 'true' }}
78+
working-directory: kernel
79+
run: |
80+
git clone https://gitlab.com/simonpunk/susfs4ksu.git -b kernel-4.14 susfs_patches
81+
cp susfs_patches/kernel_patches/KernelSU/10_enable_susfs_for_ksu.patch KernelSU/
82+
cp susfs_patches/kernel_patches/50_add_susfs_in_kernel-4.14.patch .
83+
cp susfs_patches/kernel_patches/fs/* fs/
84+
cp susfs_patches/kernel_patches/include/linux/* include/linux/
85+
cd KernelSU
86+
patch -p1 -F 3 < 10_enable_susfs_for_ksu.patch
87+
cd ..
88+
patch -p1 -F 3 < 50_add_susfs_in_kernel-4.14.patch
89+
90+
- name: Add SUSFS configs if enabled
91+
if: ${{ github.event.inputs.enable_susfs == 'true' }}
92+
working-directory: kernel
93+
run: |
94+
echo "CONFIG_KSU=y" >> arch/arm64/configs/${{ github.event.inputs.defconfig_file }}
95+
echo "CONFIG_KSU_SUSFS=y" >> arch/arm64/configs/${{ github.event.inputs.defconfig_file }}
96+
echo "CONFIG_KSU_SUSFS_SUS_PATH=y" >> arch/arm64/configs/${{ github.event.inputs.defconfig_file }}
97+
echo "CONFIG_KSU_SUSFS_SUS_MOUNT=y" >> arch/arm64/configs/${{ github.event.inputs.defconfig_file }}
98+
echo "CONFIG_KSU_SUSFS_SUS_KSTAT=y" >> arch/arm64/configs/${{ github.event.inputs.defconfig_file }}
99+
echo "CONFIG_KSU_SUSFS_SUS_OVERLAYFS=y" >> arch/arm64/configs/${{ github.event.inputs.defconfig_file }}
100+
echo "CONFIG_KSU_SUSFS_TRY_UMOUNT=y" >> arch/arm64/configs/${{ github.event.inputs.defconfig_file }}
101+
echo "CONFIG_KSU_SUSFS_SPOOF_UNAME=y" >> arch/arm64/configs/${{ github.event.inputs.defconfig_file }}
102+
echo "CONFIG_KSU_SUSFS_ENABLE_LOG=y" >> arch/arm64/configs/${{ github.event.inputs.defconfig_file }}
103+
echo "CONFIG_KSU_SUSFS_OPEN_REDIRECT=y" >> arch/arm64/configs/${{ github.event.inputs.defconfig_file }}
104+
echo "CONFIG_KSU_SUSFS_SUS_SU=y" >> arch/arm64/configs/${{ github.event.inputs.defconfig_file }}
105+
106+
- name: Build Kernel
107+
working-directory: kernel
108+
env:
109+
CROSS_COMPILE: aarch64-none-linux-gnu-
110+
ARCH: arm64
111+
LTO: thin
112+
run: |
113+
make ${{ github.event.inputs.defconfig_file }}
114+
# Use the build/build.sh from repo if present, fallback to make
115+
if [ -f build/build.sh ]; then
116+
LTO=thin ARCH=arm64 CROSS_COMPILE=aarch64-none-linux-gnu- BUILD_CONFIG=common/build.config.aarch64 build/build.sh
117+
else
118+
make -j$(nproc)
119+
fi
120+
121+
- name: Copy kernel Image.lz4
122+
if: exists('kernel/out/android12-5.10/dist/Image.lz4')
123+
run: |
124+
cp kernel/out/android12-5.10/dist/Image.lz4 kernel/AnyKernel3/Image.lz4
125+
126+
- name: Package Kernel
127+
working-directory: kernel/AnyKernel3
128+
run: |
129+
zip -r ../${{ github.event.inputs.release_name }}.zip *
130+
131+
- name: Build Wi-Fi module (qca_cld3)
132+
working-directory: kernel
133+
env:
134+
CROSS_COMPILE: aarch64-none-linux-gnu-
135+
ARCH: arm64
136+
run: |
137+
make modules_prepare
138+
make -C drivers/staging/qcacld-3.0 M=$(pwd)/drivers/staging/qcacld-3.0 modules
139+
mkdir -p ../modules/vendor/lib/modules
140+
find out/drivers/staging/qcacld-3.0 -name "*.ko" -exec cp -v {} ../modules/vendor/lib/modules/ \;
141+
sudo chown -R $(id -u):$(id -g) ../modules
142+
143+
- name: Package Wi-Fi modules
144+
run: |
145+
if [ ! -d "modules/vendor/lib/modules" ] || ! ls modules/vendor/lib/modules/*.ko >/dev/null 2>&1; then
146+
echo "No Wi-Fi modules found."
147+
exit 1
148+
fi
149+
cd modules
150+
zip -r ../${{ github.event.inputs.release_name }}-modules.zip *
151+
cd ..
152+
153+
- name: Upload kernel artifacts
154+
uses: actions/upload-artifact@v4
155+
with:
156+
name: kernel-output
157+
path: kernel/out
158+
159+
- name: Upload zips
160+
uses: actions/upload-artifact@v4
161+
with:
162+
name: build-zips
163+
path: |
164+
kernel/${{ github.event.inputs.release_name }}.zip
165+
${{ github.event.inputs.release_name }}-modules.zip

0 commit comments

Comments
 (0)