Custom Build kernel and Wi-Fi module #35
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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-23.0' | |
| defconfig_file: | |
| description: 'Kernel defconfig filename' | |
| required: true | |
| default: 'defconfig' | |
| use_kernelsu_next: | |
| description: 'Use KernelSU-Next' | |
| required: true | |
| default: true | |
| type: boolean | |
| enable_susfs: | |
| description: 'Enable SUSFS patches' | |
| required: true | |
| default: false | |
| type: boolean | |
| release_name: | |
| description: 'Release name for ZIPs' | |
| required: true | |
| default: 'OP7_KSN_wifi' | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Install dependencies | |
| 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 | |
| - name: Clone kernel | |
| run: git clone --depth=1 --branch "${{ github.event.inputs.kernel_branch }}" "${{ github.event.inputs.kernel_repo_url }}" kernel | |
| - name: Setup KernelSU | |
| if: ${{ !github.event.inputs.use_kernelsu_next }} | |
| working-directory: ./kernel | |
| run: curl -LSs "https://raw.githubusercontent.com/tiann/KernelSU/main/kernel/setup.sh" | bash -s stable | |
| - name: Setup KernelSU-Next | |
| if: ${{ github.event.inputs.use_kernelsu_next }} | |
| working-directory: ./kernel | |
| run: curl -LSs "https://raw.githubusercontent.com/KernelSU-Next/KernelSU-Next/next/kernel/setup.sh" | bash - | |
| - name: Apply Patches and DEBUG | |
| working-directory: ./kernel | |
| shell: bash | |
| run: | | |
| set -x | |
| sed -i 's|try_to_unmap(page, ttu_flags);|try_to_unmap(page, ttu_flags, NULL);|g' mm/huge_memory.c | |
| sed -i 's/\(.*mm->nr_ptes.*\)/\/\* REMOVED_for_ARM64 \1 \*\//' mm/khugepaged.c | |
| if grep -qF "struct timespec now = current_time(&parent_inode->vfs_inode);" fs/btrfs/inode.c; then | |
| cat > btrfs_patch.diff <<- 'EOF' | |
| --- a/fs/btrfs/inode.c | |
| +++ b/fs/btrfs/inode.c | |
| @@ -6627,7 +6627,7 @@ | |
| - struct timespec now = current_time(&parent_inode->vfs_inode); | |
| + struct timespec64 now = current_time(&parent_inode->vfs_inode); | |
| EOF | |
| echo "--- DEBUG: Displaying patch file contents ---" | |
| cat btrfs_patch.diff | |
| echo "-------------------------------------------" | |
| patch -p1 < btrfs_patch.diff | |
| fi | |
| - name: Prepare kernel config | |
| working-directory: ./kernel | |
| run: | | |
| conf="arch/arm64/configs/${{ github.event.inputs.defconfig_file }}" | |
| echo "CONFIG_NR_CPUS=8" >> "$conf" | |
| for opt in CONFIG_TASKSTATS CONFIG_TASK_DELAY_ACCT CONFIG_TASK_XACCT CONFIG_TASK_IO_ACCOUNTING; do echo "${opt}=n" >> "$conf"; done | |
| 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 | |
| - name: Build kernel | |
| working-directory: ./kernel | |
| run: make O=out ARCH=arm64 LTO=thin CROSS_COMPILE=aarch64-linux-gnu- -j$(nproc) | |
| - name: Package Kernel ZIP | |
| run: | | |
| if [ -f kernel/out/arch/arm64/boot/Image.lz4 ]; then | |
| mkdir -p AnyKernel3 | |
| cp kernel/out/arch/arm64/boot/Image.lz4 AnyKernel3/Image.lz4 | |
| cd AnyKernel3 | |
| zip -r ../${{ github.event.inputs.release_name }}.zip ./* | |
| cd .. | |
| fi | |
| - name: Build and Package Wi-Fi Module | |
| run: | | |
| 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 | |
| cd .. | |
| mkdir -p modules/vendor/lib/modules | |
| find kernel/out -name "wlan.ko" -exec cp -v {} modules/vendor/lib/modules/ \; | |
| if [ -n "$(ls -A modules/vendor/lib/modules)" ]; then | |
| cd modules | |
| zip -r ../${{ github.event.inputs.release_name }}-modules.zip ./* | |
| cd .. | |
| fi | |
| - name: Upload zips | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: build-zips | |
| path: | | |
| ${{ github.event.inputs.release_name }}.zip | |
| ${{ github.event.inputs.release_name }}-modules.zip | |
| if-no-files-found: warn |