bypass.yml 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. name: Build Bypass Kernels
  2. permissions:
  3. contents: write
  4. actions: write
  5. on:
  6. workflow_call:
  7. inputs:
  8. ksu_commit:
  9. type: string
  10. required: false
  11. default: ''
  12. feature_set:
  13. type: string
  14. required: false
  15. default: 'WKSU+SUSFS+BBG'
  16. jobs:
  17. build:
  18. runs-on: ubuntu-latest
  19. strategy:
  20. fail-fast: false
  21. matrix:
  22. kernel_version:
  23. - "5.10.X-android12-lts"
  24. - "5.10.X-android13-lts"
  25. - "5.15.X-android13-lts"
  26. - "5.15.X-android14-lts"
  27. - "6.1.X-android14-lts"
  28. - "6.6.X-android15-lts"
  29. - "6.12.X-android16-lts"
  30. name: "${{ matrix.kernel_version }}"
  31. timeout-minutes: 60
  32. steps:
  33. - name: Checkout Repository
  34. uses: actions/checkout@v4
  35. - name: Parse kernel version
  36. id: parse
  37. run: |
  38. INPUT_VERSION="${{ matrix.kernel_version }}"
  39. KERNEL_BASE="${INPUT_VERSION%%-*}"
  40. KERNEL_VERSION="${KERNEL_BASE%.*}"
  41. SUB_LEVEL="${KERNEL_BASE##*.}"
  42. ANDROID_VERSION="${INPUT_VERSION#*-}"
  43. ANDROID_VERSION="${ANDROID_VERSION%%-*}"
  44. OS_PATCH_LEVEL="${INPUT_VERSION#*-}"
  45. OS_PATCH_LEVEL="${OS_PATCH_LEVEL#*-}"
  46. echo "ANDROID_VERSION=$ANDROID_VERSION" >> "$GITHUB_ENV"
  47. echo "KERNEL_VERSION=$KERNEL_VERSION" >> "$GITHUB_ENV"
  48. echo "SUB_LEVEL=$SUB_LEVEL" >> "$GITHUB_ENV"
  49. echo "OS_PATCH_LEVEL=$OS_PATCH_LEVEL" >> "$GITHUB_ENV"
  50. echo "android_version=$ANDROID_VERSION" >> $GITHUB_OUTPUT
  51. echo "kernel_version=$KERNEL_VERSION" >> $GITHUB_OUTPUT
  52. echo "sub_level=$SUB_LEVEL" >> $GITHUB_OUTPUT
  53. echo "os_patch_level=$OS_PATCH_LEVEL" >> $GITHUB_OUTPUT
  54. - name: Free Disk Space
  55. if: true
  56. uses: endersonmenezes/free-disk-space@v3
  57. with:
  58. remove_android: true
  59. remove_dotnet: true
  60. remove_haskell: true
  61. remove_tool_cache: true
  62. remove_swap: true
  63. remove_packages: "azure-cli google-cloud-cli microsoft-edge-stable google-chrome-stable firefox postgresql* temurin-* *llvm* mysql* dotnet-sdk-*"
  64. remove_packages_one_command: true
  65. remove_folders: "/usr/share/swift /usr/share/miniconda /usr/share/az* /usr/local/lib/node_modules /usr/local/share/chromium /usr/local/share/powershell /usr/local/julia /usr/local/aws-cli /usr/local/aws-sam-cli /usr/share/gradle"
  66. rm_cmd: "rmz"
  67. rmz_version: "3.1.1"
  68. testing: false
  69. - name: Download Build Dependencies
  70. uses: actions/download-artifact@v4
  71. with:
  72. name: build-dependencies
  73. path: .
  74. - name: Setup Build Environment
  75. run: |
  76. mkdir -p "$GITHUB_WORKSPACE/kernel"
  77. chmod +x "$GITHUB_WORKSPACE/git-repo/repo"
  78. echo "$GITHUB_WORKSPACE/git-repo" >> "$GITHUB_PATH"
  79. - name: Download Kernel Repository
  80. uses: ./.github/actions/download-kernel
  81. with:
  82. android_version: ${{ steps.parse.outputs.android_version }}
  83. kernel_version: ${{ steps.parse.outputs.kernel_version }}
  84. os_patch_level: ${{ steps.parse.outputs.os_patch_level }}
  85. - name: Extract Sublevel and Set File Name
  86. id: extract
  87. run: |
  88. SUBLEVEL="$SUB_LEVEL"
  89. if [[ -f "$GITHUB_WORKSPACE/kernel/common/Makefile" ]]; then
  90. EXTRACTED=$(grep '^SUBLEVEL = ' "$GITHUB_WORKSPACE/kernel/common/Makefile" | awk '{print $3}')
  91. [[ -n "$EXTRACTED" ]] && SUBLEVEL="$EXTRACTED"
  92. fi
  93. FILE_NAME="$KERNEL_VERSION.$SUBLEVEL-$ANDROID_VERSION-$OS_PATCH_LEVEL"
  94. echo "SUBLEVEL=$SUBLEVEL" >> $GITHUB_ENV
  95. echo "FILE_NAME=$FILE_NAME" >> $GITHUB_ENV
  96. echo "file_name=$FILE_NAME" >> $GITHUB_OUTPUT
  97. echo "sublevel=$SUBLEVEL" >> $GITHUB_OUTPUT
  98. - name: Setup Wild KSU
  99. if: contains(inputs.feature_set, 'WKSU')
  100. uses: ./.github/actions/wksu
  101. - name: Setup SUSFS
  102. if: contains(inputs.feature_set, 'SUSFS')
  103. uses: ./.github/actions/susfs
  104. with:
  105. android_version: ${{ steps.parse.outputs.android_version }}
  106. kernel_version: ${{ steps.parse.outputs.kernel_version }}
  107. os_patch_level: ${{ steps.parse.outputs.os_patch_level }}
  108. sublevel: ${{ steps.parse.outputs.sub_level }}
  109. - name: Setup Baseband Guard
  110. if: contains(inputs.feature_set, 'BBG')
  111. uses: ./.github/actions/bbg
  112. - name: Apply Device-Specific Patches
  113. uses: ./.github/actions/apply-device-patches
  114. with:
  115. kernel_version: ${{ steps.parse.outputs.kernel_version }}
  116. - name: Configure Kernel Options
  117. uses: ./.github/actions/configure-kernel
  118. - name: Apply ABI Compare Bypass
  119. working-directory: ${{ github.workspace }}/kernel
  120. run: |
  121. if [[ "$ANDROID_VERSION" == "android12" && "$KERNEL_VERSION" == "5.10" ]]; then
  122. sed -i 's/^\s*exit 1$/ echo "Who Cares? Bypassing Now!"/' build/abi/compare_to_symbol_list
  123. elif [[ "$ANDROID_VERSION" == "android13" && "$KERNEL_VERSION" == "5.10" ]]; then
  124. sed -i 's/^\s*exit 1$/ echo "Who Cares? Bypassing Now!"/' build/kernel/abi/compare_to_symbol_list
  125. elif [[ "$ANDROID_VERSION" == "android13" && "$KERNEL_VERSION" == "5.15" ]]; then
  126. sed -i 's/^\s*exit 1$/ echo "Who Cares? Bypassing Now!"/' build/kernel/abi/compare_to_symbol_list
  127. elif [[ "$ANDROID_VERSION" == "android14" && "$KERNEL_VERSION" == "5.15" ]]; then
  128. perl -i -pe 's/^(\s*)return 1$/$1print("Who Cares? Bypassing Now!")\n$1return 0/g if /if missing_symbols:/../return 1/' build/kernel/abi/check_buildtime_symbol_protection.py
  129. elif [[ "$ANDROID_VERSION" == "android14" && "$KERNEL_VERSION" == "6.1" ]]; then
  130. perl -i -pe 's/^(\s*)return 1$/$1print("Who Cares? Bypassing Now!")\n$1return 0/g if /if missing_symbols:/../return 1/' build/kernel/abi/check_buildtime_symbol_protection.py
  131. elif [[ "$ANDROID_VERSION" == "android15" && "$KERNEL_VERSION" == "6.6" ]]; then
  132. perl -i -pe 's/^(\s*)return 1$/$1print("Who Cares? Bypassing Now!")\n$1return 0/g if /if missing_symbols:/../return 1/' build/kernel/abi/check_buildtime_symbol_protection.py
  133. fi
  134. - name: Apply Kernel Branding
  135. uses: ./.github/actions/apply-kernel-branding
  136. with:
  137. build_type: 'Bypass'
  138. kernel_version: ${{ steps.parse.outputs.kernel_version }}
  139. - name: Clean Kernel Flags
  140. uses: ./.github/actions/clean-kernel-flags
  141. - name: Build Kernel
  142. working-directory: ${{ github.workspace }}/kernel
  143. run: |
  144. set -ex
  145. if [ -f "build/build.sh" ]; then
  146. GKI_DEFCONFIG_FRAGMENT="$GITHUB_WORKSPACE/wild_gki.fragment" LTO=thin BUILD_CONFIG=common/build.config.gki.aarch64 build/build.sh || exit 1
  147. else
  148. cp "$GITHUB_WORKSPACE/wild_gki.fragment" common/arch/arm64/configs/wild_gki.fragment
  149. if [[ "$ANDROID_VERSION" == "android14" ]]; then
  150. tools/bazel build --config=fast --lto=thin --defconfig_fragment=//common:arch/arm64/configs/wild_gki.fragment //common:kernel_aarch64_dist || exit 1
  151. else
  152. tools/bazel build --config=fast --lto=none --defconfig_fragment=//common:arch/arm64/configs/wild_gki.fragment //common:kernel_aarch64_dist || exit 1
  153. fi
  154. fi
  155. - name: Prepare AnyKernel3 Zip
  156. run: |
  157. if [ -f "$GITHUB_WORKSPACE/kernel/out/$ANDROID_VERSION-$KERNEL_VERSION/dist/Image" ]; then
  158. cp "$GITHUB_WORKSPACE/kernel/out/$ANDROID_VERSION-$KERNEL_VERSION/dist/Image" "$GITHUB_WORKSPACE/AnyKernel3/Image"
  159. elif [ -f "$GITHUB_WORKSPACE/kernel/bazel-bin/common/kernel_aarch64/Image" ]; then
  160. cp "$GITHUB_WORKSPACE/kernel/bazel-bin/common/kernel_aarch64/Image" "$GITHUB_WORKSPACE/AnyKernel3/Image"
  161. else
  162. echo "Error: Image file not found in any expected location"
  163. exit 1
  164. fi
  165. - name: Scan and collect patch rejects
  166. id: scan
  167. if: ${{ always() }}
  168. run: |
  169. set -e
  170. CONFIG_DIR="$GITHUB_WORKSPACE/kernel"
  171. REJECTS_DIR="$GITHUB_WORKSPACE/patch-rejects"
  172. mkdir -p "$REJECTS_DIR"
  173. mapfile -t REJS < <(find "$CONFIG_DIR" -type f -name '*.rej')
  174. REJ_COUNT=${#REJS[@]}
  175. echo "Found $REJ_COUNT .rej files under $CONFIG_DIR"
  176. echo "REJ_COUNT=$REJ_COUNT" >> $GITHUB_ENV
  177. echo "rej_count=$REJ_COUNT" >> $GITHUB_OUTPUT
  178. if [ "$REJ_COUNT" -gt 0 ]; then
  179. for REJ in "${REJS[@]}"; do
  180. REL="${REJ#"$CONFIG_DIR"/}"
  181. DEST="$REJECTS_DIR/$REL"
  182. mkdir -p "$(dirname "$DEST")"
  183. cp "$REJ" "$DEST"
  184. ORIG="${REJ%.rej}"
  185. if [ -f "$ORIG" ]; then
  186. ORIG_DEST="$REJECTS_DIR/${REL%.rej}"
  187. mkdir -p "$(dirname "$ORIG_DEST")"
  188. cp "$ORIG" "$ORIG_DEST"
  189. fi
  190. echo "$REL" >> "$REJECTS_DIR/index.txt"
  191. done
  192. fi
  193. - name: Upload Artifacts
  194. uses: actions/upload-artifact@v4
  195. with:
  196. name: ${{ steps.extract.outputs.file_name }}-AnyKernel3
  197. path: ${{ github.workspace }}/AnyKernel3/**
  198. if-no-files-found: ignore
  199. compression-level: 9
  200. - name: Upload Rejects
  201. if: ${{ always() && steps.scan.outputs.rej_count > 0 }}
  202. uses: actions/upload-artifact@v4
  203. with:
  204. name: ${{ steps.extract.outputs.file_name }}-Rejects
  205. path: patch-rejects/
  206. if-no-files-found: ignore
  207. compression-level: 9
  208. - name: Build Summary
  209. if: ${{ always() }}
  210. run: |
  211. echo "Android Version : $ANDROID_VERSION"
  212. echo "Kernel Version : $KERNEL_VERSION"
  213. echo "Sub Level : $SUB_LEVEL"
  214. echo "Sub level (Makefile): $SUBLEVEL"
  215. echo "Patch Level : $OS_PATCH_LEVEL"
  216. echo "Build Type : Bypass"
  217. echo "Features : ${{ inputs.feature_set || 'None' }}"
  218. echo "WKSU Commit : ${{ inputs.ksu_commit || 'canary' }}"