Repository navigation
Coba_Masak_CL22 #77
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: "Coba_Masak_CL22" | |
| env: | |
| OUT_DIR: "out" | |
| KERNEL_VERSION: "5.15" | |
| ANDROID_VERSION: "13" | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| kernelSourceURL: | |
| description: "Kernel source URL" | |
| required: true | |
| type: string | |
| default: "https://github.com/topnotchfreaks/kernel_msm-5.15" | |
| kernelBranch: | |
| description: "Kernel branch" | |
| required: false | |
| type: string | |
| default: "google" | |
| kernelDevice: | |
| description: "Device (used for defconfig)" | |
| required: true | |
| type: string | |
| default: "gki" | |
| localVersion: | |
| description: "Custom localversion name (e.g., -mybuild)" | |
| required: false | |
| type: string | |
| default: "-NeFaRiaN-3.0-G-16032026" | |
| buildKSU: | |
| description: "Build KSU variant?" | |
| required: true | |
| type: choice | |
| default: "both" | |
| options: | |
| - "noksu" | |
| - "ksu" | |
| - "both" | |
| ksuVariant: | |
| description: "KSU implementation (if KSU enabled)" | |
| required: true | |
| type: choice | |
| default: "wksu+susfs" | |
| options: | |
| - "kernelsu" | |
| - "kernelsu+susfs" | |
| - "sukisu+susfs" | |
| - "wildksu" | |
| - "wksu+susfs" | |
| - "next" | |
| - "next+susfs" | |
| optimizationLevel: | |
| description: "Compiler optimization level" | |
| required: false | |
| type: choice | |
| default: "O3" | |
| options: | |
| - "O2" | |
| - "O3" | |
| - "Os" | |
| tickRate: | |
| description: "Kernel tick rate (Hz)" | |
| required: false | |
| type: choice | |
| default: "500" | |
| options: | |
| - "default" | |
| - "100" | |
| - "250" | |
| - "300" | |
| - "500" | |
| - "600" | |
| - "750" | |
| - "1000" | |
| bbg: | |
| description: "Baseband-guard Support (if KSU Enabled)" | |
| required: true | |
| type: choice | |
| default: "on" | |
| options: | |
| - "on" | |
| - "off" | |
| swapSizeGB: | |
| description: "Optional swap size in GB to create on the runner (set 0 to disable)" | |
| required: false | |
| type: string | |
| default: "8" | |
| LTOOptimizations: | |
| description: "Choose LTO" | |
| required: true | |
| type: choice | |
| default: "thin" | |
| options: | |
| - "thin" | |
| - "full" | |
| jobs: | |
| Build-Kernel: | |
| name: "🚀 Build Kernel" | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| variant: ${{ fromJSON( | |
| inputs.buildKSU == 'both' && '["noksu", "ksu"]' || | |
| inputs.buildKSU == 'ksu' && '["ksu"]' || | |
| '["noksu"]' ) }} | |
| env: | |
| kernelDir: common_${{ github.event.inputs.kernelDevice }} | |
| kernelName: common | |
| DEFCONFIG_NAME: ${{ github.event.inputs.kernelDevice }}_defconfig | |
| WORK_DIR: ${{ github.workspace }} | |
| steps: | |
| - name: "✨ Setup WorkSpace" | |
| run: | | |
| mkdir -p $kernelDir | |
| echo "BUILD_TIME=$(date +'%Y-%m-%d')" >> $GITHUB_ENV | |
| sudo apt-get update -qq | |
| sudo apt-get install -y repo rsync aria2 build-essential bc curl flex cpio rsync git zip dwarves libelf-dev gcc-aarch64-linux-gnu libssl-dev python3 clang lld llvm llvm-dev | |
| - name: 🔍 Check Space (Before CleanUp) | |
| run: | | |
| echo "Disk space before cleanup:" | |
| df -h / | |
| - name: 🧹 Aggressive CleanUp | |
| run: | | |
| # Remove heavy pre-installed tools | |
| sudo rm -rf /usr/share/dotnet | |
| sudo rm -rf /usr/local/lib/android | |
| sudo rm -rf /opt/ghc | |
| sudo rm -rf "/usr/local/share/boost" | |
| sudo rm -rf "$AGENT_TOOLSDIRECTORY" | |
| # Prune Docker to remove hidden images and build cache | |
| sudo docker image prune --all --force | |
| sudo docker builder prune -a -f | |
| - name: 🔍 Check Space (After Cleanup) | |
| run: | | |
| echo "Disk space after cleanup:" | |
| df -h / | |
| - name: "🧰 Setup Swapfile (optional)" | |
| # swap creation happens early so build processes can use it | |
| run: | | |
| SWAP_GB="${{ github.event.inputs.swapSizeGB }}" | |
| # Normalize empty input to 0 | |
| if [ -z "$SWAP_GB" ]; then | |
| SWAP_GB=0 | |
| fi | |
| if [ "$SWAP_GB" != "0" ]; then | |
| echo "Requested swap: ${SWAP_GB}G" | |
| # If /swapfile exists, try to remove it first to avoid conflicts | |
| if [ -f /swapfile ]; then | |
| echo "Existing /swapfile found, disabling and removing..." | |
| sudo swapoff /swapfile || true | |
| sudo rm -f /swapfile | |
| fi | |
| # Try to create swap with fallocate for speed; fallback to dd | |
| if command -v fallocate >/dev/null 2>&1; then | |
| echo "Creating swapfile with fallocate..." | |
| sudo fallocate -l ${SWAP_GB}G /swapfile || sudo dd if=/dev/zero of=/swapfile bs=1M count=$((SWAP_GB * 1024)) | |
| else | |
| echo "fallocate not available, creating swapfile with dd..." | |
| sudo dd if=/dev/zero of=/swapfile bs=1M count=$((SWAP_GB * 1024)) | |
| fi | |
| sudo chmod 600 /swapfile | |
| sudo mkswap /swapfile | |
| sudo swapon /swapfile | |
| # Reduce swappiness so system prefers RAM but can use swap when needed | |
| sudo sysctl -w vm.swappiness=10 || true | |
| echo "SWAP_CREATED=true" >> $GITHUB_ENV | |
| echo "/swapfile created and activated (size: ${SWAP_GB}G)" | |
| else | |
| echo "No swap requested (swapSizeGB=${SWAP_GB})" | |
| fi | |
| - name: "🌟 Clone Kernel Source" | |
| working-directory: ./${{ env.kernelDir }} | |
| run: | | |
| git clone --recursive --branch ${{ github.event.inputs.kernelBranch }} \ | |
| ${{ github.event.inputs.kernelSourceURL }} ${{ env.kernelName }} --depth=1 | |
| - name: "📥 Initialize Repo ToolChain" | |
| working-directory: ${{ env.WORK_DIR}} | |
| run: | | |
| repo init -u https://android.googlesource.com/kernel/manifest -b common-android13-5.15-lts --depth=1 | |
| repo sync --optimized-fetch --prune --no-clone-bundle --no-tags -j$(nproc --all) | |
| rm -rf .repo | |
| rm -rf common | |
| aria2c -x 16 -s 16 -o prebuilts/clang/host/linux-x86/clang-r584948b.tar.gz "https://github.com/nebixts/clang_L/releases/download/v1.5.3/clang-r584948b.tar.gz" | |
| mkdir -p prebuilts/clang/host/linux-x86/clang-r584948b | |
| tar -xzf prebuilts/clang/host/linux-x86/clang-r584948b.tar.gz -C prebuilts/clang/host/linux-x86/clang-r584948b | |
| rm -rf prebuilts/clang/host/linux-x86/clang-r584948b.tar.gz | |
| rm -rf prebuilts/clang/host/linux-x86/clang-r547379 | |
| rm -rf prebuilts/clang/host/linux-x86/clang-3289846 | |
| rm -rf prebuilts/clang/host/linux-x86/clang-r450784e | |
| rm -rf prebuilts/clang/host/linux-x86/clang-stable | |
| sed -i \ | |
| -e 's/^BRANCH=.*/BRANCH=android13-5.15/' \ | |
| -e 's/^CLANG_VERSION=.*/CLANG_VERSION=r584948b/' \ | |
| ${{ env.kernelDir }}/${{ env.kernelName }}/build.config.constants | |
| sed -i '/^DEFCONFIG=gki_defconfig/d' ${{ env.kernelDir }}/${{ env.kernelName }}/build.config.gki | |
| sed -i '$a\DEFCONFIG=${{ env.DEFCONFIG_NAME }}' ${{ env.kernelDir }}/${{ env.kernelName }}/build.config.gki | |
| sed -i '/^POST_DEFCONFIG_CMDS="check_defconfig"/d' ${{ env.kernelDir }}/${{ env.kernelName }}/build.config.gki | |
| sed -i \ | |
| -e '/^KMI_SYMBOL_LIST_STRICT_MODE=/d' \ | |
| -e '/^TRIM_NONLISTED_KMI=/d' \ | |
| -e '/^KMI_ENFORCED=/d' \ | |
| -e '$a\KMI_SYMBOL_LIST_STRICT_MODE=0' \ | |
| -e '$a\TRIM_NONLISTED_KMI=0' \ | |
| -e '$a\KMI_ENFORCED=0' \ | |
| -e '/^MODULES_ORDER=/d' \ | |
| -e '/^MODULES_LIST=/d' \ | |
| ${{ env.kernelDir }}/${{ env.kernelName }}/build.config.gki.aarch64 | |
| - name: "📐 Setup SWAP 24GB" | |
| uses: pierotofy/set-swap-space@master | |
| with: | |
| swap-size-gb: 24 | |
| - name: "⚙️ Configure Kernel Optimization and TickRate" | |
| working-directory: ./${{ env.kernelDir }}/${{ env.kernelName }} | |
| run: | | |
| CONFIG_FILE="arch/arm64/configs/${{ env.DEFCONFIG_NAME }}"; | |
| # Helper | |
| apply_patch() { | |
| local url="$1"; | |
| local file=$(basename "$url") | |
| curl -L -o "$file" "$url" | |
| patch -p1 < "$file" || echo "::warning::Hunks failed in $file" | |
| rm -f "$file" | |
| } | |
| # Remove existing optimization configs | |
| sed -i '/CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE/d' "$CONFIG_FILE" | |
| sed -i '/CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3/d' "$CONFIG_FILE" | |
| sed -i '/CONFIG_CC_OPTIMIZE_FOR_SIZE/d' "$CONFIG_FILE" | |
| # Apply selected optimization level | |
| case "${{ github.event.inputs.optimizationLevel }}" in | |
| O2) | |
| echo "CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE=y" >> "$CONFIG_FILE" | |
| echo "# CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3 is not set" >> "$CONFIG_FILE" | |
| echo "# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set" >> "$CONFIG_FILE" | |
| ;; | |
| O3) | |
| echo "# CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE is not set" >> "$CONFIG_FILE" | |
| echo "CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3=y" >> "$CONFIG_FILE" | |
| echo "# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set" >> "$CONFIG_FILE" | |
| patch -p1 "https://raw.githubusercontent.com/nebixts/kernel_patches/main/add_-03.patch" | |
| grep "KBUILD_CFLAGS += -O3" Makefile || (echo "Patch failed!" && exit 1) | |
| ;; | |
| Os) | |
| echo "# CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE is not set" >> "$CONFIG_FILE" | |
| echo "# CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3 is not set" >> "$CONFIG_FILE" | |
| echo "CONFIG_CC_OPTIMIZE_FOR_SIZE=y" >> "$CONFIG_FILE" | |
| ;; | |
| esac | |
| # custom tickrate options patch | |
| apply_patch "https://raw.githubusercontent.com/nebixts/kernel_patches/main/custom_tickrate_options.patch" | |
| # Apply selected tick rate | |
| case "${{ github.event.inputs.tickRate }}" in | |
| default) | |
| echo Nothing to change. Keep Default. | |
| ;; | |
| 100) | |
| sed -i '/^CONFIG_HZ_100=/d' "$CONFIG_FILE" | |
| sed -i '/^CONFIG_HZ_250=/d' "$CONFIG_FILE" | |
| sed -i '/^CONFIG_HZ_300=/d' "$CONFIG_FILE" | |
| sed -i '/^CONFIG_HZ_1000=/d' "$CONFIG_FILE" | |
| echo "CONFIG_NO_HZ_IDLE=y" >> "$CONFIG_FILE" | |
| echo "CONFIG_HZ=100" >> "$CONFIG_FILE" | |
| echo "CONFIG_HZ_100=y" >> "$CONFIG_FILE" | |
| ;; | |
| 250) | |
| sed -i '/^CONFIG_HZ_100=/d' "$CONFIG_FILE" | |
| sed -i '/^CONFIG_HZ_250=/d' "$CONFIG_FILE" | |
| sed -i '/^CONFIG_HZ_300=/d' "$CONFIG_FILE" | |
| sed -i '/^CONFIG_HZ_1000=/d' "$CONFIG_FILE" | |
| echo "CONFIG_NO_HZ_IDLE=y" >> "$CONFIG_FILE" | |
| echo "CONFIG_HZ=250" >> "$CONFIG_FILE" | |
| echo "CONFIG_HZ_250=y" >> "$CONFIG_FILE" | |
| ;; | |
| 300) | |
| sed -i '/^CONFIG_HZ_100=/d' "$CONFIG_FILE" | |
| sed -i '/^CONFIG_HZ_250=/d' "$CONFIG_FILE" | |
| sed -i '/^CONFIG_HZ_300=/d' "$CONFIG_FILE" | |
| sed -i '/^CONFIG_HZ_1000=/d' "$CONFIG_FILE" | |
| echo "CONFIG_NO_HZ_IDLE=y" >> "$CONFIG_FILE" | |
| echo "CONFIG_HZ=300" >> "$CONFIG_FILE" | |
| echo "CONFIG_HZ_300=y" >> "$CONFIG_FILE" | |
| ;; | |
| 500) | |
| sed -i '/^CONFIG_HZ_100=/d' "$CONFIG_FILE" | |
| sed -i '/^CONFIG_HZ_250=/d' "$CONFIG_FILE" | |
| sed -i '/^CONFIG_HZ_300=/d' "$CONFIG_FILE" | |
| sed -i '/^CONFIG_HZ_500=/d' "$CONFIG_FILE" | |
| sed -i '/^CONFIG_HZ_600=/d' "$CONFIG_FILE" | |
| sed -i '/^CONFIG_HZ_750=/d' "$CONFIG_FILE" | |
| sed -i '/^CONFIG_HZ_1000=/d' "$CONFIG_FILE" | |
| echo "CONFIG_NO_HZ_IDLE=y" >> "$CONFIG_FILE" | |
| echo "CONFIG_HZ=500" >> "$CONFIG_FILE" | |
| echo "CONFIG_HZ_500=y" >> "$CONFIG_FILE" | |
| ;; | |
| 600) | |
| sed -i '/^CONFIG_HZ_100=/d' "$CONFIG_FILE" | |
| sed -i '/^CONFIG_HZ_250=/d' "$CONFIG_FILE" | |
| sed -i '/^CONFIG_HZ_300=/d' "$CONFIG_FILE" | |
| sed -i '/^CONFIG_HZ_500=/d' "$CONFIG_FILE" | |
| sed -i '/^CONFIG_HZ_600=/d' "$CONFIG_FILE" | |
| sed -i '/^CONFIG_HZ_750=/d' "$CONFIG_FILE" | |
| sed -i '/^CONFIG_HZ_1000=/d' "$CONFIG_FILE" | |
| echo "CONFIG_NO_HZ_IDLE=y" >> "$CONFIG_FILE" | |
| echo "CONFIG_HZ=600" >> "$CONFIG_FILE" | |
| echo "CONFIG_HZ_600=y" >> "$CONFIG_FILE" | |
| ;; | |
| 750) | |
| sed -i '/^CONFIG_HZ_100=/d' "$CONFIG_FILE" | |
| sed -i '/^CONFIG_HZ_250=/d' "$CONFIG_FILE" | |
| sed -i '/^CONFIG_HZ_300=/d' "$CONFIG_FILE" | |
| sed -i '/^CONFIG_HZ_500=/d' "$CONFIG_FILE" | |
| sed -i '/^CONFIG_HZ_600=/d' "$CONFIG_FILE" | |
| sed -i '/^CONFIG_HZ_750=/d' "$CONFIG_FILE" | |
| sed -i '/^CONFIG_HZ_1000=/d' "$CONFIG_FILE" | |
| echo "CONFIG_NO_HZ_IDLE=y" >> "$CONFIG_FILE" | |
| echo "CONFIG_HZ=750" >> "$CONFIG_FILE" | |
| echo "CONFIG_HZ_750=y" >> "$CONFIG_FILE" | |
| ;; | |
| 1000) | |
| sed -i '/^CONFIG_HZ_100=/d' "$CONFIG_FILE" | |
| sed -i '/^CONFIG_HZ_250=/d' "$CONFIG_FILE" | |
| sed -i '/^CONFIG_HZ_300=/d' "$CONFIG_FILE" | |
| sed -i '/^CONFIG_HZ_1000=/d' "$CONFIG_FILE" | |
| echo "CONFIG_NO_HZ_IDLE=y" >> "$CONFIG_FILE" | |
| echo "CONFIG_HZ=1000" >> "$CONFIG_FILE" | |
| echo "CONFIG_HZ_1000=y" >> "$CONFIG_FILE" | |
| ;; | |
| esac | |
| # Set localversion | |
| if [ -n "${{ github.event.inputs.localVersion }}" ]; then | |
| echo "CONFIG_LOCALVERSION=\"${{ github.event.inputs.localVersion }}\"" >> "$CONFIG_FILE" | |
| echo "CONFIG_LOCALVERSION_AUTO=n\"" >> "$CONFIG_FILE" | |
| fi | |
| # Full Metamodule + KP NEXT Support | |
| echo "CONFIG_KALLSYMS=y" >> "$CONFIG_FILE" | |
| echo "CONFIG_KALLSYMS_ALL=y >> $CONFIG_FILE" | |
| echo "CONFIG_TMPFS_XATTR=y" >> "$CONFIG_FILE" | |
| echo "CONFIG_TMPFS_POSIX_ACL=y" >> "$CONFIG_FILE" | |
| echo "CONFIG_OVERLAY_FS=y" >> "$CONFIG_FILE" | |
| # Extra TCP configs | |
| cat >> "$CONFIG_FILE" << 'EOF' | |
| CONFIG_TCP_CONG_ADVANCED=y | |
| CONFIG_TCP_CONG_BIC=y | |
| CONFIG_TCP_CONG_WESTWOOD=y | |
| CONFIG_TCP_CONG_HTCP=y | |
| CONFIG_TCP_CONG_BBR=y | |
| CONFIG_DEFAULT_WESTWOOD=y | |
| CONFIG_NET_SCH_FQ=y | |
| CONFIG_NET_SCH_FQ_CODEL=y | |
| EOF | |
| # Networking Configuration | |
| cat >> "$CONFIG_FILE" << 'EOF' | |
| CONFIG_IP_NF_TARGET_TTL=y | |
| CONFIG_IP6_NF_TARGET_HL=y | |
| CONFIG_IP6_NF_MATCH_HL=y | |
| EOF | |
| # IPSet Support | |
| cat >> "$CONFIG_FILE" << 'EOF' | |
| CONFIG_IP_SET=y | |
| CONFIG_IP_SET_MAX=65534 | |
| CONFIG_IP_SET_BITMAP_IP=y | |
| CONFIG_IP_SET_BITMAP_IPMAC=y | |
| CONFIG_IP_SET_BITMAP_PORT=y | |
| CONFIG_IP_SET_HASH_IP=y | |
| CONFIG_IP_SET_HASH_IPMARK=y | |
| CONFIG_IP_SET_HASH_IPPORT=y | |
| CONFIG_IP_SET_HASH_IPPORTIP=y | |
| CONFIG_IP_SET_HASH_IPPORTNET=y | |
| CONFIG_IP_SET_HASH_IPMAC=y | |
| CONFIG_IP_SET_HASH_MAC=y | |
| CONFIG_IP_SET_HASH_NETPORTNET=y | |
| CONFIG_IP_SET_HASH_NET=y | |
| CONFIG_IP_SET_HASH_NETNET=y | |
| CONFIG_IP_SET_HASH_NETPORT=y | |
| CONFIG_IP_SET_HASH_NETIFACE=y | |
| CONFIG_IP_SET_LIST_SET=y | |
| EOF | |
| # Script sign patch | |
| apply_patch "https://raw.githubusercontent.com/nebixts/kernel_patches/main/0001-scripts-sign-builds.patch" | |
| echo "✅ Applied -${{ github.event.inputs.optimizationLevel }} Optimization" | |
| echo "✅ Applied ${{ github.event.inputs.tickRate }}Hz tick rate" | |
| echo "✅ Applied Full Meta Module Support" | |
| echo "✅ Applied Extra TCP configs" | |
| echo "✅ Applied Networking Configuration" | |
| echo "✅ Applied IPSet Support" | |
| - name: "🔧 Add BBG Support (KSU variant only)" | |
| if: matrix.variant == 'ksu' && github.event.inputs.bbg == 'on' | |
| working-directory: ./${{ env.kernelDir }}/${{ env.kernelName }} | |
| run: | | |
| echo "Adding BBG..."; | |
| wget -O- https://github.com/vc-teahouse/Baseband-guard/raw/main/setup.sh | bash | |
| echo "CONFIG_BBG=y" >> arch/arm64/configs/${{ env.DEFCONFIG_NAME }} | |
| sed -i '/^config LSM$/,/^help$/{ /^[[:space:]]*default/ { /baseband_guard/! s/selinux/selinux,baseband_guard/ } }' security/Kconfig | |
| - name: "🔧 Setup KernelSU" | |
| if: matrix.variant == 'ksu' && github.event.inputs.ksuVariant == 'kernelsu' | |
| working-directory: ./${{ env.kernelDir }}/${{ env.kernelName }} | |
| run: | | |
| rm -rf ./KernelSU ./drivers/kernelsu | |
| echo "📦 Installing KernelSU..." | |
| curl -LSs "https://raw.githubusercontent.com/tiann/KernelSU/main/kernel/setup.sh" | bash -s main | |
| echo "✔ KernelSU installed successfully" | |
| # Add KSU configs | |
| CONFIG_FILE="arch/arm64/configs/${{ env.DEFCONFIG_NAME }}" | |
| cat >> "$CONFIG_FILE" << 'EOF' | |
| CONFIG_KSU=y | |
| CONFIG_KPROBES=y | |
| CONFIG_HAVE_KPROBES=y | |
| CONFIG_KPROBE_EVENTS=y | |
| CONFIG_KSU_KPROBES_HOOK=y | |
| EOF | |
| echo "🎉 KernelSU kernel patches fully integrated" | |
| - name: "🔧 Setup KernelSU+SUSFS" | |
| if: matrix.variant == 'ksu' && github.event.inputs.ksuVariant == 'kernelsu+susfs' | |
| working-directory: ./${{ env.kernelDir }}/${{ env.kernelName }} | |
| run: | | |
| rm -rf ./KernelSU ./drivers/kernelsu | |
| echo "📦 Installing KernelSU..." | |
| curl -LSs "https://raw.githubusercontent.com/tiann/KernelSU/main/kernel/setup.sh" | bash -s main | |
| echo "✔ KernelSU installed successfully" | |
| echo "📦 Cloning SUSFS4KSU..." | |
| git clone --depth=1 https://gitlab.com/simonpunk/susfs4ksu.git -b gki-android13-5.15 | |
| SUSFS_KERNEL_PATCH="susfs4ksu/kernel_patches/50_add_susfs_in_gki-android13-5.15.patch" | |
| echo "🔧 Applying SUSFS kernel patch if possible..."; | |
| if patch -p1 < "$SUSFS_KERNEL_PATCH"; then | |
| echo "✅ SUSFS patch successfully applied" | |
| else | |
| echo "⚠️ SUSFS patch failed — copying files manually" | |
| fi | |
| echo "📄 Forcing SUSFS source injection..." | |
| # Always replace fs/susfs.c | |
| mkdir -p fs | |
| cp -f susfs4ksu/kernel_patches/fs/susfs.c fs/susfs.c | |
| echo "✔ Copied fs/susfs.c" | |
| # Always replace include/linux/susfs.h | |
| mkdir -p include/linux | |
| cp -f susfs4ksu/kernel_patches/include/linux/susfs.h include/linux/susfs.h | |
| echo "✔ Copied include/linux/susfs.h" | |
| # NEW: Also install missing susfs_def.h | |
| if [ -f susfs4ksu/kernel_patches/include/linux/susfs_def.h ]; then | |
| cp -f susfs4ksu/kernel_patches/include/linux/susfs_def.h include/linux/susfs_def.h | |
| echo "✔ Copied include/linux/susfs_def.h" | |
| else | |
| echo "⚠️ susfs_def.h not found in repo" | |
| fi | |
| echo "📦 Injecting SUSFS -> KernelSU integration files" | |
| if [ -d "susfs4ksu/kernel_patches/KernelSU/kernel" ]; then | |
| cp -rf susfs4ksu/kernel_patches/KernelSU/kernel/* KernelSU/kernel/ | |
| echo "✔ Copied SUSFS KernelSU integration files" | |
| fi | |
| echo "🔧 Applying SUSFS -> KernelSU patch..." | |
| KSU_PATCH="susfs4ksu/kernel_patches/KernelSU/10_enable_susfs_for_ksu.patch" | |
| if [ -f "$KSU_PATCH" ]; then | |
| cd KernelSU | |
| if patch -p1 --dry-run < ../$KSU_PATCH >/dev/null; then | |
| patch -p1 < ../$KSU_PATCH && echo "✔ Applied KSU SUSFS patch" | |
| cd .. | |
| else | |
| echo "⚠️ KSU SUSFS patch failed — applying manual fallback" | |
| cd .. | |
| sed -i '/#include /a #include ' KernelSU/kernel/ksu.c | |
| sed -i '/ksu_core_init()/a \tsusfs_init();' KernelSU/kernel/ksu.c | |
| fi | |
| else | |
| echo "⚠️ KSU patch missing — manually injecting changes" | |
| sed -i '/#include /a #include ' KernelSU/kernel/ksu.c | |
| sed -i '/ksu_core_init()/a \tsusfs_init();' KernelSU/kernel/ksu.c | |
| fi | |
| echo "🔍 Verifying SUSFS files..." | |
| for f in fs/susfs.c include/linux/susfs.h include/linux/susfs_def.h; do | |
| if [ -f "$f" ]; then echo "✔ Found: $f"; else echo "❌ Missing: $f"; fi | |
| done | |
| rm -rf susfs4ksu | |
| # Add KSU/KSUN/WKSU configs with SUSFS | |
| CONFIG_FILE="arch/arm64/configs/${{ env.DEFCONFIG_NAME }}" | |
| cat >> "$CONFIG_FILE" << 'EOF' | |
| CONFIG_KSU=y | |
| CONFIG_KSU_SUSFS=y | |
| CONFIG_KSU_SUSFS_HAS_MAGIC_MOUNT=y | |
| CONFIG_KSU_SUSFS_SUS_PATH=y | |
| CONFIG_KSU_SUSFS_SUS_MOUNT=y | |
| CONFIG_KSU_SUSFS_AUTO_ADD_SUS_KSU_DEFAULT_MOUNT=y | |
| CONFIG_KSU_SUSFS_AUTO_ADD_SUS_BIND_MOUNT=y | |
| CONFIG_KSU_SUSFS_SUS_KSTAT=y | |
| CONFIG_KSU_SUSFS_TRY_UMOUNT=y | |
| CONFIG_KSU_SUSFS_AUTO_ADD_TRY_UMOUNT_FOR_BIND_MOUNT=y | |
| CONFIG_KSU_SUSFS_SPOOF_UNAME=y | |
| CONFIG_KSU_SUSFS_ENABLE_LOG=y | |
| CONFIG_KSU_SUSFS_HIDE_KSU_SUSFS_SYMBOLS=y | |
| CONFIG_KSU_SUSFS_SPOOF_CMDLINE_OR_BOOTCONFIG=y | |
| CONFIG_KSU_SUSFS_OPEN_REDIRECT=y | |
| CONFIG_KSU_SUSFS_SUS_MAP=y | |
| CONFIG_KSU_SUSFS_SUS_SU=y | |
| EOF | |
| echo "🎉 KernelSU kernel patches fully integrated" | |
| - name: "🔧 Setup SukiSU-Ultra (Stable)" | |
| if: matrix.variant == 'ksu' && github.event.inputs.ksuVariant == 'sukisu+susfs' | |
| working-directory: ./${{ env.kernelDir }}/${{ env.kernelName }} | |
| run: | | |
| rm -rf ./KernelSU ./drivers/kernelsu | |
| # Install SukiSU-Ultra with SUSFS | |
| curl -LSs "https://raw.githubusercontent.com/ShirkNeko/SukiSU-Ultra/main/kernel/setup.sh" | bash -s builtin | |
| # Apply SUSFS patch | |
| PATCH_URL="https://api.github.com/repos/topnotchfreaks/kernel_patches/releases/latest" | |
| SUSFS_PATCH=$(curl -s "$PATCH_URL" | grep "browser_download_url.*0001-Implement-SUSFS.*Android-13.*Kernel-5.15.*patch" | cut -d '"' -f 4 | head -n 1) | |
| if [ -n "$SUSFS_PATCH" ]; then | |
| curl -L -o susfs.patch "$SUSFS_PATCH" | |
| patch -p1 < susfs.patch || echo "Warning: SUSFS patch failed" | |
| fi | |
| # Add KSU configs | |
| CONFIG_FILE="arch/arm64/configs/${{ env.DEFCONFIG_NAME }}" | |
| cat >> "$CONFIG_FILE" << 'EOF' | |
| CONFIG_KSU=y | |
| CONFIG_KSU_SUSFS=y | |
| CONFIG_KSU_SUSFS_HAS_MAGIC_MOUNT=y | |
| CONFIG_KSU_SUSFS_SUS_PATH=y | |
| CONFIG_KSU_SUSFS_SUS_MOUNT=y | |
| CONFIG_KSU_SUSFS_AUTO_ADD_SUS_KSU_DEFAULT_MOUNT=y | |
| CONFIG_KSU_SUSFS_AUTO_ADD_SUS_BIND_MOUNT=y | |
| CONFIG_KSU_SUSFS_SUS_KSTAT=y | |
| CONFIG_KSU_SUSFS_TRY_UMOUNT=y | |
| CONFIG_KSU_SUSFS_AUTO_ADD_TRY_UMOUNT_FOR_BIND_MOUNT=y | |
| CONFIG_KSU_SUSFS_SPOOF_UNAME=y | |
| CONFIG_KSU_SUSFS_ENABLE_LOG=y | |
| CONFIG_KSU_SUSFS_HIDE_KSU_SUSFS_SYMBOLS=y | |
| CONFIG_KSU_SUSFS_SPOOF_CMDLINE_OR_BOOTCONFIG=y | |
| CONFIG_KSU_SUSFS_OPEN_REDIRECT=y | |
| CONFIG_KSU_SUSFS_SUS_MAP=y | |
| CONFIG_KSU_SUSFS_SUS_SU=y | |
| CONFIG_KPM=y | |
| EOF | |
| echo "✅ Installed SukiSU-Ultra with SUSFS" | |
| - name: "🔧 Setup Wild KSU" | |
| if: matrix.variant == 'ksu' && github.event.inputs.ksuVariant == 'wildksu' | |
| working-directory: ./${{ env.kernelDir }}/${{ env.kernelName }} | |
| run: | | |
| rm -rf ./KernelSU ./drivers/kernelsu | |
| echo "📦 Installing Wild KSU..." | |
| # Install WildKSU | |
| curl -LSs "https://raw.githubusercontent.com/WildKernels/Wild_KSU/wild/kernel/setup.sh" | bash -s canary | |
| echo "✔ Wild KSU installed successfully" | |
| # Add KSU configs | |
| CONFIG_FILE="arch/arm64/configs/${{ env.DEFCONFIG_NAME }}" | |
| cat >> "$CONFIG_FILE" << 'EOF' | |
| CONFIG_KSU=y | |
| CONFIG_KPROBES=y | |
| CONFIG_HAVE_KPROBES=y | |
| CONFIG_KPROBE_EVENTS=y | |
| CONFIG_KSU_KPROBES_HOOK=y | |
| EOF | |
| echo "🎉 Wild KSU kernel patches fully integrated!" | |
| - name: "🔧 Setup Wild KSU with SUSFS" | |
| if: matrix.variant == 'ksu' && github.event.inputs.ksuVariant == 'wksu+susfs' | |
| working-directory: ./${{ env.kernelDir }}/${{ env.kernelName }} | |
| run: | | |
| rm -rf ./KernelSU ./drivers/kernelsu | |
| echo "📦 Installing Wild KSU..." | |
| # Install WildKSU with SUSFS | |
| curl -LSs "https://raw.githubusercontent.com/WildKernels/Wild_KSU/wild/kernel/setup.sh" | bash -s canary | |
| echo "✔ Wild KSU installed successfully" | |
| # Clone SUSFS4KSU for kernel patches only (not KSU integration) | |
| echo "📦 Cloning SUSFS4KSU for kernel patches..." | |
| git clone --depth=1 https://gitlab.com/simonpunk/susfs4ksu.git -b gki-android13-5.15 | |
| SUSFS_KERNEL_PATCH="susfs4ksu/kernel_patches/50_add_susfs_in_gki-android13-5.15.patch" | |
| echo "🔧 Applying SUSFS kernel patch..." | |
| if patch -p1 < "$SUSFS_KERNEL_PATCH"; then | |
| echo "✅ SUSFS patch successfully applied" | |
| else | |
| echo "⚠️ SUSFS patch failed — copying files manually" | |
| fi | |
| echo "🔧 Applying SUSFS -> KernelSU patch..." | |
| KSU_PATCH="susfs4ksu/kernel_patches/KernelSU/10_enable_susfs_for_ksu.patch" | |
| echo "📄 Forcing SUSFS source injection..." | |
| # Always replace fs/susfs.c | |
| mkdir -p fs | |
| cp -f susfs4ksu/kernel_patches/fs/susfs.c fs/susfs.c | |
| echo "✔ Copied fs/susfs.c" | |
| # Always replace include/linux/susfs.h | |
| mkdir -p include/linux | |
| cp -f susfs4ksu/kernel_patches/include/linux/susfs.h include/linux/susfs.h | |
| echo "✔ Copied include/linux/susfs.h" | |
| # Also install missing susfs_def.h | |
| if [ -f susfs4ksu/kernel_patches/include/linux/susfs_def.h ]; then | |
| cp -f susfs4ksu/kernel_patches/include/linux/susfs_def.h include/linux/susfs_def.h | |
| echo "✔ Copied include/linux/susfs_def.h" | |
| else | |
| echo "⚠️ susfs_def.h not found in repo" | |
| fi | |
| echo "🔍 Verifying SUSFS files..." | |
| for f in fs/susfs.c include/linux/susfs.h include/linux/susfs_def.h; do | |
| if [ -f "$f" ]; then echo "✔ Found: $f"; else echo "❌ Missing: $f"; fi | |
| done | |
| # Clean up SUSFS repo (we only needed kernel patches, not KSU integration) | |
| rm -rf susfs4ksu | |
| # Create symbolic link for drivers/kernelsu (if needed by build system) | |
| if [ ! -L "drivers/kernelsu" ]; then | |
| ln -sf ../KernelSU drivers/kernelsu | |
| echo "✔ Created drivers/kernelsu symlink" | |
| fi | |
| # Add KSU/KSUN/WKSU configs with SUSFS | |
| CONFIG_FILE="arch/arm64/configs/${{ env.DEFCONFIG_NAME }}" | |
| cat >> "$CONFIG_FILE" << 'EOF' | |
| CONFIG_KSU=y | |
| CONFIG_KSU_SUSFS=y | |
| CONFIG_KSU_SUSFS_HAS_MAGIC_MOUNT=y | |
| CONFIG_KSU_SUSFS_SUS_PATH=y | |
| CONFIG_KSU_SUSFS_SUS_MOUNT=y | |
| CONFIG_KSU_SUSFS_AUTO_ADD_SUS_KSU_DEFAULT_MOUNT=y | |
| CONFIG_KSU_SUSFS_AUTO_ADD_SUS_BIND_MOUNT=y | |
| CONFIG_KSU_SUSFS_SUS_KSTAT=y | |
| CONFIG_KSU_SUSFS_TRY_UMOUNT=y | |
| CONFIG_KSU_SUSFS_AUTO_ADD_TRY_UMOUNT_FOR_BIND_MOUNT=y | |
| CONFIG_KSU_SUSFS_SPOOF_UNAME=y | |
| CONFIG_KSU_SUSFS_ENABLE_LOG=y | |
| CONFIG_KSU_SUSFS_HIDE_KSU_SUSFS_SYMBOLS=y | |
| CONFIG_KSU_SUSFS_SPOOF_CMDLINE_OR_BOOTCONFIG=y | |
| CONFIG_KSU_SUSFS_OPEN_REDIRECT=y | |
| CONFIG_KSU_SUSFS_SUS_MAP=y | |
| CONFIG_KSU_SUSFS_SUS_SU=y | |
| EOF | |
| echo "🎉 Wild KSU with SUSFS kernel patches fully integrated!" | |
| - name: "🔧 Setup NEXT" | |
| if: matrix.variant == 'ksu' && github.event.inputs.ksuVariant == 'next' | |
| working-directory: ./${{ env.kernelDir }}/${{ env.kernelName }} | |
| run: | | |
| rm -rf ./KernelSU ./drivers/kernelsu | |
| echo "📦 Installing NEXT..." | |
| # Install NEXT | |
| curl -LSs "https://raw.githubusercontent.com/KernelSU-Next/KernelSU-Next/next/kernel/setup.sh" | bash -s main | |
| echo "✔ NEXT installed successfully" | |
| # Add KSU configs | |
| CONFIG_FILE="arch/arm64/configs/${{ env.DEFCONFIG_NAME }}" | |
| cat >> "$CONFIG_FILE" << 'EOF' | |
| CONFIG_KSU=y | |
| CONFIG_KPROBES=y | |
| CONFIG_HAVE_KPROBES=y | |
| CONFIG_KPROBE_EVENTS=y | |
| CONFIG_KSU_KPROBES_HOOK=y | |
| EOF | |
| echo "🎉 NEXT kernel patches fully integrated" | |
| - name: "🔧 Setup NEXT with SUSFS" | |
| if: matrix.variant == 'ksu' && github.event.inputs.ksuVariant == 'next+susfs' | |
| working-directory: ./${{ env.kernelDir }}/${{ env.kernelName }} | |
| run: | | |
| # Install KernelSU-Next using the official remote script | |
| rm -rf ./KernelSU ./drivers/kernelsu | |
| echo "📦 Installing NEXT..." | |
| curl -LSs "https://raw.githubusercontent.com/KernelSU-Next/KernelSU-Next/next/kernel/setup.sh" | bash -s dev | |
| # Clone the official SUSFS repository for GKI 13-5.15 | |
| echo "📦 Cloning SUSFS4KSU..." | |
| git clone --depth=1 https://gitlab.com/simonpunk/susfs4ksu.git -b gki-android13-5.15 | |
| # Inject SUSFS source files to the KERNEL root | |
| echo "📄 Injecting SUSFS source files..." | |
| cp -f susfs4ksu/kernel_patches/fs/susfs.c fs/ | |
| cp -f susfs4ksu/kernel_patches/include/linux/susfs.h include/linux/ | |
| [ -f susfs4ksu/kernel_patches/include/linux/susfs_def.h ] && cp -f susfs4ksu/kernel_patches/include/linux/susfs_def.h include/linux/ | |
| # Apply Kernel-level Patch (Targets the main kernel tree) | |
| echo "🔧 Applying SUSFS kernel patch..." | |
| patch -p1 < susfs4ksu/kernel_patches/50_add_susfs_in_gki-android13-5.15.patch || echo "⚠️ Kernel patch failed" | |
| echo "📦 Injecting SUSFS -> KernelSU integration files" | |
| if [ -d "susfs4ksu/kernel_patches/KernelSU/kernel" ]; then | |
| cp -rf susfs4ksu/kernel_patches/KernelSU/kernel/* KernelSU/kernel/ | |
| echo "✔ Copied SUSFS KernelSU integration files" | |
| fi | |
| # Apply KSU-specific SUSFS patch (CRITICAL: Targets KernelSU folder) | |
| echo "🔧 Applying SUSFS -> KernelSU patch..." | |
| KSU_PATCH=susfs4ksu/kernel_patches/KernelSU/10_enable_susfs_for_ksu.patch || echo "⚠️ KSU patch failed" | |
| echo "🔍 Verifying SUSFS files..." | |
| for f in fs/susfs.c include/linux/susfs.h include/linux/susfs_def.h; do | |
| if [ -f "$f" ]; then echo "✔ Found: $f"; else echo "❌ Missing: $f"; fi | |
| done | |
| # Clean up SUSFS repo (we only needed kernel patches, not KSU integration) | |
| rm -rf susfs4ksu | |
| # Create symbolic link for drivers/kernelsu (if needed by build system) | |
| if [ ! -L "drivers/kernelsu" ]; then | |
| ln -sf ../KernelSU drivers/kernelsu | |
| echo "✔ Created drivers/kernelsu symlink" | |
| fi | |
| # Add KSU/KSUN/WKSU configs with SUSFS | |
| CONFIG_FILE="arch/arm64/configs/${{ env.DEFCONFIG_NAME }}" | |
| echo "📝 Configuring $CONFIG_FILE" | |
| cat >> "$CONFIG_FILE" << 'EOF' | |
| CONFIG_KSU=y | |
| CONFIG_KSU_SUSFS=y | |
| CONFIG_KSU_SUSFS_HAS_MAGIC_MOUNT=y | |
| CONFIG_KSU_SUSFS_SUS_PATH=y | |
| CONFIG_KSU_SUSFS_SUS_MOUNT=y | |
| CONFIG_KSU_SUSFS_AUTO_ADD_SUS_KSU_DEFAULT_MOUNT=y | |
| CONFIG_KSU_SUSFS_AUTO_ADD_SUS_BIND_MOUNT=y | |
| CONFIG_KSU_SUSFS_SUS_KSTAT=y | |
| CONFIG_KSU_SUSFS_TRY_UMOUNT=y | |
| CONFIG_KSU_SUSFS_AUTO_ADD_TRY_UMOUNT_FOR_BIND_MOUNT=y | |
| CONFIG_KSU_SUSFS_SPOOF_UNAME=y | |
| CONFIG_KSU_SUSFS_ENABLE_LOG=y | |
| CONFIG_KSU_SUSFS_HIDE_KSU_SUSFS_SYMBOLS=y | |
| CONFIG_KSU_SUSFS_SPOOF_CMDLINE_OR_BOOTCONFIG=y | |
| CONFIG_KSU_SUSFS_OPEN_REDIRECT=y | |
| CONFIG_KSU_SUSFS_SUS_MAP=y | |
| CONFIG_KSU_SUSFS_SUS_SU=y | |
| EOF | |
| echo "🎉 NEXT with SUSFS Integration complete!" | |
| - name: "🔨 START Build Kernel" | |
| working-directory: ${{ env.WORK_DIR }} | |
| run: | | |
| if [ "${{ github.event.inputs.LTOoptimizations }}" = "thin" ]; then | |
| LTO=thin BUILD_CONFIG=${{ env.kernelDir }}/${{ env.kernelName }}/build.config.gki.aarch64 build/build.sh -j$(nproc --all) | |
| else | |
| LTO=full BUILD_CONFIG=${{ env.kernelDir }}/${{ env.kernelName }}/build.config.gki.aarch64 build/build.sh -j$(nproc --all) | |
| fi | |
| - name: "🩹 Apply KPM patch (SukiSU-Ultra only)" | |
| if: matrix.variant == 'ksu' && github.event.inputs.ksuVariant == 'sukisu+susfs' | |
| working-directory: ${{ env.WORK_DIR }}/out/dist | |
| run: | | |
| curl -LSs "https://raw.githubusercontent.com/SukiSU-Ultra/SukiSU_patch/refs/heads/main/kpm/patch_linux" -o patch | |
| chmod +x patch | |
| ./patch | |
| mv oImage Image | |
| - name: "📦 Prepare artifact" | |
| working-directory: ${{ env.WORK_DIR }} | |
| run: | | |
| VARIANT_NAME="${{ matrix.variant }}"; | |
| if [ "${{ matrix.variant }}" == "ksu" ]; then | |
| VARIANT_NAME="${{ matrix.variant }}"; | |
| fi | |
| cp out/dist/Image Image.$VARIANT_NAME | |
| echo "ARTIFACT_NAME=kernel-${VARIANT_NAME}-${{ github.event.inputs.optimizationLevel }}-${{ github.event.inputs.tickRate }}hz" >> $GITHUB_ENV | |
| echo "IMAGE_NAME=Image.$VARIANT_NAME" >> $GITHUB_ENV | |
| - name: 🔍 Check Space (Post-Build) | |
| if: always() # Run even if build fails to debug space issues | |
| run: | | |
| echo "Final disk space status:" | |
| df -h / | |
| - name: "♻️ Remove swapfile (cleanup)" | |
| if: always() | |
| run: | | |
| # Only remove if we previously created a swapfile | |
| if [ -f /swapfile ]; then | |
| echo "Disabling and removing /swapfile..." | |
| sudo swapoff /swapfile || true | |
| sudo rm -f /swapfile || true | |
| # Try to reset swappiness to default | |
| sudo sysctl -w vm.swappiness=60 || true | |
| echo "Swapfile removed." | |
| else | |
| echo "No /swapfile found - nothing to cleanup." | |
| fi | |
| - name: "📤 Upload kernel" | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ env.ARTIFACT_NAME }} | |
| path: ${{ env.WORK_DIR }}/${{ env.IMAGE_NAME }} | |
| retention-days: 3 | |
| Package-Kernels: | |
| name: "📦 Package kernels" | |
| runs-on: ubuntu-latest | |
| needs: Build-Kernel | |
| steps: | |
| - name: "📥 Download artifacts" | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: ./kernels/ | |
| - name: "📦 Create flashable ZIP" | |
| run: | | |
| BUILD_TIME=$(date +'%d-%m-%Y') | |
| git clone --depth=1 https://github.com/nebixts/AnyKernel3 -b master AnyKernel3 | |
| # Copy kernels | |
| find kernels -name "Image.*" -exec cp {} AnyKernel3/ \; | |
| # Create ZIP with optimization and KSU variant info | |
| KSU_INFO="" | |
| if [ "${{ github.event.inputs.buildKSU }}" != "noksu" ]; then | |
| KSU_INFO="_${{ github.event.inputs.ksuVariant }}" | |
| fi | |
| ZIP_NAME="nefarian_cl22b_${{ github.event.inputs.kernelBranch }}${KSU_INFO}_${{ github.event.inputs.optimizationLevel }}_${{ github.event.inputs.tickRate }}hz_${BUILD_TIME}.zip" | |
| cd AnyKernel3 | |
| zip -r9 "../$ZIP_NAME" * -x .git/* | |
| cd .. | |
| echo "ZIP_PATH=$(pwd)/$ZIP_NAME" >> $GITHUB_ENV | |
| echo "ZIP_NAME=$ZIP_NAME" >> $GITHUB_ENV | |
| - name: "📤 Upload final package" | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ env.ZIP_NAME }} | |
| path: ${{ env.ZIP_PATH }} | |
| retention-days: 7 |