Bläddra i källkod

Merge pull request #29 from WildKernels/reorganizing-workflow

Reorganizing workflow
jimsterino98 4 månader sedan
förälder
incheckning
0adb5217c9

+ 37 - 0
.github/actions/6.6-fix/action.yml

@@ -0,0 +1,37 @@
+name: Fix wifi and BT
+description: fix wifi and BT on samsung 6.6 devices
+inputs:
+ branch: 
+   description: 'device kernel'
+   required: true
+
+runs:
+ using: composite
+ steps:
+  - name: fix wifi and BT for 6.6 samsung
+    shell: bash
+    run: |
+     cd "$COMMON"
+     patch -p1 < "$KERNEL_PATCHES/samsung/${{ inputs.branch }}/kdp/add_min_kdp.patch"
+         
+     SYMBOL_LIST=android/abi_gki_aarch64_galaxy
+     echo "kdp_set_cred_non_rcu" >> $SYMBOL_LIST
+     echo "kdp_usecount_dec_and_test" >> $SYMBOL_LIST
+     echo "kdp_usecount_inc" >> $SYMBOL_LIST
+
+     if [[ "${{ inputs.branch }}" == "SM-S931B-Oneui8" ]]; then
+       echo "snd_soc_find_dai" >> $SYMBOL_LIST
+       sed -i '
+       /"kernel_aarch64": {/,/},/ {
+       s/"kmi_symbol_list_strict_mode": True/"kmi_symbol_list_strict_mode": False/
+       s/"trim_nonlisted_kmi": True/"trim_nonlisted_kmi": False/
+       }
+       /"kernel_aarch64_16k": {/,/},/ {
+       s/"kmi_symbol_list_strict_mode": True/"kmi_symbol_list_strict_mode": False/
+       s/"trim_nonlisted_kmi": True/"trim_nonlisted_kmi": False/
+       }
+       ' BUILD.bazel
+     fi
+
+     cp "$KERNEL_PATCHES/samsung/min_kdp/min_kdp.c" drivers/min_kdp.c
+     echo "obj-y += min_kdp.o" >> drivers/Makefile

+ 13 - 0
.github/actions/abi-export/action.yml

@@ -0,0 +1,13 @@
+name: abi export removal
+description: remove abi exports for wifi and bt functionality
+
+runs:
+ using: composite
+ steps:
+  - name: remove protected exports
+    shell: bash
+    run: |
+     cd "$COMMON"
+     
+     rm -rf ./android/abi_gki_protected_exports_*
+     perl -pi -e 's/^\s*"protected_exports_list"\s*:\s*"android\/abi_gki_protected_exports_aarch64",\s*$//;' ./BUILD.bazel

+ 41 - 0
.github/actions/ak3zip-prep/action.yml

@@ -0,0 +1,41 @@
+name: prepare ak3
+description: copy kernel image to ak3 folder
+inputs:
+ branch:
+  description: 'device kernel/repo'
+  required: true
+
+runs:
+ using: composite
+ steps:
+  - name: copy image to ak3 folder depending on branch
+    shell: bash
+    run: |
+     cd "$CONFIG"
+
+     if [[ "${{ inputs.branch }}" == "SM-S928B-Oneui7" || "${{ inputs.branch }}" == "SM-S928B-Oneui8-bit4" || "${{ inputs.branch }}" == "SM-S928B-Oneui8-bit5" || "${{ inputs.branch }}" == "SM-F741B-Oneui8" ]]; then
+       cp ./kernel_platform/sec/dist/Image "$ANYKERNEL3/Image"
+     elif [[ "${{ inputs.branch }}" == "SM-S928B-Oneui6.1" ]]; then
+       cp ./out/msm-pineapple-pineapple-gki/dist/Image "$ANYKERNEL3/Image"
+     elif [[ "${{ inputs.branch }}" == "SM-S938B-Oneui7" || "${{ inputs.branch }}" == "SM-S931B-Oneui8" || "${{ inputs.branch }}" == "SM-M556B-Oneui8" ]]; then
+       cp ./kernel_platform/gki/dist/Image "$ANYKERNEL3/Image"
+     elif [[ -f ./$CONFIG/bazel-bin/common/kernel_aarch64/Image ]]; then
+       cp ./$CONFIG/bazel-bin/common/kernel_aarch64/Image "$ANYKERNEL3/Image"
+     elif [[ "${{ inputs.branch }}" == "SM-X916B" || "${{ inputs.branch }}" == "SM-F946N-Oneui7" || "${{ inputs.branch }}" == "SM-F946B-Oneui8" || "${{ inputs.branch }}" == "SM-S916B-Oneui8" || "${{ inputs.branch }}" == "SM-S918B-Oneui8" || "${{ inputs.branch }}" == "SM-S911B-Oneui8-bit8" ]]; then
+       cp ./out/msm-kalama-kalama-gki/dist/Image "$ANYKERNEL3/Image"
+     elif [[ ${{ inputs.branch }} == SM-A546* || "${{ inputs.branch }}" == "SM-M146B-Oneui7-ADYJ2" || "${{ inputs.branch }}" == "SM-S908B-Oneui8-bitK" ]]; then
+       cp ./arch/arm64/boot/Image "$ANYKERNEL3/Image"
+     elif [[ "${{ inputs.branch }}" == "SM-A566B" ]]; then
+       cp ./kernel-6.6/out/arch/arm64/boot/Image "$ANYKERNEL3/Image"
+     elif [[ "${{ inputs.branch }}" == "SM-S926B-Oneui8" ]]; then
+       cp ./out/s5e9945_user/dist/Image "$ANYKERNEL3/Image"
+     elif [[ ${{ inputs.branch }} == SM-A556* ]]; then
+       cp ./out/s5e8845_user/dist/Image "$ANYKERNEL3/Image"
+     elif [[ "${{ inputs.branch }}" == "SM-S901E-Oneui8" || "${{ inputs.branch }}" == "SM-X800-Oneui8" ]]; then
+       cp ./out/msm-waipio-waipio-gki/dist/Image "$ANYKERNEL3/Image"
+     elif [[ ${{ inputs.branch }} == SM-A055* ]]; then
+       cp ./out/target/product/a05m/obj/KLEAF_OBJ/dist/kernel_device_modules-6.6/mgk_64_k66_kernel_aarch64.user/Image.gz "$ANYKERNEL3/Image.gz"
+     else
+       echo "Error: Image file not found in any expected location"
+       exit 1
+     fi

+ 32 - 0
.github/actions/bbg/action.yml

@@ -0,0 +1,32 @@
+name: Add bbg
+description: add and enable bbg into the kernel
+
+runs:
+  using: composite
+  steps:
+   - name: add bbg into kernel
+     shell: bash
+     run: |
+      cd "$COMMON"
+      echo "Adding BBG..."
+      curl -LSs https://github.com/vc-teahouse/Baseband-guard/raw/main/setup.sh | bash
+      
+   - name: enable bbg in defconfig
+     shell: bash
+     run: |
+      cd "$GITHUB_WORKSPACE"
+      cat >> "$GKI_DEFCONFIG" << 'EOF'
+      CONFIG_BBG=y
+      EOF
+
+   - name: add bbg into kconfig
+     shell: bash
+     run: |
+       cd "$COMMON"
+       sed -i '/^config LSM$/,/^help$/{ /^[[:space:]]*default/ { /baseband_guard/! s/selinux/selinux,baseband_guard/ } }' security/Kconfig
+
+   - name: if config_lsm is in defconfig, add bbg
+     shell: bash
+     run: |
+      cd "$GITHUB_WORKSPACE"
+      sed -i '/^CONFIG_LSM=/ s/"$/,baseband_guard"/' "$GKI_DEFCONFIG"

+ 43 - 0
.github/actions/build/action.yml

@@ -0,0 +1,43 @@
+name: build kernel
+description: each samsung kernel has its own way of building the kernel, they are sorted here.
+inputs:
+ branch:
+  description: 'device kernel'
+  required: true
+
+runs:
+ using: composite
+ steps:
+  - name: start kernel build
+    shell: bash
+    run: |
+     set -e
+     set -x
+     cd "$CONFIG"
+     echo "Building the kernel..."
+     if [[ ${{ inputs.branch }} == SM-S928B* || "${{ inputs.branch }}" == "SM-S938B-Oneui7" || "${{ inputs.branch }}" == "SM-S931B-Oneui8" || "${{ inputs.branch }}" == "SM-F741B-Oneui8" ]]; then
+       chmod +x build_kernel_GKI.sh
+       ./build_kernel_GKI.sh || true
+     elif [[ "${{ inputs.branch }}" == "SM-X916B" || "${{ inputs.branch }}" == "SM-F946N-Oneui7" || "${{ inputs.branch }}" == "SM-S916B-Oneui8" || "${{ inputs.branch }}" == "SM-S918B-Oneui8" || "${{ inputs.branch }}" == "SM-F946B-Oneui8" || "${{ inputs.branch }}" == "SM-S901E-Oneui8" || "${{ inputs.branch }}" == "SM-X800-Oneui8" || "${{ inputs.branch }}" == "SM-S911B-Oneui8-bit8" || "${{ inputs.branch }}" == "SM-M556B-Oneui8" ]]; then
+       chmod +x build_kernel_GKI.sh
+       #LTO=thin ./build_kernel_GKI.sh || true
+       ./build_kernel_GKI.sh || true
+     elif [[ ${{ inputs.branch }} == SM-A546* || "${{ inputs.branch }}" == "SM-M146B-Oneui7-ADYJ2" || "${{ inputs.branch }}" == "SM-S908B-Oneui8-bitK" ]]; then
+       sudo apt update
+       sudo apt-get install -y libyaml-dev
+       chmod +x build_kernel.sh
+       #LTO=thin ./build_kernel.sh || true
+       ./build_kernel.sh || true
+     elif [[ "${{ inputs.branch }}" == "SM-A566B" ]]; then
+       chmod +x build_script.sh
+       touch ./kernel-6.6/abi_symbollist.raw
+       touch ./kernel-6.6/abi_symbollist
+       ./build_script.sh || true
+     elif [[ "${{ inputs.branch }}" == "SM-S926B-Oneui8" ]]; then
+       tools/bazel run --nocheck_bzl_visibility --config=stamp --sandbox_debug --verbose_failures --debug_make_verbosity=I //projects/s5e9945:s5e9945_user_dist
+     elif [[ ${{ inputs.branch }} == SM-A556* ]]; then
+       tools/bazel run --nocheck_bzl_visibility --config=stamp --sandbox_debug --verbose_failures --debug_make_verbosity=I //projects/s5e8845:s5e8845_user_dist
+     elif [[ ${{ inputs.branch }} == SM-A055* ]]; then
+       chmod +x build_kernel.sh
+       ./build_kernel.sh
+     fi

+ 15 - 0
.github/actions/clone-kernel/action.yml

@@ -0,0 +1,15 @@
+name: 'Download Samsung Kernels'
+description: "initialize and download the samsung kernel"
+
+inputs:
+  branch:
+    description: 'Device Kernel branch'
+    required: true
+
+runs:
+ using: composite
+ steps:
+   - name: Clone Kernel Source
+     shell: bash
+     run: |
+      git clone --depth 1 -b ${{ inputs.branch }} --single-branch https://github.com/WildKernels/Samsung_Kernels.git $CONFIG

+ 90 - 0
.github/actions/configs/action.yml

@@ -0,0 +1,90 @@
+name: add configs
+description: add configs and disabling securities
+inputs:
+ branch:
+   description: 'which device kernel'
+   required: true
+
+runs:
+ using: composite
+ steps:
+  - name: add mountify support
+    shell: bash
+    run: |
+     cat >> "$GKI_DEFCONFIG" << 'EOF'
+     # Mountify Support
+     CONFIG_OVERLAY_FS=y
+     CONFIG_TMPFS_XATTR=y
+     CONFIG_TMPFS_POSIX_ACL=y
+
+  - name: increase log buffer size for showing bbg on ksu manager homepage
+    shell: bash
+    run: |
+     cat >> "$GKI_DEFCONFIG" << 'EOF'
+     # increase log buffer size to show bbg version in wksu homepage
+     CONFIG_LOG_BUF_SHIFT=20
+     EOF
+
+  - name: nuke securities for root access
+    shell: bash
+    run: |
+     if [[ "${{ inputs.branch }}" == "SM-S938B-Oneui7" || "${{ inputs.branch }}" == "SM-S931B-Oneui8" ]]; then
+     echo "nothing to see here moving on"
+          
+     elif [[ "${{ inputs.branch }}" == "SM-S926B-Oneui8" ]]; then
+     cat >> "$COMMON/arch/arm64/configs/s5e9945-bazel_defconfig" << 'EOF'
+     # nuke root protection
+     CONFIG_UH=n
+     CONFIG_UH_RKP=n
+     CONFIG_UH_LKMAUTH=n
+     CONFIG_UH_LKM_BLOCK=n
+     CONFIG_RKP_CFP_JOPP=n
+     CONFIG_RKP_CFP=n
+     CONFIG_SECURITY_DEFEX=n
+     CONFIG_PROCA=n
+     CONFIG_FIVE=n
+     CONFIG_RKP=n
+     CONFIG_KDP_NS=n
+     CONFIG_KDP=n
+     EOF
+
+     elif [[ ${{ inputs.branch }} == SM-A556* ]]; then
+     cat >> "$COMMON/arch/arm64/configs/s5e8845-bazel_defconfig" << 'EOF'
+     # nuke root protection
+     CONFIG_UH=n
+     CONFIG_UH_RKP=n
+     CONFIG_UH_LKMAUTH=n
+     CONFIG_UH_LKM_BLOCK=n
+     CONFIG_RKP_CFP_JOPP=n
+     CONFIG_RKP_CFP=n
+     CONFIG_SECURITY_DEFEX=n
+     CONFIG_PROCA=n
+     CONFIG_FIVE=n
+     CONFIG_RKP=n
+     CONFIG_KDP_NS=n
+     CONFIG_KDP=n
+     EOF
+
+     else
+     cat >> "$GKI_DEFCONFIG" << 'EOF'
+     # nuke root protection
+     CONFIG_UH=n
+     CONFIG_UH_RKP=n
+     CONFIG_UH_LKMAUTH=n
+     CONFIG_UH_LKM_BLOCK=n
+     CONFIG_RKP_CFP_JOPP=n
+     CONFIG_RKP_CFP=n
+     CONFIG_SECURITY_DEFEX=n
+     CONFIG_PROCA=n
+     CONFIG_FIVE=n
+     CONFIG_RKP=n  
+     CONFIG_KDP_NS=n
+     CONFIG_KDP=n
+     EOF
+     fi
+  - name: remove check_defconfig
+    shell: bash
+    run: |
+     cd "$COMMON"
+     # Remove check_defconfig
+     sed -i 's/check_defconfig//' ./build.config.gki

+ 45 - 0
.github/actions/dependencies/action.yml

@@ -0,0 +1,45 @@
+name: clone dependencies
+description: dependencies
+inputs:
+ android_version:
+    description: 'Android version (e.g., android15)'
+    required: true
+ kernel_version:
+    description: 'Kernel version (e.g., 6.6)'
+    required: true
+ zeromount:
+    description: 'zeromount'
+    required: true
+ susfs:
+    description: 'SUSFS'
+    required: true
+
+runs:
+ using: composite
+ steps:
+  - name: clone susfs and change commit if necessary, and clone kernel patches
+    shell: bash
+    run: |
+     ANYKERNEL_BRANCH="gki-2.0"
+     git clone https://github.com/WildKernels/kernel_patches.git
+     git clone https://github.com/WildKernels/AnyKernel3.git -b "$ANYKERNEL_BRANCH"
+     if [[ ${{ inputs.zeromount }} == 'true' ]]; then
+      git clone https://github.com/jimsterino98/Super-Builders.git
+     fi
+
+     if [[ ${{ inputs.susfs }} == 'true' ]]; then
+      SUSFS_BRANCH="gki-${{ inputs.android_version }}-${{ inputs.kernel_version }}"
+      git clone https://gitlab.com/simonpunk/susfs4ksu.git -b "$SUSFS_BRANCH"
+     
+      cd susfs4ksu
+      if [[ "${{ inputs.android_version }}-${{ inputs.kernel_version }}" == "android12-5.10" ]]; then
+        COMMIT=674f72b6f683e837d7f557704cabe00a83eeb0b4
+      elif [[ "${{ inputs.android_version }}-${{ inputs.kernel_version }}" == "android13-5.15" ]]; then
+        COMMIT=eaa5d299dd85a4230f936b94dc5dd8303f27130a
+      elif [[ "${{ inputs.android_version }}-${{ inputs.kernel_version }}" == "android14-6.1" ]]; then
+        COMMIT=971cc4e770b7f344a4df35ce92d7a859e6a1e0fd
+      elif [[ "${{ inputs.android_version }}-${{ inputs.kernel_version }}" == "android15-6.6" ]]; then
+        COMMIT=85bcfac5edc8ba7808581e8d0a3ca9c7deca78e4
+      fi
+      git checkout "$COMMIT"
+     fi

+ 42 - 0
.github/actions/droidspaces/action.yml

@@ -0,0 +1,42 @@
+name: add droidspaces
+description: apply patches and configs for droidspaces support
+
+runs:
+ using: composite
+ steps:
+  - name: apply patch and add configs
+    shell: bash
+    run: |
+     cd "$COMMON"
+     # ABI: use ABI padding for SYSVIPC This commit allows us to enable CONFIG_SYSVIPC in defconfig without breaking kernel ABI
+     patch -p1 --forward < "$KERNEL_PATCHES/common/droidspaces/fix_sysvipc_kabi_6_7_8.patch"
+
+     cd "$GITHUB_WORKSPACE"
+     cat >> "$GKI_DEFCONFIG" << 'EOF'
+     # IPC
+     CONFIG_SYSVIPC=y
+     CONFIG_POSIX_MQUEUE=y
+
+     # Namespaces
+     CONFIG_IPC_NC=y
+     CONFIG_PID_NS=y
+
+     # HW Access Support
+     CONFIG_DEVTMPFS=y
+
+     # Below configs are optional
+
+     # Docker NAT
+     CONFIG_NETFILTER_XT_MATCH_ADDRTYPE=y
+
+     # UFW
+     CONFIG_NETFILTER_XT_TARGET_REJECT=y
+     CONFIG_NETFILTER_XT_TARGET_LOG=y
+     CONFIG_NETFILTER_XT_MATCH_RECENT
+
+     # Fail2Ban
+     CONFIG_IP_SET=y
+     CONFIG_IP_SET_HASH_IP=y
+     CONFIG_IP_SET_HASH_NET=y
+     CONFIG_NETFILTER_XT_SET=y
+     EOF

+ 64 - 0
.github/actions/env-variables/action.yml

@@ -0,0 +1,64 @@
+name: set variables
+description: set environment variables
+inputs:
+ susfs:
+  description: 'susfs'
+  required: true
+ branch:
+  description: 'device kernel'
+  required: true
+ zeromount:
+  description: 'zeromount'
+  required: true
+
+runs:
+ using: composite
+ steps:
+  - name: set dependency directory variables
+    shell: bash
+    run: |
+     ROOT="$GITHUB_WORKSPACE"
+     if [[ ${{ inputs.susfs }} == 'true' ]]; then
+      SUSFS4KSU="$ROOT/susfs4ksu"
+      KERNEL_PATCHES="$ROOT/kernel_patches"
+      echo "SUSFS4KSU=$SUSFS4KSU" >> $GITHUB_ENV
+      echo "KERNEL_PATCHES=$KERNEL_PATCHES" >> $GITHUB_ENV
+     fi
+     ANYKERNEL3="$ROOT/AnyKernel3"
+     if [[ ${{ inputs.zeromount }} == 'true' ]]; then
+      ZEROMOUNT="$ROOT/Super-Builders"
+      echo "ZEROMOUNT=$ZEROMOUNT" >> $GITHUB_ENV
+     fi
+
+     echo "ROOT=$ROOT" >> $GITHUB_ENV
+     echo "ANYKERNEL3=$ANYKERNEL3" >> $GITHUB_ENV
+     
+  - name: set common variable
+    shell: bash
+    run: |
+     if [[ ${{ inputs.branch }} == SM-A546* || "${{ inputs.branch }}" == "SM-M146B-Oneui7-ADYJ2" || "${{ inputs.branch }}" == "SM-S908B-Oneui8-bitK" ]]; then  
+       COMMON="$CONFIG"
+     elif [[ "${{ inputs.branch }}" == "SM-A566B" || ${{ inputs.branch }} == SM-A055* ]]; then
+       COMMON="$CONFIG/kernel-6.6"
+     elif [[ "${{ inputs.branch }}" == "SM-S926B-Oneui8" || ${{ inputs.branch }} == SM-A556* ]]; then
+       COMMON="$CONFIG/kernel"
+     else
+       COMMON="$CONFIG/kernel_platform/common"
+     fi
+     echo "COMMON=$COMMON" >> $GITHUB_ENV
+    
+  - name: set defconfig variable
+    shell: bash
+    run: |
+     if [[ "${{ inputs.branch }}" == "SM-A546B-Oneui7" || "${{ inputs.branch }}" == "SM-A546B-Oneui8" ]]; then
+       GKI_DEFCONFIG="$COMMON/arch/arm64/configs/s5e8835-a54xnaxx_defconfig"
+     elif [[ "${{ inputs.branch }}" == "SM-A546E-Oneui7" || "${{ inputs.branch }}" == "SM-A546E-Oneui8" ]]; then
+       GKI_DEFCONFIG="$COMMON/arch/arm64/configs/s5e8835-a54xnsxx_defconfig"
+     elif [[ "${{ inputs.branch }}" == "SM-M146B-Oneui7-ADYJ2" ]]; then
+       GKI_DEFCONFIG="$COMMON/arch/arm64/configs/s5e8535-m14xnsxx_defconfig"
+     elif [[ "${{ inputs.branch }}" == "SM-S908B-Oneui8-bitK" ]]; then
+       GKI_DEFCONFIG="$COMMON/arch/arm64/configs/s5e9925-b0sxxx_defconfig"
+     else
+       GKI_DEFCONFIG="$COMMON/arch/arm64/configs/gki_defconfig"
+     fi
+     echo "GKI_DEFCONFIG=$GKI_DEFCONFIG" >> $GITHUB_ENV

+ 28 - 0
.github/actions/file-name/action.yml

@@ -0,0 +1,28 @@
+name: set file name for ak3zip
+description: set file name for ak3 zip
+inputs:
+ branch:
+  description: 'Device kernel'
+  required: true
+ android_version:
+  description: 'Android version (android14)'
+  required: true
+ kernel_version:
+  description: 'Kernel version (6.1)'
+  required: true
+
+runs:
+ using: composite
+ steps:
+  - name: set file name for ak3zip
+    shell: bash
+    run: |
+     ARTIFACT_BASE="${{ inputs.branch }}-${{ inputs.kernel_version }}-${{ inputs.android_version }}"
+          
+     # This gives: KSUxxxxx-branch-xxx-xxx
+     FILE_NAME="KSUN${KSU_VERSION}-${ARTIFACT_BASE}"
+      
+     echo "ARTIFACT_BASE=$ARTIFACT_BASE" >> $GITHUB_ENV
+     echo "FILE_NAME=$FILE_NAME" >> $GITHUB_ENV
+          
+     echo "✅ Final artifact name: $FILE_NAME"

+ 18 - 0
.github/actions/kernel-name/action.yml

@@ -0,0 +1,18 @@
+name: set kernel name
+description: add wild and remove dirty from kernel name
+
+runs:
+ using: composite
+ steps:
+  - name: add wild to kernel name
+    shell: bash
+    run: |
+     cd "$COMMON"
+
+     sed -i '$s|echo "\$res"|echo "\$res-Wild"|' ./scripts/setlocalversion
+
+  - name: remove dirty flag
+    shell: bash
+    run: |
+     
+     sed -i 's/-dirty//' "./$COMMON/scripts/setlocalversion"

+ 45 - 0
.github/actions/ksun/action.yml

@@ -0,0 +1,45 @@
+name: Set up KernelSU-Next
+description: download and set up KSUN into the kernel source
+
+
+runs:
+  using: composite
+  steps:
+    - name: Setup KSUN
+      shell: bash
+      run: |
+        cd "$COMMON"
+        curl -LSs "https://raw.githubusercontent.com/KernelSU-Next/KernelSU-Next/next/kernel/setup.sh" | bash -s dev
+
+        cd KernelSU-Next
+        git checkout 551ad80473f60e052917aec08abf5323b6ab2f7c
+
+        cd kernel
+        COMMITS_COUNT=$(/usr/bin/git rev-list --count HEAD)
+        BASE_VERSION=30000
+        KSU_VERSION=$(expr $COMMITS_COUNT "+" $BASE_VERSION)
+        sed -i "s/^KSU_VERSION_FALLBACK := 1$/KSU_VERSION_FALLBACK := ${KSU_VERSION}/" Kbuild
+
+        KSU_GIT_TAG="$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.1")"
+        sed -i "s/^KSU_VERSION_TAG_FALLBACK := v0.0.1$/KSU_VERSION_TAG_FALLBACK := ${KSU_GIT_TAG}/" Kbuild
+
+        cd "$GITHUB_WORKSPACE"
+        cat >> "$GKI_DEFCONFIG" << 'EOF'
+        # KernelSU Configuration
+        CONFIG_KSU=y
+        EOF
+
+    - name: Extract KSU Version Info
+      id: ksu-version
+      shell: bash
+      run: |
+        cd "$COMMON/KernelSU-Next"
+        # Extract and export KSU version info
+        KSU_GIT_VERSION=$(git rev-list --count HEAD 2>/dev/null)
+        KSU_GIT_TAG=$(git describe --tags --abbrev=0 2>/dev/null)
+        KSU_COMMIT=$(git rev-parse --short HEAD 2>/dev/null)
+        KSU_VERSION=$((30000 + KSU_GIT_VERSION))
+        
+        echo "KSU_GIT_TAG=$KSU_GIT_TAG" >> $GITHUB_ENV
+        echo "KSU_VERSION=$KSU_VERSION" >> $GITHUB_ENV
+        echo "KSU_COMMIT=$KSU_COMMIT" >> $GITHUB_ENV

+ 28 - 0
.github/actions/m55-fix/action.yml

@@ -0,0 +1,28 @@
+name: m55 fix
+description: disable CRC to allow booting
+
+runs:
+ using: composite
+ steps:
+  - name: disable CRC checks
+    shell: bash
+    run: |
+     cd "$COMMON"
+     curl -L -s https://raw.githubusercontent.com/jimsterino98/Android-Kernel-Tutorials/refs/heads/main/patches/010.Disable-CRC-Checks.patch | patch -p1 --forward
+
+     cd "$GITHUB_WORKSPACE"
+     cat >> "$GKI_DEFCONFIG" << 'EOF'
+     #Force Load Kernel Modules
+     CONFIG_MODULES=y
+     CONFIG_MODULE_FORCE_LOAD=y
+     CONFIG_MODULE_UNLOAD=y
+     CONFIG_MODULE_FORCE_UNLOAD=y
+     CONFIG_MODVERSIONS=y
+     CONFIG_MODULE_SRCVERSION_ALL=n
+     CONFIG_MODULE_SIG=n
+     CONFIG_MODULE_COMPRESS=n
+     CONFIG_TRIM_UNUSED_KSYMS=n
+     
+     #Add btrfs user request
+     CONFIG_BTRFS_FS=y
+     EOF

+ 26 - 0
.github/actions/ntsync/action.yml

@@ -0,0 +1,26 @@
+name: add ntsync
+description: integrate ntsync into kernel
+inputs:
+  android_version:
+    description: 'Android version (android14)'
+    required: true
+  kernel_version:
+    description: 'Kernel version (6.1)'
+    required: true
+
+runs:
+  using: composite
+  steps:
+   - name: apply ntsync patches
+     shell: bash
+     run: |
+      cd "$COMMON"
+      patch -p1 < "$KERNEL_PATCHES/common/ntsync/ntsync_base.patch"
+      patch -p1 < "$KERNEL_PATCHES/common/ntsync/ntsync_compat_${{ inputs.android_version }}-${{ inputs.kernel_version }}.patch"
+      
+   - name: enable ntsync config
+     shell: bash
+     run: |
+      cat >> "$GKI_DEFCONFIG" << 'EOF'
+      CONFIG_NTSYNC=y
+      EOF

+ 83 - 0
.github/actions/susfs-patches/action.yml

@@ -0,0 +1,83 @@
+name: apply susfs patches
+description: apply susfs patches
+inputs:
+  android_version:
+   description: 'Android version (android14)'
+   required: true
+  kernel_version:
+   description: 'Kernel version (6.1)'
+   required: true
+  branch:
+   description: 'device kernel'
+   required: true
+
+runs:
+  using: composite
+  steps:
+   - name: Apply to KSUN
+     shell: bash
+     run: |
+       cd "$COMMON/KernelSU-Next"
+       SUSFS_VERSION="v2.1.0"
+          
+       # Apply SUSFS to KernelSU-Next
+       cp "$SUSFS4KSU/kernel_patches/KernelSU/10_enable_susfs_for_ksu.patch" .
+       patch -p1 < 10_enable_susfs_for_ksu.patch || true
+       rm -rf 10_enable_susfs_for_ksu.patch
+
+       #Fix rejects from adding susfs to KSUN
+       cp "$KERNEL_PATCHES/next/susfs_fix_patches/$SUSFS_VERSION/"*.patch .
+       rm -rf multi_manager.patch
+       rm -rf multi_sepolicy_fix.patch
+       for p in *.patch; do
+           patch -p1 < "$p"
+           rm -f "$p"
+       done
+       
+   - name: Apply to Kernel
+     shell: bash
+     run: |
+      # Apply SUSFS to kernel
+      cd "$COMMON"
+      cp "$SUSFS4KSU/kernel_patches/fs/"* ./fs/
+      cp "$SUSFS4KSU/kernel_patches/include/linux/"* ./include/linux/
+      cp "$SUSFS4KSU/kernel_patches/50_add_susfs_in_gki-${{ inputs.android_version }}-${{ inputs.kernel_version }}.patch" ./          
+
+      #Prepare open.c for susfs patching
+      sed -i '/#ifdef CONFIG_SECURITY_DEFEX/,/^#endif/d' fs/open.c
+
+      #Prepare namespace.c for susfs patching
+      sed -i '/copy_flags = CL_COPY_UNBINDABLE | CL_EXPIRE;/,/#endif/ {
+        /#ifdef CONFIG_KDP_NS/,/#endif/ {
+           /#else/,/#endif/!d
+           /#else/d
+           /#endif/d
+        }
+       }' fs/namespace.c
+          
+      # Apply SUSFS core patch
+      patch -p1 < 50_add_susfs_in_gki-${{ inputs.android_version }}-${{ inputs.kernel_version }}.patch || true
+      rm -rf 50_add_susfs_in_gki-${{ inputs.android_version }}-${{ inputs.kernel_version }}.patch
+
+      shopt -s nullglob
+      patches=("$KERNEL_PATCHES/samsung/${{ inputs.branch }}"/*.patch)
+      
+      if [ ${#patches[@]} -gt 0 ]; then
+       echo "Patches found, applying..."
+       cp "${patches[@]}" ./
+       
+       # Fix SUSFS rejects
+        for p in *.patch; do
+          patch -p1 < "$p"
+          rm -f "$p"
+        done
+        shopt -u nullglob
+      else
+        echo "No patch file found, skipping"
+      fi
+          
+      cd "$GITHUB_WORKSPACE"
+      cat >> "$GKI_DEFCONFIG" << 'EOF'
+      # SUSFS Configuration
+      CONFIG_KSU_SUSFS=y
+      EOF

+ 23 - 0
.github/actions/unicode/action.yml

@@ -0,0 +1,23 @@
+name: unicode fix
+description: idk just got it from Fatal
+inputs:
+  kernel_version:
+   description: 'Kernel version (6.1)'
+   required: true
+
+runs:
+ using: composite
+ steps:
+  - name: apply unicode fix for specific kernel version
+    shell: bash
+    run: |
+     cd "$COMMON"
+     echo "detected kernel version: ${{ inputs.kernel_version }}"
+
+     if [[ ${{ inputs.kernel_version }} == 6.* ]]; then
+      cp "$KERNEL_PATCHES/common/unicode_bypass_fix_6.1+.patch" .
+      patch -p1 < unicode_bypass_fix_6.1+.patch
+     else
+      cp "$KERNEL_PATCHES/common/unicode_bypass_fix_6.1-.patch" .
+      patch -p1 < unicode_bypass_fix_6.1-.patch
+     fi

+ 55 - 0
.github/actions/zeromount/action.yml

@@ -0,0 +1,55 @@
+name: Add zeromount
+description: add zeromount to kernel
+inputs:
+  android_version:
+   description: 'Android version (android14)'
+   required: true
+  kernel_version:
+   description: 'kernel version (6.1)'
+   required: true
+
+runs:
+ using: composite
+ steps:
+  - name: apply zeromount patches
+    shell: bash
+    run: |
+     echo "adding zeromount..."
+            
+      cd "$COMMON"
+      cp "$ZEROMOUNT/${{ inputs.android_version }}-${{ inputs.kernel_version }}/WildKSU/patches/60_zeromount-${{ inputs.android_version }}-${{ inputs.kernel_version }}.patch" .
+      #patch -p1 < 51_enhanced_susfs_gki-${{ inputs.android_version }}-${{ inputs.kernel_version }}.patch || true
+      patch -p1 < 60_zeromount-${{ inputs.android_version }}-${{ inputs.kernel_version }}.patch || true
+      rm -rf 60_zeromount-${{ inputs.android_version }}-${{ inputs.kernel_version }}.patch
+
+      if [ -f fs/proc/task_mmu.c.rej ]; then
+        echo "Fixing task_mmu.c..."
+
+        sed -i '/pgoff = ((loff_t)vma->vm_pgoff) << PAGE_SHIFT;/a\
+        #ifdef CONFIG_ZEROMOUNT\
+        \tzeromount_spoof_mmap_metadata(inode, \&dev, \&ino);\
+        #endif' fs/proc/task_mmu.c
+      fi
+
+      if [ -f fs/stat.c.rej ]; then
+       echo "fixing stat.c."
+
+        if ! grep -q 'zeromount_stat_hook(dfd, filename, stat, request_mask, flags)' fs/stat.c; then
+          perl -0pi -e 's@(static int vfs_statx\(.*?\)\s*\{.*?orig_flow:\n#endif\n)@$1\n#ifdef CONFIG_ZEROMOUNT\n\tif (filename) {\n\t\tint zm_ret = zeromount_stat_hook(dfd, filename, stat, request_mask, flags);\n\t\tif (zm_ret != -ENOENT)\n\t\t\treturn zm_ret;\n\t}\n#endif\n\n@s' fs/stat.c
+        fi
+      fi
+
+      if [ -f fs/Kconfig.rej ]; then
+        echo "Applying Kconfig zeromount fix..."
+
+        if ! grep -q '^config ZEROMOUNT$' fs/Kconfig; then
+            perl -0pi -e 's@(config IO_WQ\n\tbool\n)@\1\nconfig ZEROMOUNT\n\tbool "ZeroMount Path Redirection Subsystem"\n\tdefault y\n\thelp\n\t  ZeroMount allows path redirection and virtual file injection\n\t  without mounting filesystems. Useful for systemless modifications.\n\n@' fs/Kconfig
+        fi
+      fi
+      #patch -p1 < 70_ksu_safety-wksu-${{ inputs.kernel_version }}.patch || true
+
+      cd "$GITHUB_WORKSPACE"
+      cat >> "$GKI_DEFCONFIG" << 'EOF'
+      # Zeromount Configuration
+      CONFIG_ZEROMOUNT=y
+      EOF

+ 72 - 536
.github/workflows/build.yml

@@ -36,9 +36,6 @@ on:
       ntsync:
         required: true
         type: string
-      optimizations:
-        required: true
-        type: string
 
 jobs:
   build-samsung-gki:
@@ -48,6 +45,9 @@ jobs:
       fail-fast: false
 
     steps:
+      - name: Checkout Repository
+        uses: actions/checkout@v5
+       
       - name: Free Disk Space
         if: true
         uses: endersonmenezes/free-disk-space@v3  # Use @main for latest, @v3 for stable
@@ -63,8 +63,13 @@ jobs:
           rm_cmd: "rmz"  # Use 'rmz' for faster deletion (default: 'rm')
           rmz_version: "3.1.1"  # Required when rm_cmd is 'rmz'
           testing: false
-      
-          
+
+      - name: Setup more Swap (for LTO)
+        uses: thejerrybao/setup-swap-space@v1   # or pierotofy/set-swap-space
+        with:
+          swap-size-gb: 25          # 10-24 GB is common for heavy LTO
+        # swap-space-path: /mnt/swapfile   # optional
+        
       - name: Set CONFIG Environment Variable
         run: |
           # Set CONFIG dynamically based on inputs values
@@ -73,68 +78,25 @@ jobs:
           # Set CONFIG as an environment variable for future steps
           echo "CONFIG=$CONFIG" >> $GITHUB_ENV
 
-      - name: Clone AnyKernel3 and Other Dependencies
-        run: |
-          ANYKERNEL_BRANCH="gki-2.0"
-          SUSFS_BRANCH="gki-${{ inputs.android_version }}-${{ inputs.kernel_version }}"
+      - name: dependencies
+        uses: ./.github/actions/dependencies
+        with:
+          zeromount: ${{ inputs.zeromount }}
+          susfs: ${{ inputs.susfs }}
+          android_version: ${{ inputs.android_version }}
+          kernel_version: ${{ inputs.kernel_version }}
           
-          git clone https://github.com/WildKernels/AnyKernel3.git -b "$ANYKERNEL_BRANCH"
-          git clone https://github.com/WildKernels/kernel_patches.git
-          git clone https://gitlab.com/simonpunk/susfs4ksu.git -b "$SUSFS_BRANCH"
-          git clone https://github.com/jimsterino98/Super-Builders.git
-
-          cd susfs4ksu
-          if [[ "${{ inputs.android_version }}-${{ inputs.kernel_version }}" == "android12-5.10" ]]; then
-            COMMIT=674f72b6f683e837d7f557704cabe00a83eeb0b4
-          elif [[ "${{ inputs.android_version }}-${{ inputs.kernel_version }}" == "android13-5.15" ]]; then
-            COMMIT=eaa5d299dd85a4230f936b94dc5dd8303f27130a
-          elif [[ "${{ inputs.android_version }}-${{ inputs.kernel_version }}" == "android14-6.1" ]]; then
-            COMMIT=971cc4e770b7f344a4df35ce92d7a859e6a1e0fd
-          elif [[ "${{ inputs.android_version }}-${{ inputs.kernel_version }}" == "android15-6.6" ]]; then
-            COMMIT=85bcfac5edc8ba7808581e8d0a3ca9c7deca78e4
-          fi
-          git checkout "$COMMIT"
-      
-      - name: Clone Kernel Source
-        run: |
-            git clone --depth 1 -b ${{ inputs.branch }} --single-branch https://github.com/WildKernels/Samsung_Kernels.git $CONFIG
+      - name: Download Kernel
+        uses: ./.github/actions/clone-kernel
+        with:
+          branch: ${{ inputs.branch }}
             
       - name: Set Path Environment Variables
-        run: |
-          ROOT="$GITHUB_WORKSPACE"
-          SUSFS4KSU="$ROOT/susfs4ksu"
-          KERNEL_PATCHES="$ROOT/kernel_patches"
-          ANYKERNEL3="$ROOT/AnyKernel3"
-          ZEROMOUNT="$ROOT/Super-Builders"
-          if [[ ${{ inputs.branch }} == SM-A546* || "${{ inputs.branch }}" == "SM-M146B-Oneui7-ADYJ2" || "${{ inputs.branch }}" == "SM-S908B-Oneui8-bitK" ]]; then  
-            COMMON="$CONFIG"
-          elif [[ "${{ inputs.branch }}" == "SM-A566B" || ${{ inputs.branch }} == SM-A055* ]]; then
-            COMMON="$CONFIG/kernel-6.6"
-          elif [[ "${{ inputs.branch }}" == "SM-S926B-Oneui8" || ${{ inputs.branch }} == SM-A556* ]]; then
-            COMMON="$CONFIG/kernel"
-          else
-            COMMON="$CONFIG/kernel_platform/common"
-          fi
-
-          if [[ "${{ inputs.branch }}" == "SM-A546B-Oneui7" || "${{ inputs.branch }}" == "SM-A546B-Oneui8" ]]; then
-            GKI_DEFCONFIG="$COMMON/arch/arm64/configs/s5e8835-a54xnaxx_defconfig"
-          elif [[ "${{ inputs.branch }}" == "SM-A546E-Oneui7" || "${{ inputs.branch }}" == "SM-A546E-Oneui8" ]]; then
-            GKI_DEFCONFIG="$COMMON/arch/arm64/configs/s5e8835-a54xnsxx_defconfig"
-          elif [[ "${{ inputs.branch }}" == "SM-M146B-Oneui7-ADYJ2" ]]; then
-            GKI_DEFCONFIG="$COMMON/arch/arm64/configs/s5e8535-m14xnsxx_defconfig"
-          elif [[ "${{ inputs.branch }}" == "SM-S908B-Oneui8-bitK" ]]; then
-            GKI_DEFCONFIG="$COMMON/arch/arm64/configs/s5e9925-b0sxxx_defconfig"
-          else
-            GKI_DEFCONFIG="$COMMON/arch/arm64/configs/gki_defconfig"
-          fi
-
-          echo "ROOT=$ROOT" >> $GITHUB_ENV
-          echo "SUSFS4KSU=$SUSFS4KSU" >> $GITHUB_ENV
-          echo "KERNEL_PATCHES=$KERNEL_PATCHES" >> $GITHUB_ENV
-          echo "ANYKERNEL3=$ANYKERNEL3" >> $GITHUB_ENV
-          echo "COMMON=$COMMON" >> $GITHUB_ENV
-          echo "GKI_DEFCONFIG=$GKI_DEFCONFIG" >> $GITHUB_ENV
-          echo "ZEROMOUNT=$ZEROMOUNT" >> $GITHUB_ENV
+        uses: ./.github/actions/env-variables
+        with:
+         branch: ${{ inputs.branch }}
+         susfs: ${{ inputs.susfs }}
+         zeromount: ${{ inputs.zeromount }}
           
       - name: Extract all tar.xz files and delete them
         run: |
@@ -148,508 +110,83 @@ jobs:
 
       - name: Add KernelSU-Next
         if: inputs.wksu == 'true'
-        run: |
-          cd "$COMMON"
-          curl -LSs "https://raw.githubusercontent.com/KernelSU-Next/KernelSU-Next/next/kernel/setup.sh" | bash -s dev
-
-          cd KernelSU-Next
-          git checkout 551ad80473f60e052917aec08abf5323b6ab2f7c
-
-          cd "$GITHUB_WORKSPACE"
-          cat >> "$GKI_DEFCONFIG" << 'EOF'
-          # KernelSU Configuration
-          CONFIG_KSU=y
-          EOF
-
-      - name: Getting KernelSU-Next Version
-        if: inputs.wksu == 'true'
-        run: |
-          cd "$COMMON/KernelSU-Next/kernel"
-          
-          KSU_DIR=$(pwd)
-          KBUILD="Kbuild"
-          BASE_VERSION=30000
-
-          if [ -d "$KSU_DIR/.git" ]; then
-              echo "✔ Git repo detected"
-
-              # Unshallow if needed
-              if [ -f "$KSU_DIR/.git/shallow" ]; then
-                  git -C "$KSU_DIR" fetch --unshallow || true
-              fi
-
-              # Get commit count
-              KSU_GIT_VERSION=$(git -C "$KSU_DIR" rev-list --count HEAD)
-
-              # Calculate version
-              KSU_VERSION=$((BASE_VERSION + KSU_GIT_VERSION))
-
-              # Get latest tag (safe)
-              KSU_GIT_TAG=$(git -C "$KSU_DIR" describe --tags --abbrev=0 2>/dev/null || echo "v0.0.1")
-
-          else
-              echo "⚠ Not a git repo, using defaults"
-              KSU_VERSION=33129
-              KSU_GIT_TAG="v3.2.0"
-          fi
-
-          echo "Computed version: $KSU_VERSION"
-          echo "Computed tag: $KSU_GIT_TAG"
-
-          # Export for CI (optional)
-          echo "KSU_VERSION=$KSU_VERSION" >> $GITHUB_ENV
-          echo "KSU_VERSION_TAG=$KSU_GIT_TAG" >> $GITHUB_ENV
-
-          # --- Update Kbuild fallback values ---
-
-          # Update numeric fallback
-          sed -i "s/KSU_VERSION_FALLBACK := [0-9]\+/KSU_VERSION_FALLBACK := ${KSU_VERSION}/" "$KBUILD"
-
-          # Update tag fallback
-          sed -i "s/KSU_VERSION_TAG_FALLBACK := .*/KSU_VERSION_TAG_FALLBACK := ${KSU_GIT_TAG}/" "$KBUILD"
-
-          echo "✅ Updated fallback values in $KBUILD"
-
+        uses: ./.github/actions/ksun
+        
       - name: Apply SUSFS Patches
         if: inputs.susfs == 'true'
-        run: |
-          cd "$COMMON/KernelSU-Next"
-          SUSFS_VERSION="v2.1.0"
-          
-          # Apply SUSFS to KernelSU-Next
-          cp "$SUSFS4KSU/kernel_patches/KernelSU/10_enable_susfs_for_ksu.patch" .
-          patch -p1 < 10_enable_susfs_for_ksu.patch || true
-          rm -rf 10_enable_susfs_for_ksu.patch
-
-          #Fix rejects from adding susfs to KSUN
-          cp "$KERNEL_PATCHES/next/susfs_fix_patches/$SUSFS_VERSION/"*.patch .
-          rm -rf multi_manager.patch
-          rm -rf multi_sepolicy_fix.patch
-          for p in *.patch; do
-             patch -p1 < "$p"
-              rm -f "$p"
-          done
-          
-           
-          # Apply SUSFS to kernel
-
-          cd ..
-          
-          cp "$SUSFS4KSU/kernel_patches/fs/"* ./fs/
-          cp "$SUSFS4KSU/kernel_patches/include/linux/"* ./include/linux/
-          cp "$SUSFS4KSU/kernel_patches/50_add_susfs_in_gki-${{ inputs.android_version }}-${{ inputs.kernel_version }}.patch" ./          
-
-          #Prepare open.c for susfs patching
-          sed -i '/#ifdef CONFIG_SECURITY_DEFEX/,/^#endif/d' fs/open.c
-
-          #Prepare namespace.c for susfs patching
-          sed -i '/copy_flags = CL_COPY_UNBINDABLE | CL_EXPIRE;/,/#endif/ {
-            /#ifdef CONFIG_KDP_NS/,/#endif/ {
-              /#else/,/#endif/!d
-              /#else/d
-              /#endif/d
-            }
-          }' fs/namespace.c
-          
-          # Apply SUSFS core patch
-          patch -p1 < 50_add_susfs_in_gki-${{ inputs.android_version }}-${{ inputs.kernel_version }}.patch || true
-          rm -rf 50_add_susfs_in_gki-${{ inputs.android_version }}-${{ inputs.kernel_version }}.patch
-          
-          if [ -d "$KERNEL_PATCHES/samsung/${{ inputs.branch }}" ]; then
-           echo "Directory exists, applying fixes"
-           cp "$KERNEL_PATCHES/samsung/${{ inputs.branch }}/"*.patch ./
-
-           # Fix SUSFS rejects
-           shopt -s nullglob
-
-          for p in *.patch; do
-             patch -p1 < "$p"
-              rm -f "$p"
-          done
-
-          shopt -u nullglob
-          else
-           echo "No directory found, skipping"
-          fi
-          
-          cd "$GITHUB_WORKSPACE"
-          cat >> "$GKI_DEFCONFIG" << 'EOF'
-          # SUSFS Configuration
-          CONFIG_KSU_SUSFS=y
-          EOF
-          
-          if [[ ${{ inputs.zeromount }} == 'true' ]]; then
-
-            echo "adding zeromount..."
-            
-            cd "$COMMON"
-            cp "$ZEROMOUNT/${{ inputs.android_version }}-${{ inputs.kernel_version }}/WildKSU/patches/60_zeromount-${{ inputs.android_version }}-${{ inputs.kernel_version }}.patch" .
-            #patch -p1 < 51_enhanced_susfs_gki-${{ inputs.android_version }}-${{ inputs.kernel_version }}.patch || true
-            patch -p1 < 60_zeromount-${{ inputs.android_version }}-${{ inputs.kernel_version }}.patch || true
-            rm -rf 60_zeromount-${{ inputs.android_version }}-${{ inputs.kernel_version }}.patch
-
-            if [ -f fs/proc/task_mmu.c ]; then
-              echo "Fixing task_mmu.c..."
-
-              sed -i '/pgoff = ((loff_t)vma->vm_pgoff) << PAGE_SHIFT;/a\
-              #ifdef CONFIG_ZEROMOUNT\
-              \tzeromount_spoof_mmap_metadata(inode, \&dev, \&ino);\
-              #endif' fs/proc/task_mmu.c
-            fi
-
-            if [ -f fs/stat.c.rej ]; then
-            echo "fixing stat.c."
-
-              if ! grep -q 'zeromount_stat_hook(dfd, filename, stat, request_mask, flags)' fs/stat.c; then
-                perl -0pi -e 's@(static int vfs_statx\(.*?\)\s*\{.*?orig_flow:\n#endif\n)@$1\n#ifdef CONFIG_ZEROMOUNT\n\tif (filename) {\n\t\tint zm_ret = zeromount_stat_hook(dfd, filename, stat, request_mask, flags);\n\t\tif (zm_ret != -ENOENT)\n\t\t\treturn zm_ret;\n\t}\n#endif\n\n@s' fs/stat.c
-              fi
-            fi
-
-            if [ -f fs/Kconfig.rej ]; then
-              echo "Applying Kconfig zeromount fix..."
+        uses: ./.github/actions/susfs-patches
+        with:
+          android_version: ${{ inputs.android_version }}
+          kernel_version: ${{ inputs.kernel_version }}
+          branch: ${{ inputs.branch }}
 
-              if ! grep -q '^config ZEROMOUNT$' fs/Kconfig; then
-                  perl -0pi -e 's@(config IO_WQ\n\tbool\n)@\1\nconfig ZEROMOUNT\n\tbool "ZeroMount Path Redirection Subsystem"\n\tdefault y\n\thelp\n\t  ZeroMount allows path redirection and virtual file injection\n\t  without mounting filesystems. Useful for systemless modifications.\n\n@' fs/Kconfig
-              fi
-            fi
-            #patch -p1 < 70_ksu_safety-wksu-${{ inputs.kernel_version }}.patch || true
+      - name: Apply zeromount Patches
+        if: inputs.susfs == 'true' && inputs.zeromount == 'true'
+        uses: ./.github/actions/zeromount
+        with:
+          android_version: ${{ inputs.android_version }}
+          kernel_version: ${{ inputs.kernel_version }}
 
-          cd "$GITHUB_WORKSPACE"
-          cat >> "$GKI_DEFCONFIG" << 'EOF'
-          # Zeromount Configuration
-          CONFIG_ZEROMOUNT=y
-          EOF
-          fi
-          
       - name: Fix WiFi and Bluetooth on Samsung 6.6 GKI devices
-        if: ${{ inputs.kernel_version == '6.6' }}
-        run: |
-         cd "$COMMON"
-         
-         SYMBOL_LIST=android/abi_gki_aarch64_galaxy
-         echo "kdp_set_cred_non_rcu" >> $SYMBOL_LIST
-         echo "kdp_usecount_dec_and_test" >> $SYMBOL_LIST
-         echo "kdp_usecount_inc" >> $SYMBOL_LIST
-
-         if [[ "${{ inputs.branch }}" == "SM-S931B-Oneui8" ]]; then
-           echo "snd_soc_find_dai" >> $SYMBOL_LIST
-           sed -i '
-           /"kernel_aarch64": {/,/},/ {
-           s/"kmi_symbol_list_strict_mode": True/"kmi_symbol_list_strict_mode": False/
-           s/"trim_nonlisted_kmi": True/"trim_nonlisted_kmi": False/
-           }
-           /"kernel_aarch64_16k": {/,/},/ {
-           s/"kmi_symbol_list_strict_mode": True/"kmi_symbol_list_strict_mode": False/
-           s/"trim_nonlisted_kmi": True/"trim_nonlisted_kmi": False/
-           }
-           ' BUILD.bazel
-         fi
-
-         cp "$KERNEL_PATCHES/samsung/min_kdp/min_kdp.c" drivers/min_kdp.c
-         echo "obj-y += min_kdp.o" >> drivers/Makefile         
+        if: inputs.kernel_version == '6.6'
+        uses: ./.github/actions/6.6-fix
+        with:
+         branch: ${{ inputs.branch }}
 
       - name: Add BBG
         if: inputs.bbg == 'true'
-        run: |          
-          cd "$COMMON"
-          echo "Adding BBG..."
-          curl -LSs https://github.com/vc-teahouse/Baseband-guard/raw/main/setup.sh | bash
-          echo "CONFIG_BBG=y" >> arch/arm64/configs/gki_defconfig
-          sed -i '/^config LSM$/,/^help$/{ /^[[:space:]]*default/ { /baseband_guard/! s/selinux/selinux,baseband_guard/ } }' security/Kconfig
-
-          cd "$GITHUB_WORKSPACE"
-          sed -i '/^CONFIG_LSM=/ s/"$/,baseband_guard"/' "$GKI_DEFCONFIG"
+        uses: ./.github/actions/bbg
 
       - name: temp fix for m55 bootloop maybe
         if: inputs.branch == 'SM-M556B-Oneui8'
-        run: |   
-          cd "$COMMON"
-
-          curl -L -s https://raw.githubusercontent.com/jimsterino98/Android-Kernel-Tutorials/refs/heads/main/patches/010.Disable-CRC-Checks.patch | patch -p1 --forward
-
-          cd "$GITHUB_WORKSPACE"
-          cat >> "$GKI_DEFCONFIG" << 'EOF'
-          #Force Load Kernel Modules
-          CONFIG_MODULES=y
-          CONFIG_MODULE_FORCE_LOAD=y
-          CONFIG_MODULE_UNLOAD=y
-          CONFIG_MODULE_FORCE_UNLOAD=y
-          CONFIG_MODVERSIONS=y
-          CONFIG_MODULE_SRCVERSION_ALL=n
-          CONFIG_MODULE_SIG=n
-          CONFIG_MODULE_COMPRESS=n
-          CONFIG_TRIM_UNUSED_KSYMS=n
-          
-          #Add btrfs user request
-          CONFIG_BTRFS_FS=y
-          EOF
+        uses: ./.github/actions/m55-fix
 
       - name: Add unicodefix
         if: inputs.unicodefix == 'true'
-        run: |  
-          cd "$COMMON"
-          echo "detected kernel version: ${{ inputs.kernel_version }}"
-
-          if [[ ${{ inputs.kernel_version }} == 6.* ]]; then
-           cp "$KERNEL_PATCHES/common/unicode_bypass_fix_6.1+.patch" .
-           patch -p1 < unicode_bypass_fix_6.1+.patch
-          else
-           cp "$KERNEL_PATCHES/common/unicode_bypass_fix_6.1-.patch" .
-           patch -p1 < unicode_bypass_fix_6.1-.patch
-          fi
+        uses: ./.github/actions/unicode
+        with:
+          kernel_version: ${{ inputs.kernel_version }}
 
       - name: Add droidspace support
         if: inputs.droidspace == 'true'
-        run: |  
-          cd "$COMMON"
-          # ABI: use ABI padding for SYSVIPC This commit allows us to enable CONFIG_SYSVIPC in defconfig without breaking kernel ABI
-          curl -Ls https://github.com/nullptr-t-oss/android_kernel_common_oneplus_sm8550/commit/769a5cfdc17b98d8e0bd491d45f5651180e42196.patch | patch -p1 --forward
-
-          cd "$GITHUB_WORKSPACE"
-          cat >> "$GKI_DEFCONFIG" << 'EOF'
-          # IPC
-          CONFIG_SYSVIPC=y
-          CONFIG_POSIX_MQUEUE=y
-
-          # Namespaces
-          CONFIG_IPC_NC=y
-          CONFIG_PID_NS=y
-
-          # HW Access Support
-          CONFIG_DEVTMPFS=y
-
-          # Below configs are optional
-
-          # Docker NAT
-          CONFIG_NETFILTER_XT_MATCH_ADDRTYPE=y
-
-          # UFW
-          CONFIG_NETFILTER_XT_TARGET_REJECT=y
-          CONFIG_NETFILTER_XT_TARGET_LOG=y
-          CONFIG_NETFILTER_XT_MATCH_RECENT
-
-          # Fail2Ban
-          CONFIG_IP_SET=y
-          CONFIG_IP_SET_HASH_IP=y
-          CONFIG_IP_SET_HASH_NET=y
-          CONFIG_NETFILTER_XT_SET=y
-          EOF
+        uses: ./.github/actions/droidspaces
           
       - name: Set Kernel Configuration Variables
         if: inputs.wksu == 'true'
-        run: |
-          
-          echo "Initializing kernel configuration..."
-          cat >> "$GKI_DEFCONFIG" << 'EOF'
-          # Mountify Support
-          CONFIG_OVERLAY_FS=y
-          CONFIG_TMPFS_XATTR=y
-          CONFIG_TMPFS_POSIX_ACL=y
-
-          # increase log buffer size to show bbg version in wksu homepage
-          CONFIG_LOG_BUF_SHIFT=20
-          EOF
-
-          if [[ "${{ inputs.branch }}" == "SM-S938B-Oneui7" || "${{ inputs.branch }}" == "SM-S931B-Oneui8" ]]; then
-          echo "nothing to see here moving on"
-          
-          elif [[ "${{ inputs.branch }}" == "SM-S926B-Oneui8" ]]; then
-          cat >> "$COMMON/arch/arm64/configs/s5e9945-bazel_defconfig" << 'EOF'
-          # nuke root protection
-          CONFIG_UH=n
-          CONFIG_UH_RKP=n
-          CONFIG_UH_LKMAUTH=n
-          CONFIG_UH_LKM_BLOCK=n
-          CONFIG_RKP_CFP_JOPP=n
-          CONFIG_RKP_CFP=n
-          CONFIG_SECURITY_DEFEX=n
-          CONFIG_PROCA=n
-          CONFIG_FIVE=n
-          CONFIG_RKP=n
-          CONFIG_KDP_NS=n
-          CONFIG_KDP=n
-          EOF
-
-          elif [[ ${{ inputs.branch }} == SM-A556* ]]; then
-          cat >> "$COMMON/arch/arm64/configs/s5e8845-bazel_defconfig" << 'EOF'
-          # nuke root protection
-          CONFIG_UH=n
-          CONFIG_UH_RKP=n
-          CONFIG_UH_LKMAUTH=n
-          CONFIG_UH_LKM_BLOCK=n
-          CONFIG_RKP_CFP_JOPP=n
-          CONFIG_RKP_CFP=n
-          CONFIG_SECURITY_DEFEX=n
-          CONFIG_PROCA=n
-          CONFIG_FIVE=n
-          CONFIG_RKP=n
-          CONFIG_KDP_NS=n
-          CONFIG_KDP=n
-          EOF
-
-          else
-          cat >> "$GKI_DEFCONFIG" << 'EOF'
-          # nuke root protection
-          CONFIG_UH=n
-          CONFIG_UH_RKP=n
-          CONFIG_UH_LKMAUTH=n
-          CONFIG_UH_LKM_BLOCK=n
-          CONFIG_RKP_CFP_JOPP=n
-          CONFIG_RKP_CFP=n
-          CONFIG_SECURITY_DEFEX=n
-          CONFIG_PROCA=n
-          CONFIG_FIVE=n
-          CONFIG_RKP=n  
-          CONFIG_KDP_NS=n
-          CONFIG_KDP=n
-          EOF
-          fi
-          
-          cd "$COMMON"
-          # Remove check_defconfig
-          sed -i 's/check_defconfig//' ./build.config.gki
-
-      - name: Add optimizations from kernel patches/common
-        if: inputs.optimizations == 'true'
-        run: |
-          cd "$COMMON"
-          echo "Optimizing Kernel..."
-          cp "$KERNEL_PATCHES/common/"*.patch ./
-          rm -rf unicode_bypass_fix_6.1+.patch
-          rm -rf unicode_bypass_fix_6.1-.patch
-          rm -rf IPv6_NAT_FIX.patch
-
-          for p in *.patch; do
-            if patch -p1 --dry-run < "$p"; then
-             echo "patch is OK, applying $p"
-             patch -p1 < "$p"
-             rm -f "$p"
-            else
-             echo "$p failed, skipping patch"
-            fi
-          done
-
-          echo "Kernel Optimized, hehe"
+        uses: ./.github/actions/configs
+        with:
+         branch: ${{ inputs.branch }}
 
       - name: Add ntsync
         if: inputs.ntsync == 'true'
-        run: |
-          cd "$COMMON"
-          echo "applying ntsync patches"
-          cp "$KERNEL_PATCHES/common/ntsync/ntsync_base.patch" .
-          cp "$KERNEL_PATCHES/common/ntsync/ntsync_compat_${{ inputs.android_version }}-${{ inputs.kernel_version }}.patch" .
-          patch -p1 < ntsync_base.patch || true
-          patch -p1 < ntsync_compat_${{ inputs.android_version }}-${{ inputs.kernel_version }}.patch
+        uses: ./.github/actions/ntsync
+        with:
+          android_version: ${{ inputs.android_version }}
+          kernel_version: ${{ inputs.kernel_version }}
 
-          cd "$GITHUB_WORKSPACE"
-          cat >> "$GKI_DEFCONFIG" << 'EOF'
-          CONFIG_NTSYNC=y
-          EOF
+      - name: Change Kernel Name and clean dirty
+        uses: ./.github/actions/kernel-name
 
-      - name: Change Kernel Name and remove protected exports
-        run: |
-          cd "$COMMON"
-            #Add Wild to Kernel Version
-            sed -i '$s|echo "\$res"|echo "\$res-Wild"|' ./scripts/setlocalversion
-            #Set Kernel Timestamp
-            #perl -pi -e 's{UTS_VERSION="\$\(echo \$UTS_VERSION \$CONFIG_FLAGS \$TIMESTAMP \| cut -b -\$UTS_LEN\)"}{UTS_VERSION="#1 SMP PREEMPT Sun Apr 20 04:20:00 UTC 2025"}' ./scripts/mkcompile_h
-          
-          #Remove Abi Exports and Error
-          rm -rf ./android/abi_gki_protected_exports_*
-          perl -pi -e 's/^\s*"protected_exports_list"\s*:\s*"android\/abi_gki_protected_exports_aarch64",\s*$//;' ./BUILD.bazel
-          
-      - name: Clean Dirty Flags
-        run: |
-          # remove dirty
-          sed -i 's/-dirty//' "./$COMMON/scripts/setlocalversion"
-          
+      - name: remove protected exports
+        uses: ./.github/actions/abi-export
+        
       - name: Set file name
         if: inputs.wksu == 'true'
-        run: |
-          ARTIFACT_BASE="${{ inputs.branch }}-${{ inputs.kernel_version }}-${{ inputs.android_version }}"
-          
-          # This gives: KSUxxxxx-branch-xxx-xxx
-          FILE_NAME="KSU${KSU_VERSION}-${ARTIFACT_BASE}"
-          
-          echo "ARTIFACT_BASE=$ARTIFACT_BASE" >> $GITHUB_ENV
-          echo "FILE_NAME=$FILE_NAME" >> $GITHUB_ENV
-          
-          echo "✅ Final artifact name: $FILE_NAME"
+        uses: ./.github/actions/file-name
+        with:
+         branch: ${{ inputs.branch }}
+         android_version: ${{ inputs.android_version }}
+         kernel_version: ${{ inputs.kernel_version }}
 
       - name: Build
-        run : |
-          set -e
-          set -x
-          cd "$CONFIG"
-          echo "Building the kernel..."
-          if [[ ${{ inputs.branch }} == SM-S928B* || "${{ inputs.branch }}" == "SM-S938B-Oneui7" || "${{ inputs.branch }}" == "SM-S931B-Oneui8" || "${{ inputs.branch }}" == "SM-F741B-Oneui8" ]]; then
-            chmod +x build_kernel_GKI.sh
-            ./build_kernel_GKI.sh || true
-          elif [[ "${{ inputs.branch }}" == "SM-X916B" || "${{ inputs.branch }}" == "SM-F946N-Oneui7" || "${{ inputs.branch }}" == "SM-S916B-Oneui8" || "${{ inputs.branch }}" == "SM-S918B-Oneui8" || "${{ inputs.branch }}" == "SM-F946B-Oneui8" || "${{ inputs.branch }}" == "SM-S901E-Oneui8" || "${{ inputs.branch }}" == "SM-X800-Oneui8" || "${{ inputs.branch }}" == "SM-S911B-Oneui8-bit8" || "${{ inputs.branch }}" == "SM-M556B-Oneui8" ]]; then
-            chmod +x build_kernel_GKI.sh
-            LTO=thin ./build_kernel_GKI.sh || true
-          elif [[ ${{ inputs.branch }} == SM-A546* || "${{ inputs.branch }}" == "SM-M146B-Oneui7-ADYJ2" || "${{ inputs.branch }}" == "SM-S908B-Oneui8-bitK" ]]; then
-            sudo apt update
-            sudo apt-get install -y libyaml-dev
-            chmod +x build_kernel.sh
-            LTO=thin ./build_kernel.sh || true
-          elif [[ "${{ inputs.branch }}" == "SM-A566B" ]]; then
-            chmod +x build_script.sh
-            touch ./kernel-6.6/abi_symbollist.raw
-            touch ./kernel-6.6/abi_symbollist
-            ./build_script.sh || true
-          elif [[ "${{ inputs.branch }}" == "SM-S926B-Oneui8" ]]; then
-            tools/bazel run --nocheck_bzl_visibility --config=stamp --sandbox_debug --verbose_failures --debug_make_verbosity=I //projects/s5e9945:s5e9945_user_dist
-          elif [[ ${{ inputs.branch }} == SM-A556* ]]; then
-            tools/bazel run --nocheck_bzl_visibility --config=stamp --sandbox_debug --verbose_failures --debug_make_verbosity=I //projects/s5e8845:s5e8845_user_dist
-          elif [[ ${{ inputs.branch }} == SM-A055* ]]; then
-            chmod +x build_kernel.sh
-            ./build_kernel.sh
-          else
-            #temporarily using this until i can figure out the other phones build script issues
-            cd kernel_platform
-            tools/bazel build --config=fast --lto=thin //common:kernel_aarch64_dist || exit 1
-          fi
+        uses: ./.github/actions/build
+        with:
+         branch: ${{ inputs.branch }}
           
       - name: Prepare AnyKernel3
-        run: |
-          cd "$CONFIG"
-          # Copy Image from normal build locations
-          #if [ -f "./$CONFIG/out/${{ inputs.android_version }}-${{ inputs.kernel_version }}/dist/Image" ]; then
-          #  cp ./$CONFIG/out/${{ inputs.android_version }}-${{ inputs.kernel_version }}/dist/Image AnyKernel3/Image
-          #elif [ -f "./$CONFIG/bazel-bin/common/kernel_aarch64/Image" ]; then
-          #  cp ./$CONFIG/bazel-bin/common/kernel_aarch64/Image AnyKernel3/Image
-          #else
-          #  echo "Error: Image file not found in any expected location"
-          #  exit 1
-          #fi
-          
-          if [[ "${{ inputs.branch }}" == "SM-S928B-Oneui7" || "${{ inputs.branch }}" == "SM-S928B-Oneui8-bit4" || "${{ inputs.branch }}" == "SM-S928B-Oneui8-bit5" || "${{ inputs.branch }}" == "SM-F741B-Oneui8" ]]; then
-            cp ./kernel_platform/sec/dist/Image "$ANYKERNEL3/Image"
-          elif [[ "${{ inputs.branch }}" == "SM-S928B-Oneui6.1" ]]; then
-            cp ./out/msm-pineapple-pineapple-gki/dist/Image "$ANYKERNEL3/Image"
-          elif [[ "${{ inputs.branch }}" == "SM-S938B-Oneui7" || "${{ inputs.branch }}" == "SM-S931B-Oneui8" || "${{ inputs.branch }}" == "SM-M556B-Oneui8" ]]; then
-            cp ./kernel_platform/gki/dist/Image "$ANYKERNEL3/Image"
-          elif [[ -f ./$CONFIG/bazel-bin/common/kernel_aarch64/Image ]]; then
-            cp ./$CONFIG/bazel-bin/common/kernel_aarch64/Image "$ANYKERNEL3/Image"
-          elif [[ "${{ inputs.branch }}" == "SM-X916B" || "${{ inputs.branch }}" == "SM-F946N-Oneui7" || "${{ inputs.branch }}" == "SM-F946B-Oneui8" || "${{ inputs.branch }}" == "SM-S916B-Oneui8" || "${{ inputs.branch }}" == "SM-S918B-Oneui8" || "${{ inputs.branch }}" == "SM-S911B-Oneui8-bit8" ]]; then
-            cp ./out/msm-kalama-kalama-gki/dist/Image "$ANYKERNEL3/Image"
-          elif [[ ${{ inputs.branch }} == SM-A546* || "${{ inputs.branch }}" == "SM-M146B-Oneui7-ADYJ2" || "${{ inputs.branch }}" == "SM-S908B-Oneui8-bitK" ]]; then
-            cp ./arch/arm64/boot/Image "$ANYKERNEL3/Image"
-          elif [[ "${{ inputs.branch }}" == "SM-A566B" ]]; then
-            cp ./kernel-6.6/out/arch/arm64/boot/Image "$ANYKERNEL3/Image"
-          elif [[ "${{ inputs.branch }}" == "SM-S926B-Oneui8" ]]; then
-            cp ./out/s5e9945_user/dist/Image "$ANYKERNEL3/Image"
-          elif [[ ${{ inputs.branch }} == SM-A556* ]]; then
-            cp ./out/s5e8845_user/dist/Image "$ANYKERNEL3/Image"
-          elif [[ "${{ inputs.branch }}" == "SM-S901E-Oneui8" || "${{ inputs.branch }}" == "SM-X800-Oneui8" ]]; then
-            cp ./out/msm-waipio-waipio-gki/dist/Image "$ANYKERNEL3/Image"
-          elif [[ ${{ inputs.branch }} == SM-A055* ]]; then
-            cp ./out/target/product/a05m/obj/KLEAF_OBJ/dist/kernel_device_modules-6.6/mgk_64_k66_kernel_aarch64.user/Image.gz "$ANYKERNEL3/Image.gz"
-          else
-            echo "Error: Image file not found in any expected location"
-            exit 1
-          fi
+        uses: ./.github/actions/ak3zip-prep
+        with:
+         branch: ${{ inputs.branch }}
 
       - name: Upload AnyKernel3 Artifacts
         id: upload_ak3
@@ -704,7 +241,6 @@ jobs:
           echo "- **Android Version**: ${{ inputs.android_version }}" >> build_summary.md
           echo "- **Kernel Version**: ${{ inputs.kernel_version }}.${{ inputs.sub_level }}" >> build_summary.md
           echo "- **BBG**: Installed" >> build_summary.md
-          echo "- **Bypass Mode**: ${{ matrix.apply_bypass }}" >> build_summary.md
           echo "" >> build_summary.md
 
           # Get KernelSU-Next commit

+ 0 - 4
.github/workflows/kernel-samsung.yml

@@ -28,9 +28,6 @@ on:
       ntsync:
         required: true
         type: string
-      optimizations:
-        required: true
-        type: string
 
 jobs:
   build-kernels-a12:
@@ -141,5 +138,4 @@ jobs:
       wksu: ${{ inputs.wksu }}
       droidspace: ${{ inputs.droidspace }}
       ntsync: ${{ inputs.ntsync }}
-      optimizations: ${{ inputs.optimizations }}
 

+ 21 - 52
.github/workflows/main.yml

@@ -19,75 +19,45 @@ on:
 
       wksu:
         description: "Build with WKSU?"
-        required: true
-        type: choice
-        options:
-          - yes
-          - no
-        default: yes
+        required: false
+        default: true
+        type: boolean
 
       susfs:
         description: "Build with SUSFS?"
-        required: true
-        type: choice
-        options:
-          - yes
-          - no
-        default: yes
+        required: false
+        type: boolean
+        default: true
 
       bbg:
         description: "Build with BBG?"
-        required: true
-        type: choice
-        options:
-          - yes
-          - no
-        default: yes
+        required: false
+        type: boolean
+        default: true
 
       zeromount:
         description: "Add Zeromount?"
-        required: true
-        type: choice
-        options:
-          - yes
-          - no
-        default: no
+        required: false
+        type: boolean
+        default: false
         
       unicodefix:
         description: "Add unicode fix?"
-        required: true
-        type: choice
-        options:
-          - yes
-          - no
-        default: yes
+        required: false
+        type: boolean
+        default: true
 
       droidspace:
         description: "add droidspace support?"
-        required: true
-        type: choice
-        options:
-          - yes
-          - no
-        default: yes
+        required: false
+        type: boolean
+        default: true
 
       ntsync:
         description: "add ntsync?"
-        required: true
-        type: choice
-        options:
-          - yes
-          - no
-        default: yes
-
-      optimizations:
-        description: "add optimizations from kernel patches repo?"
-        required: true
-        type: choice
-        options:
-          - yes
-          - no
-        default: no
+        required: false
+        type: boolean
+        default: true
 
 jobs:
 
@@ -102,7 +72,6 @@ jobs:
       wksu: ${{ inputs.wksu }}
       droidspace: ${{ inputs.droidspace }}
       ntsync: ${{ inputs.ntsync }}
-      optimizations: ${{ inputs.optimizations }}
 
   release:
     runs-on: ubuntu-latest