build.yml 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795
  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. if grep -q 'sound\/drivers\/snd-aloop.ko' common/modules.bzl; then
  378. echo "snd-aloop already present in common/modules.bzl"
  379. else
  380. # Insert before the closing bracket of _COMMON_GKI_MODULES_LIST
  381. echo "snd-aloop injection: adding to module list"
  382. sed -i '/_COMMON_GKI_MODULES_LIST = \[/,/^[[:space:]]*\]/{/^[[:space:]]*\]$/i\ "sound/drivers/snd-aloop.ko",
  383. }' common/modules.bzl
  384. if grep -q 'sound\/drivers\/snd-aloop.ko' common/modules.bzl; then
  385. echo "Injected snd-aloop into common/modules.bzl"
  386. else
  387. echo "Warning: could not inject snd-aloop into common/modules.bzl" >&2
  388. fi
  389. fi
  390. else
  391. echo "common/modules.bzl not found; skipping snd-aloop injection"
  392. fi
  393. # Add symbols to abi_gki_aarch64
  394. #SYMBOL_LIST=common/android/abi_gki_aarch64
  395. #cat Wild_KSU/kernel/export_symbol.txt | awk '{sub("[ \t]+","");print " "$0}' >> $SYMBOL_LIST
  396. # ABI compare bypass per kernel/android version
  397. # Edit each block as needed per version
  398. if [[ "${{ inputs.android_version }}" == "android12" && "${{ inputs.kernel_version }}" == "5.10" ]]; then
  399. sed -i 's/^\s*exit 1$/ echo "Who Cares? Bypassing Now!"/' build/abi/compare_to_symbol_list
  400. elif [[ "${{ inputs.android_version }}" == "android13" && "${{ inputs.kernel_version }}" == "5.10" ]]; then
  401. sed -i 's/^\s*exit 1$/ echo "Who Cares? Bypassing Now!"/' build/kernel/abi/compare_to_symbol_list
  402. elif [[ "${{ inputs.android_version }}" == "android13" && "${{ inputs.kernel_version }}" == "5.15" ]]; then
  403. sed -i 's/^\s*exit 1$/ echo "Who Cares? Bypassing Now!"/' build/kernel/abi/compare_to_symbol_list
  404. elif [[ "${{ inputs.android_version }}" == "android14" && "${{ inputs.kernel_version }}" == "5.15" ]]; then
  405. sed -i '/if missing_symbols:/,/return 1/ s/return 1$/ print("Who Cares? Bypassing Now!")\n return 0/' build/kernel/abi/check_buildtime_symbol_protection.py
  406. elif [[ "${{ inputs.android_version }}" == "android14" && "${{ inputs.kernel_version }}" == "6.1" ]]; then
  407. sed -i '/if missing_symbols:/,/return 1/ s/return 1$/ print("Who Cares? Bypassing Now!")\n return 0/' build/kernel/abi/check_buildtime_symbol_protection.py
  408. elif [[ "${{ inputs.android_version }}" == "android15" && "${{ inputs.kernel_version }}" == "6.6" ]]; then
  409. sed -i '/if missing_symbols:/,/return 1/ s/return 1$/ print("Who Cares? Bypassing Now!")\n return 0/' build/kernel/abi/check_buildtime_symbol_protection.py
  410. fi
  411. - name: Configure Build Optimization
  412. run: |
  413. cd "$CONFIG"
  414. # Build Optimization Configuration
  415. echo "# Build Optimization Configuration" >> "${{ env.DEFCONFIG }}"
  416. echo "CONFIG_LTO_CLANG_THIN=y" >> "${{ env.DEFCONFIG }}"
  417. echo "CONFIG_LTO_CLANG=y" >> "${{ env.DEFCONFIG }}"
  418. echo "CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE=y" >> "${{ env.DEFCONFIG }}"
  419. echo "CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3=n" >> "${{ env.DEFCONFIG }}"
  420. echo "CONFIG_OPTIMIZE_INLINING=y" >> "${{ env.DEFCONFIG }}"
  421. - name: Change Kernel Name
  422. run: |
  423. cd "$CONFIG"
  424. #Add Wild to Kernel Version
  425. sed -i '$s|echo "\$res"|echo "\$res-Wild"|' ./common/scripts/setlocalversion
  426. #Set Kernel Timestamp
  427. 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
  428. if [ -f "build/build.sh" ]; then
  429. #Remove Dirty Flag
  430. sed -i 's/-dirty//' ./common/scripts/setlocalversion
  431. else
  432. #Remove Dirty Flag
  433. sed -i "/stable_scmversion_cmd/s/-maybe-dirty//g" ./build/kernel/kleaf/impl/stamp.bzl
  434. #Remove Abi Exports and Error
  435. rm -rf ./common/android/abi_gki_protected_exports_*
  436. perl -pi -e 's/^\s*"protected_exports_list"\s*:\s*"android\/abi_gki_protected_exports_aarch64",\s*$//;' ./common/BUILD.bazel
  437. fi
  438. - name: Set file name
  439. run: |
  440. ARTIFACT_BASE="${{ inputs.kernel_version }}.$ACTUAL_SUBLEVEL-${{ inputs.android_version }}-${{ inputs.os_patch_level }}-${{ matrix.apply_bypass == 'bypass' && 'Bypass' || 'Normal' }}"
  441. echo "ARTIFACT_BASE=$ARTIFACT_BASE" >> $GITHUB_ENV
  442. echo "FILE_NAME=$ARTIFACT_BASE" >> $GITHUB_ENV
  443. - name: Build
  444. run : |
  445. set -e
  446. set -x
  447. cd "$CONFIG"
  448. echo "Building the kernel..."
  449. if [ -f "build/build.sh" ]; then
  450. LTO=thin BUILD_CONFIG=common/build.config.gki.aarch64 build/build.sh || exit 1
  451. else
  452. tools/bazel build --config=fast --lto=thin //common:kernel_aarch64_dist || exit 1
  453. fi
  454. - name: Prepare AnyKernel3
  455. run: |
  456. # Copy Image from normal build locations
  457. if [ -f "./$CONFIG/out/${{ inputs.android_version }}-${{ inputs.kernel_version }}/dist/Image" ]; then
  458. cp ./$CONFIG/out/${{ inputs.android_version }}-${{ inputs.kernel_version }}/dist/Image AnyKernel3/Image
  459. elif [ -f "./$CONFIG/bazel-bin/common/kernel_aarch64/Image" ]; then
  460. cp ./$CONFIG/bazel-bin/common/kernel_aarch64/Image AnyKernel3/Image
  461. else
  462. echo "Error: Image file not found in any expected location"
  463. exit 1
  464. fi
  465. - name: Search for Kernel Modules
  466. run: |
  467. echo "Searching for kernel modules (.ko files)..."
  468. # Function to scan for modules (search only)
  469. scan_modules() {
  470. local search_dir="$1"
  471. local module_count=0
  472. if [ -d "$search_dir" ]; then
  473. echo "Scanning directory: $search_dir"
  474. # Find all .ko files and report their locations
  475. while IFS= read -r -d '' module_file; do
  476. if [ -f "$module_file" ]; then
  477. module_name=$(basename "$module_file")
  478. echo "Found module: $module_name in $(dirname "$module_file")"
  479. ((module_count++))
  480. fi
  481. done < <(find "$search_dir" -name "*.ko" -type f -print0 2>/dev/null)
  482. fi
  483. return $module_count
  484. }
  485. # Scan common build output directories
  486. total_modules=0
  487. # Scan bazel-bin directory
  488. if scan_modules "./$CONFIG/bazel-bin"; then
  489. total_modules=$((total_modules + $?))
  490. fi
  491. # Scan out directory
  492. if scan_modules "./$CONFIG/out"; then
  493. total_modules=$((total_modules + $?))
  494. fi
  495. # Scan dist directory specifically
  496. if scan_modules "./$CONFIG/out/${{ inputs.android_version }}-${{ inputs.kernel_version }}/dist"; then
  497. total_modules=$((total_modules + $?))
  498. fi
  499. # Look for snd-aloop.ko specifically
  500. echo "Searching specifically for snd-aloop.ko..."
  501. snd_aloop_found=$(find ./$CONFIG -name "snd-aloop.ko" -type f 2>/dev/null | head -1)
  502. if [ -n "$snd_aloop_found" ]; then
  503. echo "Found snd-aloop.ko at: $snd_aloop_found"
  504. else
  505. echo "snd-aloop.ko not found"
  506. fi
  507. echo "Total kernel modules found: $total_modules"
  508. - name: Create Bootimgs Folder and Copy Images for Android 12/13
  509. if: ${{ inputs.android_version == 'android12' || inputs.android_version == 'android13' }}
  510. run: |
  511. mkdir bootimgs
  512. cp ./$CONFIG/out/${{ inputs.android_version }}-${{ inputs.kernel_version }}/dist/Image ./bootimgs
  513. cp ./$CONFIG/out/${{ inputs.android_version }}-${{ inputs.kernel_version }}/dist/Image.lz4 ./bootimgs
  514. cp ./$CONFIG/out/${{ inputs.android_version }}-${{ inputs.kernel_version }}/dist/Image ./${{ env.FILE_NAME }}-Image
  515. cp ./$CONFIG/out/${{ inputs.android_version }}-${{ inputs.kernel_version }}/dist/Image.lz4 ./${{ env.FILE_NAME }}-Image.lz4
  516. # Create gzip of the Image file
  517. gzip -n -k -f -9 ./${{ env.FILE_NAME }}-Image > ./${{ env.FILE_NAME }}-Image.gz
  518. gzip -n -k -f -9 ./bootimgs/Image > ./bootimgs/Image.gz
  519. - name: Create Bootimgs Folder and Copy Images for Android 14/15
  520. if: ${{ inputs.android_version == 'android14' || inputs.android_version == 'android15' }}
  521. run: |
  522. mkdir bootimgs
  523. cp ./$CONFIG/bazel-bin/common/kernel_aarch64/Image ./bootimgs
  524. cp ./$CONFIG/bazel-bin/common/kernel_aarch64/Image.lz4 ./bootimgs
  525. cp ./$CONFIG/bazel-bin/common/kernel_aarch64/Image ./${{ env.FILE_NAME }}-Image
  526. cp ./$CONFIG/bazel-bin/common/kernel_aarch64/Image.lz4 ./${{ env.FILE_NAME }}-Image.lz4
  527. # Create gzip of the Image file
  528. gzip -n -k -f -9 ./${{ env.FILE_NAME }}-Image > ./${{ env.FILE_NAME }}-Image.gz
  529. gzip -n -k -f -9 ./bootimgs/Image > ./bootimgs/Image.gz
  530. - name: Android 12 boot image build script
  531. if: ${{ inputs.android_version == 'android12' }}
  532. run: |
  533. cd bootimgs
  534. GKI_URL=https://dl.google.com/android/gki/gki-certified-boot-android12-5.10-"${{ inputs.os_patch_level }}"_r1.zip
  535. FALLBACK_URL=https://dl.google.com/android/gki/gki-certified-boot-android12-5.10-2023-01_r1.zip
  536. # Check if the GKI URL is available
  537. status=$(curl -sL -w "%{http_code}" "$GKI_URL" -o /dev/null)
  538. if [ "$status" = "200" ]; then
  539. curl -Lo gki-kernel.zip "$GKI_URL"
  540. else
  541. curl -Lo gki-kernel.zip "$FALLBACK_URL"
  542. fi
  543. # Unzip the downloaded kernel and remove the zip
  544. unzip gki-kernel.zip && rm gki-kernel.zip
  545. FULL_PATH=$(pwd)/boot-5.10.img
  546. $UNPACK_BOOTIMG --boot_img="$FULL_PATH"
  547. $MKBOOTIMG --header_version 4 --kernel Image --output boot.img --ramdisk out/ramdisk --os_version 12.0.0 --os_patch_level "${{ inputs.os_patch_level }}"
  548. $AVBTOOL add_hash_footer --partition_name boot --partition_size $((64 * 1024 * 1024)) --image boot.img --algorithm SHA256_RSA2048 --key $BOOT_SIGN_KEY_PATH
  549. cp ./boot.img ../${{ env.FILE_NAME }}-boot.img
  550. $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 }}"
  551. $AVBTOOL add_hash_footer --partition_name boot --partition_size $((64 * 1024 * 1024)) --image boot-gz.img --algorithm SHA256_RSA2048 --key $BOOT_SIGN_KEY_PATH
  552. cp ./boot-gz.img ../${{ env.FILE_NAME }}-boot-gz.img
  553. $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 }}"
  554. $AVBTOOL add_hash_footer --partition_name boot --partition_size $((64 * 1024 * 1024)) --image boot-lz4.img --algorithm SHA256_RSA2048 --key $BOOT_SIGN_KEY_PATH
  555. cp ./boot-lz4.img ../${{ env.FILE_NAME }}-boot-lz4.img
  556. - name: Android 13/14/15 boot image build script
  557. if: ${{ inputs.android_version == 'android13' || inputs.android_version == 'android14' || inputs.android_version == 'android15' }}
  558. run: |
  559. cd bootimgs
  560. echo "Building boot.img"
  561. $MKBOOTIMG --header_version 4 --kernel Image --output boot.img
  562. $AVBTOOL add_hash_footer --partition_name boot --partition_size $((64 * 1024 * 1024)) --image boot.img --algorithm SHA256_RSA2048 --key $BOOT_SIGN_KEY_PATH
  563. cp ./boot.img ../${{ env.FILE_NAME }}-boot.img
  564. echo "Building boot-gz.img"
  565. $MKBOOTIMG --header_version 4 --kernel Image.gz --output boot-gz.img
  566. $AVBTOOL add_hash_footer --partition_name boot --partition_size $((64 * 1024 * 1024)) --image boot-gz.img --algorithm SHA256_RSA2048 --key $BOOT_SIGN_KEY_PATH
  567. cp ./boot-gz.img ../${{ env.FILE_NAME }}-boot-gz.img
  568. echo "Building boot-lz4.img"
  569. $MKBOOTIMG --header_version 4 --kernel Image.lz4 --output boot-lz4.img
  570. $AVBTOOL add_hash_footer --partition_name boot --partition_size $((64 * 1024 * 1024)) --image boot-lz4.img --algorithm SHA256_RSA2048 --key $BOOT_SIGN_KEY_PATH
  571. cp ./boot-lz4.img ../${{ env.FILE_NAME }}-boot-lz4.img
  572. - name: Upload AnyKernel3 Artifacts
  573. id: upload_ak3
  574. uses: actions/upload-artifact@v4
  575. with:
  576. name: ${{ env.FILE_NAME }}-AnyKernel3
  577. path: |
  578. ./AnyKernel3/**
  579. compression-level: 9
  580. - name: Extra Artifacts
  581. if: ${{ always() }}
  582. id: upload_misc
  583. uses: actions/upload-artifact@v4
  584. with:
  585. name: ${{ env.FILE_NAME }}-Misc
  586. path: |
  587. ${{ env.FILE_NAME }}-Image
  588. ${{ env.FILE_NAME }}-Image.gz
  589. ${{ env.FILE_NAME }}-Image.lz4
  590. ${{ env.FILE_NAME }}-boot.img
  591. ${{ env.FILE_NAME }}-boot-gz.img
  592. ${{ env.FILE_NAME }}-boot-lz4.img
  593. patch-rejects/**
  594. build_summary.md
  595. if-no-files-found: ignore
  596. compression-level: 9
  597. - name: Generate Build Summary
  598. if: ${{ always() }}
  599. run: |
  600. # Create build summary file for inclusion in Misc artifact
  601. echo "# Kernel Build Summary" > build_summary.md
  602. # Add build variant header
  603. echo "## ${{ env.FILE_NAME }}" >> build_summary.md
  604. # Add build info
  605. echo "## Build Information" >> build_summary.md
  606. echo "- **Android Version**: ${{ inputs.android_version }}" >> build_summary.md
  607. echo "- **Kernel Version**: ${{ inputs.kernel_version }}.${{ inputs.sub_level }}" >> build_summary.md
  608. echo "- **BBG**: Installed" >> build_summary.md
  609. echo "- **Bypass Mode**: ${{ matrix.apply_bypass }}" >> build_summary.md
  610. echo "" >> build_summary.md
  611. # Get Wild_KSU commit
  612. if [ -d "$CONFIG/Wild_KSU" ]; then
  613. cd "$CONFIG/Wild_KSU"
  614. WKSU_COMMIT=$(git rev-parse HEAD)
  615. WKSU_URL="https://github.com/WildKernels/Wild_KSU/commit/$WKSU_COMMIT"
  616. echo "- **Wild_KSU**: [$WKSU_COMMIT]($WKSU_URL)" >> "$GITHUB_WORKSPACE/build_summary.md"
  617. cd "$GITHUB_WORKSPACE"
  618. else
  619. echo "- **Wild_KSU**: not present" >> build_summary.md
  620. fi
  621. # Get Baseband-guard commit
  622. if [ -d "$CONFIG/Baseband-guard" ]; then
  623. cd "$CONFIG/Baseband-guard"
  624. BBG_COMMIT=$(git rev-parse HEAD)
  625. BBG_URL="https://github.com/vc-teahouse/Baseband-guard/commit/$BBG_COMMIT"
  626. echo "- **Baseband-guard**: [$BBG_COMMIT]($BBG_URL)" >> "$GITHUB_WORKSPACE/build_summary.md"
  627. cd "$GITHUB_WORKSPACE"
  628. else
  629. echo "- **Baseband-guard**: not present" >> build_summary.md
  630. fi
  631. # Get SUSFS4KSU commit
  632. if [ -d "$GITHUB_WORKSPACE/susfs4ksu" ]; then
  633. cd "$GITHUB_WORKSPACE/susfs4ksu"
  634. SUSFS_COMMIT=$(git rev-parse HEAD)
  635. SUSFS_URL="https://gitlab.com/simonpunk/susfs4ksu/-/commit/$SUSFS_COMMIT"
  636. echo "- **SUSFS4KSU (v1.5.12)**: [$SUSFS_COMMIT]($SUSFS_URL)" >> "$GITHUB_WORKSPACE/build_summary.md"
  637. cd "$GITHUB_WORKSPACE"
  638. else
  639. echo "- **SUSFS4KSU (v1.5.12)**: not present" >> build_summary.md
  640. fi
  641. echo "" >> build_summary.md
  642. # Add artifact summary with presence verification
  643. echo "## Build Artifacts" >> build_summary.md
  644. # Verify AnyKernel3 contents - check if kernel Image was actually copied (indicates successful build)
  645. if [ -d "AnyKernel3" ] && [ -f "AnyKernel3/Image" ]; then
  646. AK3_STATUS="✅"
  647. else
  648. AK3_STATUS="❌"
  649. fi
  650. echo "- **AnyKernel3**: $AK3_STATUS ${{ env.FILE_NAME }}-AnyKernel3" >> build_summary.md
  651. echo "### Misc (uploaded files)" >> build_summary.md
  652. FILES_PRESENT=0
  653. 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
  654. if [ -f "$f" ]; then FILES_PRESENT=$((FILES_PRESENT+1)); fi
  655. done
  656. if [ "$FILES_PRESENT" -gt 0 ]; then
  657. MISC_STATUS="✅"
  658. else
  659. MISC_STATUS="❌"
  660. fi
  661. echo "- **Set**: $MISC_STATUS ${{ env.FILE_NAME }}-Misc" >> build_summary.md
  662. if [ "$MISC_STATUS" = "✅" ]; then
  663. echo " Included:" >> build_summary.md
  664. 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
  665. if [ -f "$f" ]; then
  666. echo " - $f" >> build_summary.md
  667. fi
  668. done
  669. fi
  670. echo "### Diagnostics" >> build_summary.md
  671. echo "- **Rejected Patches**: ${{ env.FILE_NAME }}-Rejected-Patches" >> build_summary.md
  672. if [ -f patch-rejects/index.txt ]; then
  673. if [ -s patch-rejects/index.txt ]; then
  674. echo " Rejected files:" >> build_summary.md
  675. while IFS= read -r line; do
  676. echo " - $line" >> build_summary.md
  677. done < patch-rejects/index.txt
  678. else
  679. echo " Rejected file list is empty." >> build_summary.md
  680. fi
  681. else
  682. echo " No rejected patches found." >> build_summary.md
  683. fi