Skip to content

Commit 2ad4eb4

Browse files
authored
Update custom.yml
1 parent 21f7c68 commit 2ad4eb4

File tree

1 file changed

+30
-180
lines changed

1 file changed

+30
-180
lines changed

.github/workflows/custom.yml

Lines changed: 30 additions & 180 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
name: Custom Build kernel and Wi-Fi module
2-
32
on:
43
workflow_dispatch:
54
inputs:
@@ -14,11 +13,11 @@ on:
1413
defconfig_file:
1514
description: 'Kernel defconfig filename'
1615
required: true
17-
default: 'defconfig'
16+
default: 'lineage_sm8150_defconfig'
1817
use_kernelsu_next:
19-
description: 'Use KernelSU-Next instead of KernelSU'
18+
description: 'Use KernelSU-Next'
2019
required: true
21-
default: false
20+
default: true
2221
type: boolean
2322
enable_susfs:
2423
description: 'Enable SUSFS patches'
@@ -29,203 +28,54 @@ on:
2928
description: 'Release name for ZIPs'
3029
required: true
3130
default: 'OP7_KSN_wifi'
32-
3331
jobs:
3432
build:
3533
runs-on: ubuntu-latest
3634
steps:
37-
- name: Checkout repository fresh
35+
- name: Checkout repository
3836
uses: actions/checkout@v4
39-
with:
40-
fetch-depth: 0
41-
42-
- name: Install full build dependencies
43-
run: |
44-
sudo apt-get update -y
45-
sudo apt-get install -y --fix-missing \
46-
git device-tree-compiler lz4 xz-utils zlib1g-dev openjdk-17-jdk \
47-
gcc g++ python3 python-is-python3 p7zip-full android-sdk-libsparse-utils \
48-
erofs-utils default-jdk gnupg flex bison gperf build-essential zip curl \
49-
libc6-dev libncurses-dev libx11-dev libreadline-dev libgl1 libgl1-mesa-dev \
50-
make sudo bc grep tofrodos python3-markdown libxml2-utils xsltproc libtinfo6 \
51-
repo cpio kmod openssl libelf-dev pahole libssl-dev libarchive-tools zstd rsync \
52-
gcc-aarch64-linux-gnu binutils-aarch64-linux-gnu
53-
54-
- name: Verify cross-compiler binaries
55-
run: |
56-
aarch64-linux-gnu-gcc --version
57-
which aarch64-linux-gnu-ld
58-
aarch64-linux-gnu-ld --version
59-
60-
- name: Clean workspace & clone kernel
61-
run: |
62-
rm -rf kernel modules || true
63-
git clone --depth=1 --branch "${{ github.event.inputs.kernel_branch }}" "${{ github.event.inputs.kernel_repo_url }}" kernel
64-
cd kernel
65-
git submodule update --init --recursive
66-
chmod +755 -R .
67-
68-
- name: Setup KernelSU or KernelSU-Next
37+
- name: Install dependencies
38+
run: sudo apt-get update -y && sudo apt-get install -y --fix-missing git device-tree-compiler lz4 xz-utils zlib1g-dev openjdk-17-jdk gcc g++ python3 python-is-python3 p7zip-full android-sdk-libsparse-utils erofs-utils default-jdk gnupg flex bison gperf build-essential zip curl libc6-dev libncurses-dev libx11-dev libreadline-dev libgl1-mesa-dev make sudo bc grep tofrodos python3-markdown libxml2-utils xsltproc libtinfo6 repo cpio kmod openssl libelf-dev pahole libssl-dev libarchive-tools zstd rsync gcc-aarch64-linux-gnu binutils-aarch64-linux-gnu
39+
- name: Clone kernel
40+
run: git clone --depth=1 --branch "${{ github.event.inputs.kernel_branch }}" "${{ github.event.inputs.kernel_repo_url }}" kernel
41+
- name: Setup KernelSU
42+
if: ${{ !github.event.inputs.use_kernelsu_next }}
6943
working-directory: ./kernel
70-
run: |
71-
export PATH=/usr/lib/llvm-18/bin:$PATH
72-
if [ "${{ github.event.inputs.use_kernelsu_next }}" = "true" ]; then
73-
curl -LSs "https://raw.githubusercontent.com/KernelSU-Next/KernelSU-Next/next/kernel/setup.sh" | bash -
74-
else
75-
curl -LSs "https://raw.githubusercontent.com/tiann/KernelSU/main/kernel/setup.sh" | bash -s stable
76-
fi
77-
78-
- name: Apply SUSFS patches if enabled
79-
if: github.event.inputs.enable_susfs == true
44+
run: curl -LSs "https://raw.githubusercontent.com/tiann/KernelSU/main/kernel/setup.sh" | bash -s stable
45+
- name: Setup KernelSU-Next
46+
if: ${{ github.event.inputs.use_kernelsu_next }}
8047
working-directory: ./kernel
81-
run: |
82-
git clone https://gitlab.com/simonpunk/susfs4ksu.git -b kernel-4.14 susfs_patches
83-
cp susfs_patches/kernel_patches/KernelSU/10_enable_susfs_for_ksu.patch KernelSU/ || true
84-
cp susfs_patches/kernel_patches/50_add_susfs_in_kernel-4.14.patch . || true
85-
cp -r susfs_patches/kernel_patches/fs/* ./fs/ || true
86-
cp -r susfs_patches/kernel_patches/include/linux/* ./include/linux/ || true
87-
if [ -f KernelSU/10_enable_susfs_for_ksu.patch ]; then
88-
(cd KernelSU && patch -N -p1 < 10_enable_susfs_for_ksu.patch)
89-
fi
90-
if [ -f 50_add_susfs_in_kernel-4.14.patch ]; then
91-
patch -N -p1 < 50_add_susfs_in_kernel-4.14.patch
92-
fi
93-
if find . -name "*.rej" | grep -q .; then
94-
echo "SUSFS patch rejects found:"
95-
find . -name "*.rej" -print -exec sed -n '1,20p' {} \;
96-
exit 1
97-
fi
98-
99-
- name: Patch btrfs struct timespec64
100-
working-directory: ./kernel
101-
run: |
102-
patchfile="btrfs_timespec64.patch"
103-
cat > $patchfile <<'EOF'
104-
--- a/fs/btrfs/inode.c
105-
+++ b/fs/btrfs/inode.c
106-
@@ -6627,7 +6627,7 @@
107-
- struct timespec now = current_time(&parent_inode->vfs_inode);
108-
+ struct timespec64 now = current_time(&parent_inode->vfs_inode);
109-
EOF
110-
if grep -qF "struct timespec now = current_time(&parent_inode->vfs_inode);" fs/btrfs/inode.c; then
111-
patch -p1 < $patchfile
112-
else
113-
echo "Patch for btrfs timespec64 already applied or no match found."
114-
fi
115-
116-
- name: Patch try_to_unmap argument pattern
48+
run: curl -LSs "https://raw.githubusercontent.com/KernelSU-Next/KernelSU-Next/next/kernel/setup.sh" | bash -
49+
- name: Apply Patches
11750
working-directory: ./kernel
11851
run: |
11952
sed -i 's|try_to_unmap(page, ttu_flags);|try_to_unmap(page, ttu_flags, NULL);|g' mm/huge_memory.c
120-
echo "Applied try_to_unmap patch."
121-
122-
- name: Patch hugetlbpage ptep allocation
123-
working-directory: ./kernel
124-
run: |
125-
file=arch/arm64/mm/hugetlbpage.c
126-
if [ ! -f "$file" ]; then
127-
echo "File not found: $file, skipping patch."
128-
exit 0
129-
fi
130-
ln=$(awk '/huge_pte_alloc/{f=1} f && /{/{print NR; exit}' $file)
131-
if [ -n "$ln" ]; then
132-
if ! sed -n "$((ln+1)),$((ln+15))p" $file | grep -q "pte_t \*ptep"; then
133-
sed -i "$((ln+1)) i\ pte_t *ptep = NULL;" $file
134-
echo "Inserted 'pte_t *ptep = NULL;' after line $ln"
135-
fi
136-
sed -i 's/ptep = huge_pmd_share(mm, vma, addr, pud);/if (!ptep) ptep = huge_pmd_share(mm, vma, addr, pud);/' $file
137-
else
138-
echo "huge_pte_alloc function not found, skipping ptep patch"
139-
fi
140-
141-
- name: Remove mm->nr_ptes usage
142-
working-directory: ./kernel
143-
run: |
14453
sed -i 's/\(.*mm->nr_ptes.*\)/\/\* REMOVED_for_ARM64 \1 \*\//' mm/khugepaged.c
145-
echo "Commented out mm->nr_ptes usage."
146-
147-
- name: Add SUSFS configs if enabled
148-
if: github.event.inputs.enable_susfs == true
149-
working-directory: ./kernel
150-
run: |
151-
conf="arch/arm64/configs/${{ github.event.inputs.defconfig_file }}"
152-
{
153-
echo "CONFIG_KSU=y"
154-
echo "CONFIG_KSU_SUSFS=y"
155-
} >> "$conf"
156-
157-
- name: Disable problematic configs
158-
working-directory: ./kernel
159-
run: |
160-
conf="arch/arm64/configs/${{ github.event.inputs.defconfig_file }}"
161-
for opt in CONFIG_TASKSTATS CONFIG_TASK_DELAY_ACCT CONFIG_TASK_XACCT CONFIG_TASK_IO_ACCOUNTING; do
162-
sed -i "/^$opt[= ]/d" "$conf" || true
163-
echo "${opt}=n" >> "$conf"
164-
done
165-
166-
- name: Ensure NR_CPUS config
167-
working-directory: ./kernel
168-
run: |
169-
conf="arch/arm64/configs/${{ github.event.inputs.defconfig_file }}"
170-
grep -q '^CONFIG_NR_CPUS=' "$conf" || echo 'CONFIG_NR_CPUS=8' >> "$conf"
171-
54+
if grep -qF "struct timespec now = current_time(&parent_inode->vfs_inode);" fs/btrfs/inode.c; then patch -p1 -i <(echo "--- a/fs/btrfs/inode.c\n+++ b/fs/btrfs/inode.c\n@@ -6627,7 +6627,7 @@\n- struct timespec now = current_time(&parent_inode->vfs_inode);\n+ struct timespec64 now = current_time(&parent_inode->vfs_inode);"); fi
17255
- name: Prepare kernel config
17356
working-directory: ./kernel
17457
run: |
175-
export PATH=/usr/lib/llvm-18/bin:$PATH
176-
make mrproper
177-
make O=out ARCH=arm64 LTO=thin CROSS_COMPILE=aarch64-linux-gnu- ${{ github.event.inputs.defconfig_file }}
178-
make O=out ARCH=arm64 LTO=thin CROSS_COMPILE=aarch64-linux-gnu- olddefconfig
179-
58+
conf="arch/arm64/configs/${{ github.event.inputs.defconfig_file }}"
59+
echo "CONFIG_NR_CPUS=8" >> "$conf"
60+
for opt in CONFIG_TASKSTATS CONFIG_TASK_DELAY_ACCT CONFIG_TASK_XACCT CONFIG_TASK_IO_ACCOUNTING; do echo "${opt}=n" >> "$conf"; done
61+
make mrproper && make O=out ARCH=arm64 LTO=thin CROSS_COMPILE=aarch64-linux-gnu- ${{ github.event.inputs.defconfig_file }} && make O=out ARCH=arm64 LTO=thin CROSS_COMPILE=aarch64-linux-gnu- olddefconfig
18062
- name: Build kernel
18163
working-directory: ./kernel
182-
run: |
183-
export PATH=/usr/lib/llvm-18/bin:$PATH
184-
make O=out ARCH=arm64 LTO=thin CROSS_COMPILE=aarch64-linux-gnu- -j$(nproc)
185-
186-
- name: Copy kernel Image if it exists
187-
if: always()
188-
run: |
189-
if [ -f kernel/out/arch/arm64/boot/Image.lz4 ]; then
190-
mkdir -p kernel/AnyKernel3
191-
cp kernel/out/arch/arm64/boot/Image.lz4 kernel/AnyKernel3/Image.lz4
192-
elif [ -f kernel/out/arch/arm64/boot/Image ]; then
193-
mkdir -p kernel/AnyKernel3
194-
cp kernel/out/arch/arm64/boot/Image kernel/AnyKernel3/Image
195-
else
196-
echo "Kernel Image not found in standard output locations."
197-
fi
198-
64+
run: make O=out ARCH=arm64 LTO=thin CROSS_COMPILE=aarch64-linux-gnu- -j$(nproc)
19965
- name: Package Kernel ZIP
20066
run: |
201-
if [ -d "kernel/AnyKernel3" ] && [ -n "$(ls -A kernel/AnyKernel3)" ]; then
202-
cd kernel/AnyKernel3
203-
zip -r ../../${{ github.event.inputs.release_name }}.zip ./*
204-
cd ../../
205-
else
206-
echo "AnyKernel3 directory is empty or missing, skipping kernel zip."
67+
if [ -f kernel/out/arch/arm64/boot/Image.lz4 ]; then
68+
mkdir -p AnyKernel3 && cp kernel/out/arch/arm64/boot/Image.lz4 AnyKernel3/Image.lz4
69+
(cd AnyKernel3 && zip -r ../${{ github.event.inputs.release_name }}.zip ./*)
20770
fi
208-
209-
- name: Build Wi-Fi Module (qca_cld3)
210-
working-directory: ./kernel
211-
run: |
212-
export PATH=/usr/lib/llvm-18/bin:$PATH
213-
make O=out ARCH=arm64 LTO=thin CROSS_COMPILE=aarch64-linux-gnu- modules_prepare
214-
make O=out ARCH=arm64 LTO=thin CROSS_COMPILE=aarch64-linux-gnu- -j$(nproc) M=$(pwd)/drivers/staging/qcacld-3.0 modules
215-
mkdir -p ../modules/vendor/lib/modules
216-
find out -name "wlan.ko" -exec cp -v {} ../modules/vendor/lib/modules/ \;
217-
sudo chown -R $(id -u):$(id -g) ../modules
218-
219-
- name: Package Wi-Fi Module ZIP
71+
- name: Build and Package Wi-Fi Module
22072
run: |
221-
if [ ! -d "modules/vendor/lib/modules" ] || ! ls modules/vendor/lib/modules/*.ko >/dev/null 2>&1; then
222-
echo "No Wi-Fi modules found to package."
223-
else
224-
cd modules
225-
zip -r ../${{ github.event.inputs.release_name }}-modules.zip ./*
226-
cd ..
73+
(cd kernel && make O=out ARCH=arm64 LTO=thin CROSS_COMPILE=aarch64-linux-gnu- modules_prepare && make O=out ARCH=arm64 LTO=thin CROSS_COMPILE=aarch64-linux-gnu- -j$(nproc) M=$(pwd)/drivers/staging/qcacld-3.0 modules)
74+
mkdir -p modules/vendor/lib/modules
75+
find kernel/out -name "wlan.ko" -exec cp -v {} modules/vendor/lib/modules/ \;
76+
if [ -n "$(ls -A modules/vendor/lib/modules)" ]; then
77+
(cd modules && zip -r ../${{ github.event.inputs.release_name }}-modules.zip ./*)
22778
fi
228-
22979
- name: Upload zips
23080
uses: actions/upload-artifact@v4
23181
with:

0 commit comments

Comments
 (0)