Skip to content

Custom Build kernel and Wi-Fi module #3

Custom Build kernel and Wi-Fi module

Custom Build kernel and Wi-Fi module #3

Workflow file for this run

name: Custom Build kernel and Wi-Fi Module
on:
workflow_dispatch:
inputs:
kernel_repo_url:
description: 'Kernel repository URL'
required: true
default: 'https://github.com/LineageOS/android_kernel_oneplus_sm8150'
kernel_branch:
description: 'Kernel branch'
required: true
default: 'lineage-22.1'
defconfig_file:
description: 'Kernel defconfig filename'
required: true
default: 'lineage_sm8150_defconfig'
use_kernelsu_next:
description: 'Use KernelSU-Next instead of KernelSU'
required: true
default: 'false'
enable_susfs:
description: 'Enable SUSFS patches'
required: true
default: 'false'
release_name:
description: 'Base name of the zip release files'
required: true
default: 'OP7_KSN_wifi'
jobs:
build:
runs-on: ubuntu-latest
env:
CCACHE_HARDLINK: "true"
CCACHE_NOHASHDIR: "true"
CCACHE_MAXSIZE: "3G"
CCACHE_COMPILERCHECK: "%compiler% -dumpmachine; %compiler% -dumpversion"
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Prepare kernel source
run: |
set -euo pipefail
rm -rf kernel builds || true
mkdir -p builds
git clone --depth=1 --branch ${{ github.event.inputs.kernel_branch }} ${{ github.event.inputs.kernel_repo_url }} kernel
cd kernel
git submodule update --init --recursive
- name: Setup dependencies
run: |
sudo apt-get update -y
sudo apt-get install -y clang-18 llvm-18 lld-18 \
gcc-aarch64-linux-gnu gcc-arm-linux-gnueabi binutils make python3 libssl-dev bc bison flex unzip \
ca-certificates xz-utils mkbootimg cpio device-tree-compiler git git-lfs zip
- name: Setup KernelSU or KernelSU-Next
working-directory: kernel
run: |
set -euo pipefail
export PATH=/usr/lib/llvm-18/bin:$PATH
if [ "${{ github.event.inputs.use_kernelsu_next }}" = "true" ]; then
curl -LSs "https://raw.githubusercontent.com/KernelSU-Next/KernelSU-Next/next/kernel/setup.sh" | bash -
else
curl -LSs "https://raw.githubusercontent.com/tiann/KernelSU/main/kernel/setup.sh" | bash -s stable
fi
- name: Apply SUSFS patches if enabled
if: ${{ github.event.inputs.enable_susfs == 'true' }}
working-directory: kernel
run: |
set -euo pipefail
git clone https://gitlab.com/simonpunk/susfs4ksu.git -b kernel-4.14 susfs_patches
cp susfs_patches/kernel_patches/KernelSU/10_enable_susfs_for_ksu.patch KernelSU/
cp susfs_patches/kernel_patches/50_add_susfs_in_kernel-4.14.patch .
cp susfs_patches/kernel_patches/fs/* ./fs/
cp susfs_patches/kernel_patches/include/linux/* ./include/linux/
cd KernelSU
patch -N -p1 -F 3 < 10_enable_susfs_for_ksu.patch || echo "Patch already applied or failed (ignore if already applied)"
cd ..
patch -N -p1 -F 3 < 50_add_susfs_in_kernel-4.14.patch || echo "Patch already applied or failed (ignore if already applied)"
find . -name "*.rej" -exec echo "Patch reject: {}" \; -exec cat {} \;
if find . -name "*.rej" | grep -q .; then
echo "FAIL: Some SUSFS hunks failed. Check your kernel version/patches above for why.";
exit 1;
fi
- name: Add SUSFS configs if enabled
if: ${{ github.event.inputs.enable_susfs == 'true' }}
working-directory: kernel
run: |
echo "CONFIG_KSU=y" >> arch/arm64/configs/${{ github.event.inputs.defconfig_file }}
echo "CONFIG_KSU_SUSFS=y" >> arch/arm64/configs/${{ github.event.inputs.defconfig_file }}
echo "CONFIG_KSU_SUSFS_SUS_PATH=y" >> arch/arm64/configs/${{ github.event.inputs.defconfig_file }}
echo "CONFIG_KSU_SUSFS_SUS_MOUNT=y" >> arch/arm64/configs/${{ github.event.inputs.defconfig_file }}
echo "CONFIG_KSU_SUSFS_SUS_KSTAT=y" >> arch/arm64/configs/${{ github.event.inputs.defconfig_file }}
echo "CONFIG_KSU_SUSFS_SUS_OVERLAYFS=y" >> arch/arm64/configs/${{ github.event.inputs.defconfig_file }}
echo "CONFIG_KSU_SUSFS_TRY_UMOUNT=y" >> arch/arm64/configs/${{ github.event.inputs.defconfig_file }}
echo "CONFIG_KSU_SUSFS_SPOOF_UNAME=y" >> arch/arm64/configs/${{ github.event.inputs.defconfig_file }}
echo "CONFIG_KSU_SUSFS_ENABLE_LOG=y" >> arch/arm64/configs/${{ github.event.inputs.defconfig_file }}
echo "CONFIG_KSU_SUSFS_OPEN_REDIRECT=y" >> arch/arm64/configs/${{ github.event.inputs.defconfig_file }}
echo "CONFIG_KSU_SUSFS_SUS_SU=y" >> arch/arm64/configs/${{ github.event.inputs.defconfig_file }}
- name: Build kernel
working-directory: kernel
run: |
set -euo pipefail
export PATH=/usr/lib/llvm-18/bin:$PATH
LTO=thin ARCH=arm64 CROSS_COMPILE=aarch64-none-linux-gnu- make ${{ github.event.inputs.defconfig_file }}
if [ -f build/build.sh ]; then
LTO=thin ARCH=arm64 CROSS_COMPILE=aarch64-none-linux-gnu- BUILD_CONFIG=common/build.config.aarch64 build/build.sh
else
make -j$(nproc)
fi
- name: Copy kernel Image.lz4 if exists
if: always()
run: |
if [ -f kernel/out/android12-5.10/dist/Image.lz4 ]; then
cp kernel/out/android12-5.10/dist/Image.lz4 kernel/AnyKernel3/Image.lz4
else
echo "Image.lz4 not found, skipping copy."
fi
- name: Package Kernel ZIP
working-directory: kernel/AnyKernel3
run: |
zip -r ../${{ github.event.inputs.release_name }}.zip *
- name: Build Wi-Fi Module (qca_cld3)
working-directory: kernel
run: |
set -euo pipefail
export PATH=/usr/lib/llvm-18/bin:$PATH
LTO=thin ARCH=arm64 CROSS_COMPILE=aarch64-none-linux-gnu- make modules_prepare
LTO=thin ARCH=arm64 CROSS_COMPILE=aarch64-none-linux-gnu- make -j$(nproc) -C drivers/staging/qcacld-3.0 M=$(pwd)/drivers/staging/qcacld-3.0 modules
mkdir -p ../modules/vendor/lib/modules
find out/drivers/staging/qcacld-3.0 -name "*.ko" -exec cp -v {} ../modules/vendor/lib/modules/ \;
sudo chown -R $(id -u):$(id -g) ../modules
- name: Package Wi-Fi Module ZIP
run: |
if [ ! -d "modules/vendor/lib/modules" ] || ! ls modules/vendor/lib/modules/*.ko >/dev/null 2>&1; then
echo "No Wi-Fi modules to package, exiting."
exit 1
fi
cd modules
zip -r ../${{ github.event.inputs.release_name }}-modules.zip *
- name: Upload kernel build artifacts
uses: actions/upload-artifact@v4
with:
name: kernel-output
path: kernel/out
- name: Upload zips
uses: actions/upload-artifact@v4
with:
name: build-zips
path: |
kernel/${{ github.event.inputs.release_name }}.zip
${{ github.event.inputs.release_name }}-modules.zip