Build kernel (KSN) & WIFI #2
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: Build kernel (KSN) & WIFI | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| kernel_source_url: | |
| description: 'URL of the kernel source repository' | |
| required: true | |
| default: 'https://github.com/LineageOS/android_kernel_oneplus_sm8150' | |
| kernel_branch: | |
| description: 'Branch of the kernel source' | |
| required: true | |
| default: 'lineage-22.1' | |
| kernel_defconfig: | |
| description: 'defconfig file to use' | |
| required: true | |
| default: 'lineage_sm8150_defconfig' | |
| output_name: | |
| description: 'Name of the output.zip' | |
| required: false | |
| default: 'OP7_KSN_wifi' | |
| push: | |
| branches: | |
| - oneplus/OOS_SM8150_11.0 | |
| pull_request: | |
| branches: | |
| - oneplus/OOS_SM8150_11.0 | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| env: | |
| CCACHE_COMPILERCHECK: "%compiler% -dumpmachine; %compiler% -dumpversion" | |
| CCACHE_NOHASHDIR: "true" | |
| CCACHE_MAXSIZE: "2G" | |
| CCACHE_HARDLINK: "true" | |
| KERNEL_DEFCONFIG: ${{ github.event.inputs.kernel_defconfig || 'lineage_sm8150_defconfig' }} | |
| KERNEL_CMDLINE: "ARCH=arm64 CLANG_TRIPLE=aarch64-linux-gnu- CROSS_COMPILE=aarch64-linux-androidkernel- CROSS_COMPILE_ARM32=arm-linux-gnueabi- LLVM=1 LLVM_IAS=1 O=out" | |
| KERNEL_SOURCE_URL: ${{ github.event.inputs.kernel_source_url || 'https://github.com/LineageOS/android_kernel_oneplus_sm8150' }} | |
| KERNEL_BRANCH: ${{ github.event.inputs.kernel_branch || 'lineage-22.1' }} | |
| OUTPUT_ZIP_NAME: ${{ github.event.inputs.output_name || 'OP7_KSN_wifi' }} | |
| steps: | |
| - name: Checkout Kernel Source | |
| run: | | |
| git clone --depth=1 --branch "${KERNEL_BRANCH}" "${KERNEL_SOURCE_URL}" kernel | |
| cd kernel | |
| git submodule update --init --recursive | |
| cd .. | |
| env: | |
| KERNEL_SOURCE_URL: ${{ env.KERNEL_SOURCE_URL }} | |
| KERNEL_BRANCH: ${{ env.KERNEL_BRANCH }} | |
| - name: Set up ccache | |
| uses: hendrikmuhs/ccache-action@v1.2 | |
| - name: Cleanup space | |
| run: | | |
| sudo rm -rf /opt/ghc | |
| sudo rm -rf "/usr/local/share/boost" | |
| sudo rm -rf /usr/share/dotnet | |
| sudo rm -rf "$AGENT_TOOLSDIRECTORY" | |
| - name: Install dependencies | |
| run: | | |
| sudo apt-get update -y | |
| sudo apt install -y gcc-aarch64-linux-gnu gcc-arm-linux-gnueabi clang-14 llvm-14 lld-14 binutils-aarch64-linux-gnu binutils make python3 libssl-dev build-essential bc bison flex unzip libssl-dev ca-certificates xz-utils mkbootimg cpio device-tree-compiler git git-lfs | |
| git clone https://github.com/LineageOS/android_prebuilts_gcc_linux-x86_aarch64_aarch64-linux-android-4.9 aarch64 --depth=1 | |
| git clone https://github.com/khalidaboelmagd/AnyKernel3 | |
| rm -rf AnyKernel3/.git | |
| - name: Remove unnecessary files | |
| run: | | |
| sudo rm -rf /opt/ghc | |
| sudo rm -rf "/usr/local/share/boost" | |
| sudo rm -rf /usr/share/dotnet | |
| sudo rm -rf "$AGENT_TOOLSDIRECTORY" | |
| - name: Get Version | |
| id: get_version | |
| run: | | |
| cd kernel | |
| git fetch --unshallow | |
| git rev-list --count HEAD | |
| echo "VERSION=$(expr $(git rev-list --count HEAD) + 10200)" >> $GITHUB_OUTPUT | |
| cd .. | |
| - name: Build KernelSU-Next | |
| run: | | |
| export DTC_EXT=dtc | |
| export PATH=$(pwd)/aarch64/bin:/usr/lib/llvm-14/bin:$PATH | |
| export ARCH=arm64 | |
| export LD=ld.lld | |
| cd kernel | |
| curl -LSs "https://raw.githubusercontent.com/rifsxd/KernelSU-Next/next-susfs/kernel/setup.sh" | bash -s next | |
| make $KERNEL_CMDLINE $KERNEL_DEFCONFIG CC="ccache clang-14" | |
| make $KERNEL_CMDLINE scripts CC="ccache clang-14" | |
| make $KERNEL_CMDLINE prepare CC="ccache clang-14" | |
| make $KERNEL_CMDLINE CC="ccache clang-14" LD="ld.lld" -j$(nproc --all) | |
| cp out/arch/arm64/boot/Image ../AnyKernel3 | |
| cd .. | |
| ls -la AnyKernel3/ # Verify kernel image | |
| - name: Build Wi-Fi Module (qca_cld3) | |
| run: | | |
| export PATH=$(pwd)/aarch64/bin:/usr/lib/llvm-14/bin:$PATH | |
| export ARCH=arm64 | |
| export LD=ld.lld | |
| cd kernel | |
| # Prepare kernel for module building | |
| make $KERNEL_CMDLINE modules_prepare CC="ccache clang-14" | |
| # Build module with identical environment | |
| make $KERNEL_CMDLINE \ | |
| CC="ccache clang-14" \ | |
| LD=ld.lld \ | |
| -j$(nproc --all) \ | |
| M=drivers/staging/qcacld-3.0 \ | |
| modules | |
| # Create module directory structure | |
| sudo mkdir -p ../modules/vendor/lib/modules | |
| # Copy modules from OUT directory | |
| echo "Searching for modules in: $(pwd)/out/drivers/staging/qcacld-3.0" | |
| sudo find out/drivers/staging/qcacld-3.0 -name "*.ko" -exec cp -v {} ../modules/vendor/lib/modules/ \; | |
| # Verify copy operation | |
| echo "Copied modules:" | |
| ls -l ../modules/vendor/lib/modules/ | |
| # Fix permissions | |
| sudo chown -R $(id -u):$(id -g) ../modules | |
| cd .. | |
| - name: Package Kernel | |
| run: | | |
| echo "Packaging kernel from: $(pwd)" | |
| ls -la AnyKernel3/ | |
| cd AnyKernel3 | |
| zip -r ../${{ env.OUTPUT_ZIP_NAME }}.zip * | |
| echo "Created kernel zip:" | |
| ls -l ../*.zip | |
| cd .. | |
| - name: Package Wi-Fi Module | |
| run: | | |
| if [ ! -d "modules/vendor/lib/modules" ] || [ -z "$(ls -A modules/vendor/lib/modules/*.ko)" ]; then | |
| echo "Error: No Wi-Fi modules found to package!" | |
| exit 1 | |
| fi | |
| echo "Packaging modules from: $(pwd)/modules" | |
| ls -la modules/vendor/lib/modules/ | |
| cd modules | |
| zip -r ../${{ env.OUTPUT_ZIP_NAME }}-modules.zip * | |
| echo "Created modules zip:" | |
| ls -l ../*-modules.zip | |
| cd .. | |
| - name: Upload to Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| files: | | |
| ${{ env.OUTPUT_ZIP_NAME }}.zip | |
| ${{ env.OUTPUT_ZIP_NAME }}-modules.zip | |
| name: ${{ env.OUTPUT_ZIP_NAME }}-${{ steps.get_version.outputs.VERSION }} | |
| tag_name: ${{ steps.get_version.outputs.VERSION }} | |
| body: | | |
| Device: Oneplus 7/Oneplus 7Pro/Oneplus 7T/Oneplus 7TPro | |
| Includes: | |
| - Kernel Image | |
| - qca_cld3 Wi-Fi Module (vermagic matched) | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GH_PAT }} |