build.yml 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806
  1. name: Kernel Build Process
  2. permissions:
  3. contents: write
  4. actions: write
  5. on:
  6. workflow_call:
  7. inputs:
  8. android_version:
  9. required: true
  10. type: string
  11. kernel_version:
  12. required: true
  13. type: string
  14. sub_level:
  15. required: true
  16. type: string
  17. os_patch_level:
  18. required: true
  19. type: string
  20. jobs:
  21. build-gki:
  22. name: "${{ inputs.kernel_version }}.${{ inputs.sub_level }}-${{ inputs.android_version }}-${{ inputs.os_patch_level }} (${{ matrix.apply_bypass }})"
  23. runs-on: ubuntu-latest
  24. strategy:
  25. fail-fast: false
  26. matrix:
  27. apply_bypass: ["normal", "bypass"]
  28. steps:
  29. - name: Check Initial Disk Space
  30. run: |
  31. echo "===== Initial Total Disk Space in GB ====="
  32. df -BG
  33. - name: Download Apache Arrow's util_free_space.sh
  34. run: |
  35. curl -L -o util_free_space.sh https://raw.githubusercontent.com/apache/arrow/main/ci/scripts/util_free_space.sh
  36. chmod +x util_free_space.sh
  37. ./util_free_space.sh
  38. - name: Check Disk Space After Cleanup
  39. run: |
  40. echo "===== Total Disk Space After Cleanup in GB ====="
  41. df -BG
  42. - name: Set CONFIG Environment Variable
  43. run: |
  44. # Set CONFIG dynamically based on inputs values
  45. CONFIG="${{ inputs.android_version }}-${{ inputs.kernel_version }}-${{ inputs.sub_level }}"
  46. # Set CONFIG as an environment variable for future steps
  47. echo "CONFIG=$CONFIG" >> $GITHUB_ENV
  48. - name: Setup Build Environment
  49. run: |
  50. AOSP_MIRROR=https://android.googlesource.com
  51. BRANCH=main-kernel-2025
  52. git clone $AOSP_MIRROR/kernel/prebuilts/build-tools -b $BRANCH --depth 1 kernel-build-tools &
  53. git clone $AOSP_MIRROR/platform/system/tools/mkbootimg -b $BRANCH --depth 1 mkbootimg &
  54. wait
  55. echo "AVBTOOL=$GITHUB_WORKSPACE/kernel-build-tools/linux-x86/bin/avbtool" >> $GITHUB_ENV
  56. echo "MKBOOTIMG=$GITHUB_WORKSPACE/mkbootimg/mkbootimg.py" >> $GITHUB_ENV
  57. echo "UNPACK_BOOTIMG=$GITHUB_WORKSPACE/mkbootimg/unpack_bootimg.py" >> $GITHUB_ENV
  58. echo "BOOT_SIGN_KEY_PATH=$GITHUB_WORKSPACE/kernel-build-tools/linux-x86/share/avb/testkey_rsa2048.pem" >> $GITHUB_ENV
  59. echo "PATH=$GITHUB_WORKSPACE/kernel-build-tools/linux-x86/bin:$PATH" >> $GITHUB_ENV
  60. mkdir -p ./git-repo
  61. curl https://storage.googleapis.com/git-repo-downloads/repo > ./git-repo/repo
  62. chmod a+rx ./git-repo/repo
  63. echo "REPO=$GITHUB_WORKSPACE/./git-repo/repo" >> $GITHUB_ENV
  64. - name: Set boot sign key
  65. env:
  66. BOOT_SIGN_KEY: ${{ secrets.BOOT_SIGN_KEY }}
  67. run: |
  68. if [ ! -z "$BOOT_SIGN_KEY" ]; then
  69. echo "$BOOT_SIGN_KEY" > ./kernel-build-tools/linux-x86/share/avb/testkey_rsa2048.pem
  70. fi
  71. - name: Clone AnyKernel3 and Other Dependencies
  72. run: |
  73. ANYKERNEL_BRANCH="gki-2.0"
  74. SUSFS_BRANCH="gki-${{ inputs.android_version }}-${{ inputs.kernel_version }}"
  75. git clone https://github.com/WildKernels/AnyKernel3.git -b "$ANYKERNEL_BRANCH"
  76. git clone https://github.com/WildKernels/kernel_patches.git
  77. git clone https://gitlab.com/simonpunk/susfs4ksu.git -b "$SUSFS_BRANCH"
  78. - name: Initialize and Sync Kernel Source
  79. run: |
  80. mkdir -p "$CONFIG"
  81. cd "$CONFIG"
  82. FORMATTED_BRANCH="${{ inputs.android_version }}-${{ inputs.kernel_version }}-${{ inputs.os_patch_level }}"
  83. $REPO init --depth=1 --u https://android.googlesource.com/kernel/manifest -b common-${FORMATTED_BRANCH} --repo-rev=v2.16
  84. REMOTE_BRANCH=$(git ls-remote https://android.googlesource.com/kernel/common ${FORMATTED_BRANCH})
  85. DEFAULT_MANIFEST_PATH=.repo/manifests/default.xml
  86. if grep -q deprecated <<< $REMOTE_BRANCH; then
  87. sed -i "s/\"${FORMATTED_BRANCH}\"/\"deprecated\/${FORMATTED_BRANCH}\"/g" $DEFAULT_MANIFEST_PATH
  88. fi
  89. $REPO --trace sync -c -j$(nproc --all) --no-tags --fail-fast
  90. - name: Check Directory Space Usage
  91. run: |
  92. echo "===== Total Disk Space After Kernel Download in GB ====="
  93. df -BG
  94. echo "===== Directory Space Usage in GB ====="
  95. du -BG -d 1 | sort -nr
  96. echo "===== $CONFIG Directory Space Usage in GB ====="
  97. cd "$CONFIG"
  98. du -BG -d 2 | sort -nr
  99. - name: Extract Actual Sublevel
  100. run: |
  101. cd "$CONFIG/common"
  102. if [ -f "Makefile" ]; then
  103. ACTUAL_SUBLEVEL=$(grep '^SUBLEVEL = ' Makefile | awk '{print $3}')
  104. if [ -n "$ACTUAL_SUBLEVEL" ]; then
  105. echo "ACTUAL_SUBLEVEL=$ACTUAL_SUBLEVEL" >> $GITHUB_ENV
  106. echo "Extracted ACTUAL_SUBLEVEL=$ACTUAL_SUBLEVEL; no directory changes performed."
  107. else
  108. echo "Warning: SUBLEVEL not found in Makefile; continuing with inputs.sub_level."
  109. fi
  110. fi
  111. - name: Apply glibc 2.38 Compatibility Fix
  112. run: |
  113. # Use ACTUAL_SUBLEVEL for LTS builds, otherwise use the input sub_level
  114. if ([[ "${{ inputs.android_version }}" == "android13" ]] && [[ "${{ inputs.kernel_version }}" == "5.10" ]] && (( $ACTUAL_SUBLEVEL <= 186 ))) ||
  115. ([[ "${{ inputs.android_version }}" == "android13" ]] && [[ "${{ inputs.kernel_version }}" == "5.15" ]] && (( $ACTUAL_SUBLEVEL <= 119 ))) ||
  116. ([[ "${{ inputs.android_version }}" == "android14" ]] && [[ "${{ inputs.kernel_version }}" == "5.15" ]] && (( $ACTUAL_SUBLEVEL <= 110 ))) ||
  117. ([[ "${{ inputs.android_version }}" == "android14" ]] && [[ "${{ inputs.kernel_version }}" == "6.1" ]] && (( $ACTUAL_SUBLEVEL <= 43 ))); then
  118. GLIBC_VERSION=$(ldd --version 2>/dev/null | head -n 1 | awk '{print $NF}')
  119. if [ "$(printf '%s\n' "2.38" "$GLIBC_VERSION" | sort -V | head -n1)" = "2.38" ]; then
  120. cd $CONFIG/common/
  121. sed -i '/\$(Q)\$(MAKE) -C \$(SUBCMD_SRC) OUTPUT=\$(abspath \$(dir \$@))\/ \$(abspath \$@)/s//$(Q)$(MAKE) -C $(SUBCMD_SRC) EXTRA_CFLAGS="$(CFLAGS)" OUTPUT=$(abspath $(dir $@))\/ $(abspath $@)/' tools/bpf/resolve_btfids/Makefile 2>/dev/null || true
  122. if ([[ "${{ inputs.android_version }}" == "android13" ]] && [[ "${{ inputs.kernel_version }}" == "5.10" ]] && (( $ACTUAL_SUBLEVEL <= 186 ))) ||
  123. ([[ "${{ inputs.android_version }}" == "android13" ]] && [[ "${{ inputs.kernel_version }}" == "5.15" ]] && (( $ACTUAL_SUBLEVEL <= 119 ))) ||
  124. ([[ "${{ inputs.android_version }}" == "android14" ]] && [[ "${{ inputs.kernel_version }}" == "5.15" ]] && (( $ACTUAL_SUBLEVEL <= 110 ))); then
  125. sed -i '/char \*buf = NULL;/a int i;' tools/lib/subcmd/parse-options.c 2>/dev/null || true
  126. sed -i 's/for (int i = 0; subcommands\[i\]; i++) {/for (i = 0; subcommands[i]; i++) {/' tools/lib/subcmd/parse-options.c 2>/dev/null || true
  127. sed -i '/if (subcommands) {/a int i;' tools/lib/subcmd/parse-options.c 2>/dev/null || true
  128. sed -i 's/for (int i = 0; subcommands\[i\]; i++)/for (i = 0; subcommands[i]; i++)/' tools/lib/subcmd/parse-options.c 2>/dev/null || true
  129. fi
  130. fi
  131. fi
  132. - name: Fix Less Then 6.6.50 Builds
  133. if: inputs.android_version == 'android15' && inputs.kernel_version == '6.6'
  134. run: |
  135. cd "$CONFIG/common"
  136. if ! grep -qxF '#include <trace/hooks/fs.h>' ./fs/namespace.c; then
  137. sed -i '/#include <trace\/hooks\/blk.h>/a #include <trace\/hooks\/fs.h>' ./fs/namespace.c
  138. fi
  139. - name: Apply ptrace patch for older kernels
  140. if: fromJSON(inputs.kernel_version) < 5.16
  141. run: |
  142. cd "$CONFIG/common"
  143. patch -p1 -F 3 < "../../kernel_patches/gki_ptrace.patch"
  144. - name: Add KernelSU
  145. run: |
  146. cd "$CONFIG"
  147. curl -LSs "https://raw.githubusercontent.com/WildKernels/Wild_KSU/wild/kernel/setup.sh" | bash -s wild
  148. - name: Getting KernelSU Version
  149. run: |
  150. cd "$CONFIG/Wild_KSU/kernel"
  151. BASE_VERSION=10200
  152. COMMIT_COUNT=$(/usr/bin/git rev-list --count HEAD)
  153. KSU_VERSION=$(expr $COMMIT_COUNT "+" $BASE_VERSION)
  154. echo "KSUVER=$KSU_VERSION" >> $GITHUB_ENV
  155. - name: Apply SUSFS Patches for KernelSU Variants
  156. run: |
  157. cd "$CONFIG"
  158. # Apply compatibility fixes
  159. SUSFS_VERSION="1.5.12"
  160. cp ../susfs4ksu/kernel_patches/fs/* ./common/fs/
  161. cp ../susfs4ksu/kernel_patches/include/linux/* ./common/include/linux/
  162. # Apply core SUSFS patches
  163. cp ../susfs4ksu/kernel_patches/50_add_susfs_in_gki-${{ inputs.android_version }}-${{ inputs.kernel_version }}.patch ./common/
  164. cd common
  165. # Pre-SUSFS sed safeguards removed; moved below core patch
  166. # Apply SUSFS core patch
  167. patch -p1 < 50_add_susfs_in_gki-${{ inputs.android_version }}-${{ inputs.kernel_version }}.patch || true
  168. # Post-SUSFS sed safeguards for task_mmu.c 'goto show_pad' handling
  169. if ( ( [[ "${{ inputs.android_version }}" == "android12" ]] && [[ "${{ inputs.kernel_version }}" == "5.10" ]] && (( $ACTUAL_SUBLEVEL <= 209 )) ) \
  170. || ( [[ "${{ inputs.android_version }}" == "android13" ]] && [[ "${{ inputs.kernel_version }}" == "5.10" ]] && [[ "${{ inputs.os_patch_level }}" != "2024-05" ]] && (( $ACTUAL_SUBLEVEL <= 209 )) ) \
  171. || ( [[ "${{ inputs.android_version }}" == "android13" ]] && [[ "${{ inputs.kernel_version }}" == "5.15" ]] && [[ "${{ inputs.os_patch_level }}" != "2024-05" ]] && (( $ACTUAL_SUBLEVEL <= 148 )) ) \
  172. || ( [[ "${{ inputs.android_version }}" == "android14" ]] && [[ "${{ inputs.kernel_version }}" == "5.15" ]] && [[ "${{ inputs.os_patch_level }}" != "2024-05" ]] && (( $ACTUAL_SUBLEVEL <= 148 )) ) \
  173. || ( [[ "${{ inputs.android_version }}" == "android14" ]] && [[ "${{ inputs.kernel_version }}" == "6.1" ]] && [[ "${{ inputs.os_patch_level }}" != "2024-05" ]] && (( $ACTUAL_SUBLEVEL <= 75 )) ) ); then
  174. sed -i -e 's/goto show_pad;/return 0;/' ./fs/proc/task_mmu.c
  175. fi
  176. # Apply additional SUSFS patches for Android 13 5.15 compatibility
  177. if [[ "${{ inputs.android_version }}" == "android13" ]] && [[ "${{ inputs.kernel_version }}" == "5.15" ]] && (( ${{ inputs.sub_level }} <= 41 )); then
  178. cp ../../kernel_patches/wild/susfs_fix_patches/v${SUSFS_VERSION}/fix_fdinfo.c.patch ./
  179. patch -p1 < fix_fdinfo.c.patch || true
  180. cp ../../kernel_patches/wild/susfs_fix_patches/v${SUSFS_VERSION}/fix_namespace.c.patch ./
  181. patch -p1 < fix_namespace.c.patch || true
  182. cp ../../kernel_patches/wild/susfs_fix_patches/v${SUSFS_VERSION}/fix_open.c.patch ./
  183. patch -p1 < fix_open.c.patch || true
  184. sed -i 's/i_uid_into_mnt(i_user_ns(inode), inode)/i_uid_into_mnt(inode->i_sb->s_user_ns, inode)/g' fs/susfs.c
  185. fi
  186. # Use ACTUAL_SUBLEVEL for LTS or actual kernel sublevel if available
  187. if ( [[ "${{ inputs.android_version }}" == "android12" ]] && [[ "${{ inputs.kernel_version }}" == "5.10" ]] && (( $ACTUAL_SUBLEVEL <= 43 )) ) \
  188. || ( [[ "${{ inputs.android_version }}" == "android14" ]] && [[ "${{ inputs.kernel_version }}" == "6.1" ]] && (( $ACTUAL_SUBLEVEL >= 145 )) ) \
  189. || ( [[ "${{ inputs.android_version }}" == "android15" ]] && [[ "${{ inputs.kernel_version }}" == "6.6" ]] && (( $ACTUAL_SUBLEVEL >= 98 )) ); then
  190. cp ../../kernel_patches/wild/susfs_fix_patches/v${SUSFS_VERSION}/1_fix_base.c.patch ./
  191. patch -p1 < 1_fix_base.c.patch || true
  192. fi
  193. if [[ "${{ inputs.android_version }}" == "android12" ]] && [[ "${{ inputs.kernel_version }}" == "5.10" ]] && (( $ACTUAL_SUBLEVEL <= 43 )); then
  194. cp ../../kernel_patches/wild/susfs_fix_patches/v${SUSFS_VERSION}/2_fix_base.c.patch ./
  195. patch -p1 < 2_fix_base.c.patch || true
  196. fi
  197. if ( [[ "${{ inputs.android_version }}" == "android15" ]] && [[ "${{ inputs.kernel_version }}" == "6.6" ]] && (( $ACTUAL_SUBLEVEL <= 58 )) ); then
  198. cp ../../kernel_patches/wild/susfs_fix_patches/v${SUSFS_VERSION}/fix_task_mmu.c.patch ./
  199. patch -p1 < fix_task_mmu.c.patch || true
  200. fi
  201. # Apply KSU integration patches
  202. cd ../Wild_KSU
  203. cp ../../susfs4ksu/kernel_patches/KernelSU/10_enable_susfs_for_ksu.patch .
  204. patch -p1 < 10_enable_susfs_for_ksu.patch || true
  205. cp ../../kernel_patches/wild/susfs_fix_patches/v${SUSFS_VERSION}/fix_core_hook.c.patch ./
  206. patch -p1 < fix_core_hook.c.patch
  207. cp ../../kernel_patches/wild/susfs_fix_patches/v${SUSFS_VERSION}/fix_sucompat.c.patch ./
  208. patch -p1 < fix_sucompat.c.patch
  209. cp ../../kernel_patches/wild/susfs_fix_patches/v${SUSFS_VERSION}/fix_kernel_compat.c.patch ./
  210. patch -p1 < fix_kernel_compat.c.patch
  211. - name: Apply Hooks Patches
  212. run: |
  213. cd "$CONFIG/common"
  214. cp ../../kernel_patches/wild/hooks/scope_min_manual_hooks_v1.4.patch ./
  215. patch -p1 -F 3 < scope_min_manual_hooks_v1.4.patch
  216. - name: Scan and collect patch rejects
  217. if: ${{ always() }}
  218. run: |
  219. set -e
  220. CONFIG_DIR="$CONFIG"
  221. REJECTS_DIR="$GITHUB_WORKSPACE/patch-rejects"
  222. mkdir -p "$REJECTS_DIR"
  223. # Find all .rej files under the configuration directory
  224. mapfile -t REJS < <(find "$CONFIG_DIR" -type f -name '*.rej')
  225. REJ_COUNT=${#REJS[@]}
  226. echo "Found $REJ_COUNT .rej files under $CONFIG_DIR"
  227. echo "REJ_COUNT=$REJ_COUNT" >> $GITHUB_ENV
  228. if [ "$REJ_COUNT" -gt 0 ]; then
  229. for REJ in "${REJS[@]}"; do
  230. # Relative path from $CONFIG
  231. REL="${REJ#"$CONFIG_DIR"/}"
  232. DEST="$REJECTS_DIR/$REL"
  233. mkdir -p "$(dirname "$DEST")"
  234. cp "$REJ" "$DEST"
  235. # Copy the associated original file alongside the .rej
  236. ORIG="${REJ%.rej}"
  237. if [ -f "$ORIG" ]; then
  238. ORIG_DEST="$REJECTS_DIR/${REL%.rej}"
  239. mkdir -p "$(dirname "$ORIG_DEST")"
  240. cp "$ORIG" "$ORIG_DEST"
  241. fi
  242. echo "$REL" >> "$REJECTS_DIR/index.txt"
  243. done
  244. fi
  245. - name: Add BBG
  246. run: |
  247. cd "$CONFIG"
  248. echo "Adding BBG..."
  249. wget -O- https://github.com/vc-teahouse/Baseband-guard/raw/main/setup.sh | bash
  250. echo "CONFIG_BBG=y" >> common/arch/arm64/configs/gki_defconfig
  251. sed -i '/^config LSM$/,/^help$/{ /^[[:space:]]*default/ { /baseband_guard/! s/lockdown/lockdown,baseband_guard/ } }' common/security/Kconfig
  252. - name: Apply Module Check Bypass
  253. if: ${{ matrix.apply_bypass == 'bypass' }}
  254. run: |
  255. if [[ "${{ inputs.kernel_version }}" == "6.1" || "${{ inputs.kernel_version }}" == "6.6" ]]; then
  256. cd "$CONFIG/common/kernel/module"
  257. sed -i '/bad_version:/{:a;n;/return 0;/{s/return 0;/return 1;/;b};ba}' version.c
  258. else
  259. cd "$CONFIG/common/kernel"
  260. sed -i '/bad_version:/{:a;n;/return 0;/{s/return 0;/return 1;/;b};ba}' module.c
  261. fi
  262. - name: Fix WiFi and Bluetooth on Samsung 6.6 GKI devices
  263. if: ${{ ( inputs.kernel_version == '6.6' ) }}
  264. run: |
  265. SYMBOL_LIST=$CONFIG/common/android/abi_gki_aarch64_galaxy
  266. echo "kdp_set_cred_non_rcu" >> $SYMBOL_LIST
  267. echo "kdp_usecount_dec_and_test" >> $SYMBOL_LIST
  268. echo "kdp_usecount_inc" >> $SYMBOL_LIST
  269. cd $CONFIG/common
  270. PATCH="../../kernel_patches/samsung/min_kdp/add-min_kdp-symbols.patch"
  271. if patch -p1 --dry-run < $PATCH; then
  272. patch -p1 --no-backup-if-mismatch < $PATCH
  273. fi
  274. cd drivers
  275. cp "../../../kernel_patches/samsung/min_kdp/min_kdp.c" min_kdp.c
  276. echo "obj-y += min_kdp.o" >> Makefile
  277. - name: Set Kernel Configuration Variables
  278. run: |
  279. cd "$CONFIG"
  280. echo "Initializing kernel configuration..."
  281. echo "DEFCONFIG=./common/arch/arm64/configs/gki_defconfig" >> $GITHUB_ENV
  282. # Remove check_defconfig
  283. sed -i 's/check_defconfig//' ./common/build.config.gki
  284. - name: Configure KernelSU Core
  285. run: |
  286. cd "$CONFIG"
  287. # KernelSU Configuration
  288. echo "# KernelSU Configuration" >> "${{ env.DEFCONFIG }}"
  289. echo "CONFIG_KSU=y" >> "${{ env.DEFCONFIG }}"
  290. echo "CONFIG_KSU_KPROBES_HOOK=n" >> "${{ env.DEFCONFIG }}"
  291. - name: Configure Mountify Support
  292. run: |
  293. cd "$CONFIG"
  294. # Mountify Support
  295. echo "# Mountify Support" >> "${{ env.DEFCONFIG }}"
  296. echo "CONFIG_TMPFS_XATTR=y" >> "${{ env.DEFCONFIG }}"
  297. echo "CONFIG_TMPFS_POSIX_ACL=y" >> "${{ env.DEFCONFIG }}"
  298. - name: Configure Networking
  299. run: |
  300. cd "$CONFIG"
  301. # Networking Configuration
  302. echo "# Networking Configuration" >> "${{ env.DEFCONFIG }}"
  303. echo "CONFIG_IP_NF_TARGET_TTL=y" >> "${{ env.DEFCONFIG }}"
  304. echo "CONFIG_IP6_NF_TARGET_HL=y" >> "${{ env.DEFCONFIG }}"
  305. echo "CONFIG_IP6_NF_MATCH_HL=y" >> "${{ env.DEFCONFIG }}"
  306. - name: Configure TCP Congestion Control
  307. run: |
  308. cd "$CONFIG"
  309. # BBR TCP Congestion Control
  310. echo "# BBR TCP Congestion Control" >> "${{ env.DEFCONFIG }}"
  311. echo "CONFIG_TCP_CONG_ADVANCED=y" >> "${{ env.DEFCONFIG }}"
  312. echo "CONFIG_TCP_CONG_BBR=y" >> "${{ env.DEFCONFIG }}"
  313. echo "CONFIG_NET_SCH_FQ=y" >> "${{ env.DEFCONFIG }}"
  314. echo "CONFIG_TCP_CONG_BIC=n" >> "${{ env.DEFCONFIG }}"
  315. echo "CONFIG_TCP_CONG_WESTWOOD=n" >> "${{ env.DEFCONFIG }}"
  316. echo "CONFIG_TCP_CONG_HTCP=n" >> "${{ env.DEFCONFIG }}"
  317. - name: Configure IPSet Support
  318. run: |
  319. cd "$CONFIG"
  320. # IPSet support
  321. echo "# IPSet Support" >> "${{ env.DEFCONFIG }}"
  322. echo "CONFIG_IP_SET=y" >> "${{ env.DEFCONFIG }}"
  323. echo "CONFIG_IP_SET_MAX=65534" >> "${{ env.DEFCONFIG }}"
  324. echo "CONFIG_IP_SET_BITMAP_IP=y" >> "${{ env.DEFCONFIG }}"
  325. echo "CONFIG_IP_SET_BITMAP_IPMAC=y" >> "${{ env.DEFCONFIG }}"
  326. echo "CONFIG_IP_SET_BITMAP_PORT=y" >> "${{ env.DEFCONFIG }}"
  327. echo "CONFIG_IP_SET_HASH_IP=y" >> "${{ env.DEFCONFIG }}"
  328. echo "CONFIG_IP_SET_HASH_IPMARK=y" >> "${{ env.DEFCONFIG }}"
  329. echo "CONFIG_IP_SET_HASH_IPPORT=y" >> "${{ env.DEFCONFIG }}"
  330. echo "CONFIG_IP_SET_HASH_IPPORTIP=y" >> "${{ env.DEFCONFIG }}"
  331. echo "CONFIG_IP_SET_HASH_IPPORTNET=y" >> "${{ env.DEFCONFIG }}"
  332. echo "CONFIG_IP_SET_HASH_IPMAC=y" >> "${{ env.DEFCONFIG }}"
  333. echo "CONFIG_IP_SET_HASH_MAC=y" >> "${{ env.DEFCONFIG }}"
  334. echo "CONFIG_IP_SET_HASH_NETPORTNET=y" >> "${{ env.DEFCONFIG }}"
  335. echo "CONFIG_IP_SET_HASH_NET=y" >> "${{ env.DEFCONFIG }}"
  336. echo "CONFIG_IP_SET_HASH_NETNET=y" >> "${{ env.DEFCONFIG }}"
  337. echo "CONFIG_IP_SET_HASH_NETPORT=y" >> "${{ env.DEFCONFIG }}"
  338. echo "CONFIG_IP_SET_HASH_NETIFACE=y" >> "${{ env.DEFCONFIG }}"
  339. echo "CONFIG_IP_SET_LIST_SET=y" >> "${{ env.DEFCONFIG }}"
  340. - name: Configure SUSFS
  341. run: |
  342. cd "$CONFIG"
  343. # SUSFS Configuration
  344. echo "# SUSFS Configuration" >> "${{ env.DEFCONFIG }}"
  345. echo "CONFIG_KSU_SUSFS=y" >> "${{ env.DEFCONFIG }}"
  346. echo "#CONFIG_KSU_SUSFS_HAS_MAGIC_MOUNT=y" >> "${{ env.DEFCONFIG }}"
  347. echo "CONFIG_KSU_SUSFS_SUS_PATH=y" >> "${{ env.DEFCONFIG }}"
  348. echo "CONFIG_KSU_SUSFS_SUS_MOUNT=y" >> "${{ env.DEFCONFIG }}"
  349. echo "CONFIG_KSU_SUSFS_TRY_UMOUNT=y" >> "${{ env.DEFCONFIG }}"
  350. echo "CONFIG_KSU_SUSFS_AUTO_ADD_SUS_KSU_DEFAULT_MOUNT=y" >> "${{ env.DEFCONFIG }}"
  351. echo "CONFIG_KSU_SUSFS_AUTO_ADD_SUS_BIND_MOUNT=y" >> "${{ env.DEFCONFIG }}"
  352. echo "CONFIG_KSU_SUSFS_AUTO_ADD_TRY_UMOUNT_FOR_BIND_MOUNT=y" >> "${{ env.DEFCONFIG }}"
  353. echo "CONFIG_KSU_SUSFS_SUS_KSTAT=y" >> "${{ env.DEFCONFIG }}"
  354. echo "CONFIG_KSU_SUSFS_SUS_OVERLAYFS=n" >> "${{ env.DEFCONFIG }}"
  355. echo "CONFIG_KSU_SUSFS_SPOOF_UNAME=y" >> "${{ env.DEFCONFIG }}"
  356. echo "CONFIG_KSU_SUSFS_SPOOF_CMDLINE_OR_BOOTCONFIG=y" >> "${{ env.DEFCONFIG }}"
  357. echo "CONFIG_KSU_SUSFS_OPEN_REDIRECT=y" >> "${{ env.DEFCONFIG }}"
  358. echo "CONFIG_KSU_SUSFS_ENABLE_LOG=y" >> "${{ env.DEFCONFIG }}"
  359. echo "CONFIG_KSU_SUSFS_HIDE_KSU_SUSFS_SYMBOLS=y" >> "${{ env.DEFCONFIG }}"
  360. echo "CONFIG_KSU_SUSFS_SUS_SU=n" >> "${{ env.DEFCONFIG }}"
  361. - name: Configure SND
  362. if: true
  363. run: |
  364. cd "$CONFIG"
  365. # Sound Configuration
  366. echo "# Sound Configuration" >> "${{ env.DEFCONFIG }}"
  367. echo "CONFIG_SND=y" >> "${{ env.DEFCONFIG }}"
  368. echo "CONFIG_SND_DRIVERS=y" >> "${{ env.DEFCONFIG }}"
  369. echo "CONFIG_SND_PCM=y" >> "${{ env.DEFCONFIG }}"
  370. echo "CONFIG_SND_TIMER=y" >> "${{ env.DEFCONFIG }}"
  371. echo "CONFIG_SND_DYNAMIC_MINORS=y" >> "${{ env.DEFCONFIG }}"
  372. echo "CONFIG_SND_PROC_FS=y" >> "${{ env.DEFCONFIG }}"
  373. echo "CONFIG_SND_ALOOP=m" >> "${{ env.DEFCONFIG }}"
  374. # Add snd-aloop.ko to modules list
  375. echo "sound/drivers/snd-aloop.ko" >> common/android/gki_aarch64_modules
  376. if [[ -f common/modules.bzl ]]; then
  377. # Insert before the closing bracket of _COMMON_GKI_MODULES_LIST
  378. echo "snd-aloop injection: adding to module list"
  379. sed -i '/_COMMON_GKI_MODULES_LIST = \[/,/^[[:space:]]*\]/{/^[[:space:]]*\]$/i\ "sound/drivers/snd-aloop.ko",
  380. }' common/modules.bzl
  381. # Verify the injection was successful
  382. if grep -q '"sound/drivers/snd-aloop.ko"' common/modules.bzl; then
  383. echo "✓ snd-aloop injection: successfully added to module list"
  384. else
  385. echo "✗ snd-aloop injection: failed to add to module list"
  386. exit 1
  387. fi
  388. fi
  389. # Add symbols to abi_gki_aarch64
  390. #SYMBOL_LIST=common/android/abi_gki_aarch64
  391. #cat Wild_KSU/kernel/export_symbol.txt | awk '{sub("[ \t]+","");print " "$0}' >> $SYMBOL_LIST
  392. # ABI compare bypass per kernel/android version
  393. # Edit each block as needed per version
  394. if [[ "${{ inputs.android_version }}" == "android12" && "${{ inputs.kernel_version }}" == "5.10" ]]; then
  395. sed -i 's/^\s*exit 1$/ echo "Who Cares? Bypassing Now!"/' build/abi/compare_to_symbol_list
  396. elif [[ "${{ inputs.android_version }}" == "android13" && "${{ inputs.kernel_version }}" == "5.10" ]]; then
  397. sed -i 's/^\s*exit 1$/ echo "Who Cares? Bypassing Now!"/' build/kernel/abi/compare_to_symbol_list
  398. elif [[ "${{ inputs.android_version }}" == "android13" && "${{ inputs.kernel_version }}" == "5.15" ]]; then
  399. sed -i 's/^\s*exit 1$/ echo "Who Cares? Bypassing Now!"/' build/kernel/abi/compare_to_symbol_list
  400. elif [[ "${{ inputs.android_version }}" == "android14" && "${{ inputs.kernel_version }}" == "5.15" ]]; then
  401. 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
  402. elif [[ "${{ inputs.android_version }}" == "android14" && "${{ inputs.kernel_version }}" == "6.1" ]]; then
  403. 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
  404. elif [[ "${{ inputs.android_version }}" == "android15" && "${{ inputs.kernel_version }}" == "6.6" ]]; then
  405. 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
  406. fi
  407. - name: Configure Build Optimization
  408. run: |
  409. cd "$CONFIG"
  410. # Build Optimization Configuration
  411. echo "# Build Optimization Configuration" >> "${{ env.DEFCONFIG }}"
  412. echo "CONFIG_LTO_CLANG_THIN=y" >> "${{ env.DEFCONFIG }}"
  413. echo "CONFIG_LTO_CLANG=y" >> "${{ env.DEFCONFIG }}"
  414. echo "CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE=y" >> "${{ env.DEFCONFIG }}"
  415. echo "CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3=n" >> "${{ env.DEFCONFIG }}"
  416. echo "CONFIG_OPTIMIZE_INLINING=y" >> "${{ env.DEFCONFIG }}"
  417. - name: Change Kernel Name
  418. run: |
  419. cd "$CONFIG"
  420. #Add Wild to Kernel Version
  421. sed -i '$s|echo "\$res"|echo "\$res-Wild"|' ./common/scripts/setlocalversion
  422. #Set Kernel Timestamp
  423. 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"}' ./common/scripts/mkcompile_h
  424. if [ -f "build/build.sh" ]; then
  425. #Remove Dirty Flag
  426. sed -i 's/-dirty//' ./common/scripts/setlocalversion
  427. else
  428. #Remove Dirty Flag
  429. sed -i "/stable_scmversion_cmd/s/-maybe-dirty//g" ./build/kernel/kleaf/impl/stamp.bzl
  430. #Remove Abi Exports and Error
  431. rm -rf ./common/android/abi_gki_protected_exports_*
  432. perl -pi -e 's/^\s*"protected_exports_list"\s*:\s*"android\/abi_gki_protected_exports_aarch64",\s*$//;' ./common/BUILD.bazel
  433. fi
  434. - name: Set file name
  435. run: |
  436. ARTIFACT_BASE="${{ inputs.kernel_version }}.$ACTUAL_SUBLEVEL-${{ inputs.android_version }}-${{ inputs.os_patch_level }}-${{ matrix.apply_bypass == 'bypass' && 'Bypass' || 'Normal' }}"
  437. echo "ARTIFACT_BASE=$ARTIFACT_BASE" >> $GITHUB_ENV
  438. echo "FILE_NAME=$ARTIFACT_BASE" >> $GITHUB_ENV
  439. - name: Build
  440. run : |
  441. set -e
  442. set -x
  443. cd "$CONFIG"
  444. echo "Building the kernel..."
  445. if [ -f "build/build.sh" ]; then
  446. LTO=thin BUILD_CONFIG=common/build.config.gki.aarch64 build/build.sh || exit 1
  447. else
  448. tools/bazel build --config=fast --lto=thin //common:kernel_aarch64_dist || exit 1
  449. fi
  450. - name: Prepare AnyKernel3
  451. run: |
  452. # Copy Image from normal build locations
  453. if [ -f "./$CONFIG/out/${{ inputs.android_version }}-${{ inputs.kernel_version }}/dist/Image" ]; then
  454. cp ./$CONFIG/out/${{ inputs.android_version }}-${{ inputs.kernel_version }}/dist/Image AnyKernel3/Image
  455. elif [ -f "./$CONFIG/bazel-bin/common/kernel_aarch64/Image" ]; then
  456. cp ./$CONFIG/bazel-bin/common/kernel_aarch64/Image AnyKernel3/Image
  457. else
  458. echo "Error: Image file not found in any expected location"
  459. exit 1
  460. fi
  461. - name: Copy snd-aloop module for Android 12-13
  462. if: inputs.android_version == 'android12' || inputs.android_version == 'android13'
  463. run: |
  464. mkdir -p AnyKernel3/modules/data/adb/lkm
  465. cp "./$CONFIG/out/${{ inputs.android_version }}-${{ inputs.kernel_version }}/dist/snd-aloop.ko" AnyKernel3/modules/data/adb/lkm/
  466. - name: Copy snd-aloop module for Android 14-15
  467. if: inputs.android_version == 'android14' || inputs.android_version == 'android15'
  468. run: |
  469. mkdir -p AnyKernel3/modules/data/adb/lkm
  470. cp "./$CONFIG/bazel-bin/common/kernel_aarch64/snd-aloop.ko" AnyKernel3/modules/data/adb/lkm/
  471. - name: Search for Kernel Modules
  472. run: |
  473. echo "Searching for kernel modules (.ko files)..."
  474. # Function to scan for modules (search only)
  475. scan_modules() {
  476. local search_dir="$1"
  477. local module_count=0
  478. if [ -d "$search_dir" ]; then
  479. echo "Scanning directory: $search_dir"
  480. # Find all .ko files and report their locations
  481. while IFS= read -r -d '' module_file; do
  482. if [ -f "$module_file" ]; then
  483. module_name=$(basename "$module_file")
  484. echo "Found module: $module_name in $(dirname "$module_file")"
  485. ((module_count++))
  486. fi
  487. done < <(find "$search_dir" -name "*.ko" -type f -print0 2>/dev/null)
  488. fi
  489. return $module_count
  490. }
  491. # Scan common build output directories
  492. total_modules=0
  493. # Scan bazel-bin directory
  494. if scan_modules "./$CONFIG/bazel-bin"; then
  495. total_modules=$((total_modules + $?))
  496. fi
  497. # Scan out directory
  498. if scan_modules "./$CONFIG/out"; then
  499. total_modules=$((total_modules + $?))
  500. fi
  501. # Scan dist directory specifically
  502. if scan_modules "./$CONFIG/out/${{ inputs.android_version }}-${{ inputs.kernel_version }}/dist"; then
  503. total_modules=$((total_modules + $?))
  504. fi
  505. # Look for snd-aloop.ko specifically
  506. echo "Searching specifically for snd-aloop.ko..."
  507. snd_aloop_found=$(find ./$CONFIG -name "snd-aloop.ko" -type f 2>/dev/null | head -1)
  508. if [ -n "$snd_aloop_found" ]; then
  509. echo "Found snd-aloop.ko at: $snd_aloop_found"
  510. else
  511. echo "snd-aloop.ko not found"
  512. fi
  513. echo "Total kernel modules found: $total_modules"
  514. - name: Create Bootimgs Folder and Copy Images for Android 12/13
  515. if: ${{ inputs.android_version == 'android12' || inputs.android_version == 'android13' }}
  516. run: |
  517. mkdir bootimgs
  518. cp ./$CONFIG/out/${{ inputs.android_version }}-${{ inputs.kernel_version }}/dist/Image ./bootimgs
  519. cp ./$CONFIG/out/${{ inputs.android_version }}-${{ inputs.kernel_version }}/dist/Image.lz4 ./bootimgs
  520. cp ./$CONFIG/out/${{ inputs.android_version }}-${{ inputs.kernel_version }}/dist/Image ./${{ env.FILE_NAME }}-Image
  521. cp ./$CONFIG/out/${{ inputs.android_version }}-${{ inputs.kernel_version }}/dist/Image.lz4 ./${{ env.FILE_NAME }}-Image.lz4
  522. # Create gzip of the Image file
  523. gzip -n -k -f -9 ./${{ env.FILE_NAME }}-Image > ./${{ env.FILE_NAME }}-Image.gz
  524. gzip -n -k -f -9 ./bootimgs/Image > ./bootimgs/Image.gz
  525. - name: Create Bootimgs Folder and Copy Images for Android 14/15
  526. if: ${{ inputs.android_version == 'android14' || inputs.android_version == 'android15' }}
  527. run: |
  528. mkdir bootimgs
  529. cp ./$CONFIG/bazel-bin/common/kernel_aarch64/Image ./bootimgs
  530. cp ./$CONFIG/bazel-bin/common/kernel_aarch64/Image.lz4 ./bootimgs
  531. cp ./$CONFIG/bazel-bin/common/kernel_aarch64/Image ./${{ env.FILE_NAME }}-Image
  532. cp ./$CONFIG/bazel-bin/common/kernel_aarch64/Image.lz4 ./${{ env.FILE_NAME }}-Image.lz4
  533. # Create gzip of the Image file
  534. gzip -n -k -f -9 ./${{ env.FILE_NAME }}-Image > ./${{ env.FILE_NAME }}-Image.gz
  535. gzip -n -k -f -9 ./bootimgs/Image > ./bootimgs/Image.gz
  536. - name: Android 12 boot image build script
  537. if: ${{ inputs.android_version == 'android12' }}
  538. run: |
  539. cd bootimgs
  540. GKI_URL=https://dl.google.com/android/gki/gki-certified-boot-android12-5.10-"${{ inputs.os_patch_level }}"_r1.zip
  541. FALLBACK_URL=https://dl.google.com/android/gki/gki-certified-boot-android12-5.10-2023-01_r1.zip
  542. # Check if the GKI URL is available
  543. status=$(curl -sL -w "%{http_code}" "$GKI_URL" -o /dev/null)
  544. if [ "$status" = "200" ]; then
  545. curl -Lo gki-kernel.zip "$GKI_URL"
  546. else
  547. curl -Lo gki-kernel.zip "$FALLBACK_URL"
  548. fi
  549. # Unzip the downloaded kernel and remove the zip
  550. unzip gki-kernel.zip && rm gki-kernel.zip
  551. FULL_PATH=$(pwd)/boot-5.10.img
  552. $UNPACK_BOOTIMG --boot_img="$FULL_PATH"
  553. $MKBOOTIMG --header_version 4 --kernel Image --output boot.img --ramdisk out/ramdisk --os_version 12.0.0 --os_patch_level "${{ inputs.os_patch_level }}"
  554. $AVBTOOL add_hash_footer --partition_name boot --partition_size $((64 * 1024 * 1024)) --image boot.img --algorithm SHA256_RSA2048 --key $BOOT_SIGN_KEY_PATH
  555. cp ./boot.img ../${{ env.FILE_NAME }}-boot.img
  556. $MKBOOTIMG --header_version 4 --kernel Image.gz --output boot-gz.img --ramdisk out/ramdisk --os_version 12.0.0 --os_patch_level "${{ inputs.os_patch_level }}"
  557. $AVBTOOL add_hash_footer --partition_name boot --partition_size $((64 * 1024 * 1024)) --image boot-gz.img --algorithm SHA256_RSA2048 --key $BOOT_SIGN_KEY_PATH
  558. cp ./boot-gz.img ../${{ env.FILE_NAME }}-boot-gz.img
  559. $MKBOOTIMG --header_version 4 --kernel Image.lz4 --output boot-lz4.img --ramdisk out/ramdisk --os_version 12.0.0 --os_patch_level "${{ inputs.os_patch_level }}"
  560. $AVBTOOL add_hash_footer --partition_name boot --partition_size $((64 * 1024 * 1024)) --image boot-lz4.img --algorithm SHA256_RSA2048 --key $BOOT_SIGN_KEY_PATH
  561. cp ./boot-lz4.img ../${{ env.FILE_NAME }}-boot-lz4.img
  562. - name: Android 13/14/15 boot image build script
  563. if: ${{ inputs.android_version == 'android13' || inputs.android_version == 'android14' || inputs.android_version == 'android15' }}
  564. run: |
  565. cd bootimgs
  566. echo "Building boot.img"
  567. $MKBOOTIMG --header_version 4 --kernel Image --output boot.img
  568. $AVBTOOL add_hash_footer --partition_name boot --partition_size $((64 * 1024 * 1024)) --image boot.img --algorithm SHA256_RSA2048 --key $BOOT_SIGN_KEY_PATH
  569. cp ./boot.img ../${{ env.FILE_NAME }}-boot.img
  570. echo "Building boot-gz.img"
  571. $MKBOOTIMG --header_version 4 --kernel Image.gz --output boot-gz.img
  572. $AVBTOOL add_hash_footer --partition_name boot --partition_size $((64 * 1024 * 1024)) --image boot-gz.img --algorithm SHA256_RSA2048 --key $BOOT_SIGN_KEY_PATH
  573. cp ./boot-gz.img ../${{ env.FILE_NAME }}-boot-gz.img
  574. echo "Building boot-lz4.img"
  575. $MKBOOTIMG --header_version 4 --kernel Image.lz4 --output boot-lz4.img
  576. $AVBTOOL add_hash_footer --partition_name boot --partition_size $((64 * 1024 * 1024)) --image boot-lz4.img --algorithm SHA256_RSA2048 --key $BOOT_SIGN_KEY_PATH
  577. cp ./boot-lz4.img ../${{ env.FILE_NAME }}-boot-lz4.img
  578. - name: Upload AnyKernel3 Artifacts
  579. id: upload_ak3
  580. uses: actions/upload-artifact@v4
  581. with:
  582. name: ${{ env.FILE_NAME }}-AnyKernel3
  583. path: |
  584. ./AnyKernel3/**
  585. compression-level: 9
  586. - name: Extra Artifacts
  587. if: ${{ always() }}
  588. id: upload_misc
  589. uses: actions/upload-artifact@v4
  590. with:
  591. name: ${{ env.FILE_NAME }}-Misc
  592. path: |
  593. ${{ env.FILE_NAME }}-Image
  594. ${{ env.FILE_NAME }}-Image.gz
  595. ${{ env.FILE_NAME }}-Image.lz4
  596. ${{ env.FILE_NAME }}-boot.img
  597. ${{ env.FILE_NAME }}-boot-gz.img
  598. ${{ env.FILE_NAME }}-boot-lz4.img
  599. patch-rejects/**
  600. build_summary.md
  601. if-no-files-found: ignore
  602. compression-level: 9
  603. - name: Generate Build Summary
  604. if: ${{ always() }}
  605. run: |
  606. # Create build summary file for inclusion in Misc artifact
  607. echo "# Kernel Build Summary" > build_summary.md
  608. # Add build variant header
  609. echo "## ${{ env.FILE_NAME }}" >> build_summary.md
  610. # Add build info
  611. echo "## Build Information" >> build_summary.md
  612. echo "- **Android Version**: ${{ inputs.android_version }}" >> build_summary.md
  613. echo "- **Kernel Version**: ${{ inputs.kernel_version }}.${{ inputs.sub_level }}" >> build_summary.md
  614. echo "- **BBG**: Installed" >> build_summary.md
  615. echo "- **Bypass Mode**: ${{ matrix.apply_bypass }}" >> build_summary.md
  616. echo "" >> build_summary.md
  617. # Get Wild_KSU commit
  618. if [ -d "$CONFIG/Wild_KSU" ]; then
  619. cd "$CONFIG/Wild_KSU"
  620. WKSU_COMMIT=$(git rev-parse HEAD)
  621. WKSU_URL="https://github.com/WildKernels/Wild_KSU/commit/$WKSU_COMMIT"
  622. echo "- **Wild_KSU**: [$WKSU_COMMIT]($WKSU_URL)" >> "$GITHUB_WORKSPACE/build_summary.md"
  623. cd "$GITHUB_WORKSPACE"
  624. else
  625. echo "- **Wild_KSU**: not present" >> build_summary.md
  626. fi
  627. # Get Baseband-guard commit
  628. if [ -d "$CONFIG/Baseband-guard" ]; then
  629. cd "$CONFIG/Baseband-guard"
  630. BBG_COMMIT=$(git rev-parse HEAD)
  631. BBG_URL="https://github.com/vc-teahouse/Baseband-guard/commit/$BBG_COMMIT"
  632. echo "- **Baseband-guard**: [$BBG_COMMIT]($BBG_URL)" >> "$GITHUB_WORKSPACE/build_summary.md"
  633. cd "$GITHUB_WORKSPACE"
  634. else
  635. echo "- **Baseband-guard**: not present" >> build_summary.md
  636. fi
  637. # Get SUSFS4KSU commit
  638. if [ -d "$GITHUB_WORKSPACE/susfs4ksu" ]; then
  639. cd "$GITHUB_WORKSPACE/susfs4ksu"
  640. SUSFS_COMMIT=$(git rev-parse HEAD)
  641. SUSFS_URL="https://gitlab.com/simonpunk/susfs4ksu/-/commit/$SUSFS_COMMIT"
  642. echo "- **SUSFS4KSU (v1.5.12)**: [$SUSFS_COMMIT]($SUSFS_URL)" >> "$GITHUB_WORKSPACE/build_summary.md"
  643. cd "$GITHUB_WORKSPACE"
  644. else
  645. echo "- **SUSFS4KSU (v1.5.12)**: not present" >> build_summary.md
  646. fi
  647. echo "" >> build_summary.md
  648. # Add artifact summary with presence verification
  649. echo "## Build Artifacts" >> build_summary.md
  650. # Verify AnyKernel3 contents - check if kernel Image was actually copied (indicates successful build)
  651. if [ -d "AnyKernel3" ] && [ -f "AnyKernel3/Image" ]; then
  652. AK3_STATUS="✅"
  653. else
  654. AK3_STATUS="❌"
  655. fi
  656. echo "- **AnyKernel3**: $AK3_STATUS ${{ env.FILE_NAME }}-AnyKernel3" >> build_summary.md
  657. echo "### Misc (uploaded files)" >> build_summary.md
  658. FILES_PRESENT=0
  659. for f in "${{ env.FILE_NAME }}-Image" "${{ env.FILE_NAME }}-Image.gz" "${{ env.FILE_NAME }}-Image.lz4" "${{ env.FILE_NAME }}-boot.img" "${{ env.FILE_NAME }}-boot-gz.img" "${{ env.FILE_NAME }}-boot-lz4.img"; do
  660. if [ -f "$f" ]; then FILES_PRESENT=$((FILES_PRESENT+1)); fi
  661. done
  662. if [ "$FILES_PRESENT" -gt 0 ]; then
  663. MISC_STATUS="✅"
  664. else
  665. MISC_STATUS="❌"
  666. fi
  667. echo "- **Set**: $MISC_STATUS ${{ env.FILE_NAME }}-Misc" >> build_summary.md
  668. if [ "$MISC_STATUS" = "✅" ]; then
  669. echo " Included:" >> build_summary.md
  670. for f in "${{ env.FILE_NAME }}-Image" "${{ env.FILE_NAME }}-Image.gz" "${{ env.FILE_NAME }}-Image.lz4" "${{ env.FILE_NAME }}-boot.img" "${{ env.FILE_NAME }}-boot-gz.img" "${{ env.FILE_NAME }}-boot-lz4.img"; do
  671. if [ -f "$f" ]; then
  672. echo " - $f" >> build_summary.md
  673. fi
  674. done
  675. fi
  676. echo "### Diagnostics" >> build_summary.md
  677. echo "- **Rejected Patches**: ${{ env.FILE_NAME }}-Rejected-Patches" >> build_summary.md
  678. if [ -f patch-rejects/index.txt ]; then
  679. if [ -s patch-rejects/index.txt ]; then
  680. echo " Rejected files:" >> build_summary.md
  681. while IFS= read -r line; do
  682. echo " - $line" >> build_summary.md
  683. done < patch-rejects/index.txt
  684. else
  685. echo " Rejected file list is empty." >> build_summary.md
  686. fi
  687. else
  688. echo " No rejected patches found." >> build_summary.md
  689. fi