build.yml 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602
  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. variant:
  21. required: false
  22. type: string
  23. ksu_commit:
  24. required: false
  25. type: string
  26. feature_set:
  27. required: true
  28. type: string
  29. build_bypass:
  30. required: true
  31. type: boolean
  32. jobs:
  33. build-gki:
  34. name: "${{ inputs.kernel_version }}.${{ inputs.sub_level }}-${{ inputs.android_version }}-${{ inputs.os_patch_level }}-${{ matrix.build_type }}"
  35. runs-on: ubuntu-latest
  36. timeout-minutes: 60
  37. strategy:
  38. fail-fast: false
  39. matrix:
  40. build_type: >-
  41. ${{
  42. fromJSON(
  43. inputs.variant == 'vTomsonek' && '["vTomsonek"]' ||
  44. inputs.variant == 'TheWildJames' && '["TheWildJames"]' ||
  45. inputs.variant == 'MarionKernel' && '["MarionKernel"]' ||
  46. inputs.variant == 'Hakan' && '["Hakan"]' ||
  47. inputs.variant == 'Neyugn' && '["Neyugn"]' ||
  48. (inputs.build_bypass && '["Normal","Bypass"]' || '["Normal"]')
  49. )
  50. }}
  51. steps:
  52. - name: Checkout Repository
  53. uses: actions/checkout@v4
  54. - name: Free Disk Space
  55. if: true
  56. uses: endersonmenezes/free-disk-space@v3 # Use @main for latest, @v3 for stable
  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" # Use 'rmz' for faster deletion (default: 'rm')
  67. rmz_version: "3.1.1" # Required when rm_cmd is 'rmz'
  68. testing: false
  69. - name: Download AnyKernel3 Artifact
  70. uses: actions/download-artifact@v4
  71. with:
  72. name: anykernel3
  73. path: AnyKernel3
  74. - name: Download Kernel Patches Artifact
  75. uses: actions/download-artifact@v4
  76. with:
  77. name: kernel-patches
  78. path: kernel_patches
  79. - name: Download Git Repo Tool Artifact
  80. uses: actions/download-artifact@v4
  81. with:
  82. name: git-repo-tool
  83. path: git-repo
  84. - name: Setup Build Environment
  85. run: |
  86. CONFIG="${{ inputs.android_version }}-${{ inputs.kernel_version }}-${{ inputs.sub_level }}"
  87. KERNEL_ROOT="$GITHUB_WORKSPACE/$CONFIG"
  88. mkdir -p "$KERNEL_ROOT"
  89. cat >> $GITHUB_ENV << EOF
  90. DEFCONFIG=$KERNEL_ROOT/common/arch/arm64/configs/gki_defconfig
  91. DEFCONFIG_FRAGMENT=$KERNEL_ROOT/common/arch/arm64/configs/wild_gki.fragment
  92. CONFIG=$CONFIG
  93. KERNEL_ROOT=$KERNEL_ROOT
  94. SUSFS4KSU=$GITHUB_WORKSPACE/susfs4ksu
  95. KERNEL_PATCHES=$GITHUB_WORKSPACE/kernel_patches
  96. ANYKERNEL3=$GITHUB_WORKSPACE/AnyKernel3
  97. REPO=$GITHUB_WORKSPACE/git-repo/repo
  98. EOF
  99. # Ensure repo tool is executable
  100. chmod +x "$GITHUB_WORKSPACE/git-repo/repo"
  101. echo "$GITHUB_WORKSPACE/git-repo" >> "$GITHUB_PATH"
  102. - name: Dependency Summary
  103. run: |
  104. echo "========================================"
  105. echo " Downloaded Dependencies Ready "
  106. echo "========================================"
  107. echo "AnyKernel3 : ✓ $(ls -d AnyKernel3 2>/dev/null && echo 'Ready' || echo 'Missing')"
  108. echo "Kernel Patches : ✓ $(ls -d kernel_patches 2>/dev/null && echo 'Ready' || echo 'Missing')"
  109. echo "Git Repo Tool : ✓ $(ls git-repo/repo 2>/dev/null && echo 'Ready' || echo 'Missing')"
  110. echo "========================================"
  111. - name: Download Kernel Repository
  112. uses: ./.github/actions/download-kernel
  113. with:
  114. android_version: ${{ inputs.android_version }}
  115. kernel_version: ${{ inputs.kernel_version }}
  116. sub_level: ${{ inputs.sub_level }}
  117. os_patch_level: ${{ inputs.os_patch_level }}
  118. kernel_root: ${{ env.KERNEL_ROOT }}
  119. - name: Extract Sublevel and Set File Name
  120. run: |
  121. SUBLEVEL="${{ inputs.sub_level }}"
  122. if [[ -f "$KERNEL_ROOT/common/Makefile" ]]; then
  123. EXTRACTED=$(grep '^SUBLEVEL = ' "$KERNEL_ROOT/common/Makefile" | awk '{print $3}')
  124. [[ -n "$EXTRACTED" ]] && SUBLEVEL="$EXTRACTED"
  125. fi
  126. ARTIFACT_BASE="${{ inputs.kernel_version }}.$SUBLEVEL-${{ inputs.android_version }}-${{ inputs.os_patch_level }}-${{ matrix.build_type }}"
  127. echo "SUBLEVEL=$SUBLEVEL" >> $GITHUB_ENV
  128. echo "ARTIFACT_BASE=$ARTIFACT_BASE" >> $GITHUB_ENV
  129. echo "FILE_NAME=$ARTIFACT_BASE" >> $GITHUB_ENV
  130. - name: Apply glibc 2.38 Compatibility Fix
  131. if: false
  132. run: |
  133. # Use SUBLEVEL for LTS builds, otherwise use the input sub_level
  134. if [[ "${{ inputs.android_version }}" == "android13" && "${{ inputs.kernel_version }}" == "5.10" && $SUBLEVEL -le 186 ]] ||
  135. [[ "${{ inputs.android_version }}" == "android13" && "${{ inputs.kernel_version }}" == "5.15" && $SUBLEVEL -le 119 ]] ||
  136. [[ "${{ inputs.android_version }}" == "android14" && "${{ inputs.kernel_version }}" == "5.15" && $SUBLEVEL -le 110 ]] ||
  137. [[ "${{ inputs.android_version }}" == "android14" && "${{ inputs.kernel_version }}" == "6.1" && $SUBLEVEL -le 43 ]]; then
  138. GLIBC_VERSION=$(ldd --version 2>/dev/null | head -n 1 | awk '{print $NF}')
  139. if [ "$(printf '%s\n' "2.38" "$GLIBC_VERSION" | sort -V | head -n1)" = "2.38" ]; then
  140. cd "$KERNEL_ROOT/common"
  141. 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
  142. if [[ "${{ inputs.android_version }}" == "android13" && "${{ inputs.kernel_version }}" == "5.10" && $SUBLEVEL -le 186 ]] ||
  143. [[ "${{ inputs.android_version }}" == "android13" && "${{ inputs.kernel_version }}" == "5.15" && $SUBLEVEL -le 119 ]] ||
  144. [[ "${{ inputs.android_version }}" == "android14" && "${{ inputs.kernel_version }}" == "5.15" && $SUBLEVEL -le 110 ]]; then
  145. sed -i '/char \*buf = NULL;/a int i;' tools/lib/subcmd/parse-options.c 2>/dev/null || true
  146. 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
  147. sed -i '/if (subcommands) {/a int i;' tools/lib/subcmd/parse-options.c 2>/dev/null || true
  148. 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
  149. fi
  150. fi
  151. fi
  152. - name: Fix Less Than 6.6.50 Builds
  153. if: inputs.android_version == 'android15' && inputs.kernel_version == '6.6'
  154. working-directory: ${{ env.KERNEL_ROOT }}/common
  155. run: |
  156. if ! grep -qxF '#include <trace/hooks/fs.h>' ./fs/namespace.c; then
  157. sed -i '/#include <trace\/hooks\/blk.h>/a #include <trace\/hooks\/fs.h>' ./fs/namespace.c
  158. fi
  159. - name: Setup Wild KSU
  160. if: contains(inputs.feature_set, 'WKSU')
  161. uses: ./.github/actions/setup-wksu
  162. with:
  163. ksu_commit: ${{ inputs.ksu_commit }}
  164. kernel_root: ${{ env.KERNEL_ROOT }}
  165. - name: Download SUSFS Cache Artifact
  166. if: contains(inputs.feature_set, 'SUSFS')
  167. uses: actions/download-artifact@v4
  168. with:
  169. name: susfs-cache
  170. path: susfs_cache
  171. - name: Setup SUSFS
  172. if: contains(inputs.feature_set, 'SUSFS')
  173. uses: ./.github/actions/setup-susfs
  174. with:
  175. android_version: ${{ inputs.android_version }}
  176. kernel_version: ${{ inputs.kernel_version }}
  177. os_patch_level: ${{ inputs.os_patch_level }}
  178. sublevel: ${{ env.SUBLEVEL }}
  179. kernel_root: ${{ env.KERNEL_ROOT }}
  180. kernel_patches: ${{ env.KERNEL_PATCHES }}
  181. susfs4ksu: ${{ env.SUSFS4KSU }}
  182. - name: Setup Baseband Guard
  183. if: contains(inputs.feature_set, 'BBG')
  184. uses: ./.github/actions/setup-bbg
  185. with:
  186. kernel_root: ${{ env.KERNEL_ROOT }}
  187. defconfig_fragment: ${{ env.DEFCONFIG_FRAGMENT }}
  188. - name: Apply Module Check Bypass
  189. if: ${{ matrix.build_type == 'Bypass' || matrix.build_type == 'Hakan' }}
  190. run: |
  191. if [[ "${{ inputs.kernel_version }}" == "6.1" || "${{ inputs.kernel_version }}" == "6.6" || "${{ inputs.kernel_version }}" == "6.12" ]]; then
  192. TARGET_FILE="$KERNEL_ROOT/common/kernel/module/version.c"
  193. else
  194. TARGET_FILE="$KERNEL_ROOT/common/kernel/module.c"
  195. fi
  196. echo "Applying bypass to $TARGET_FILE"
  197. sed -i '/bad_version:/{:a;n;/return 0;/{s/return 0;/return 1;/;b};ba}' "$TARGET_FILE"
  198. # Verify the bypass
  199. if grep -A 5 "bad_version:" "$TARGET_FILE" | grep -q "return 1;"; then
  200. echo "SUCCESS: Module check bypass verified in $TARGET_FILE"
  201. else
  202. echo "FAILED: Module check bypass not found in $TARGET_FILE"
  203. grep -A 5 "bad_version:" "$TARGET_FILE" || true
  204. exit 1
  205. fi
  206. - name: Fix WiFi and Bluetooth on Samsung 6.6 GKI devices
  207. if: ${{ inputs.kernel_version == '6.6' }}
  208. working-directory: ${{ env.KERNEL_ROOT }}/common
  209. run: |
  210. SYMBOL_LIST=android/abi_gki_aarch64_galaxy
  211. echo "kdp_set_cred_non_rcu" >> $SYMBOL_LIST
  212. echo "kdp_usecount_dec_and_test" >> $SYMBOL_LIST
  213. echo "kdp_usecount_inc" >> $SYMBOL_LIST
  214. PATCH="$KERNEL_PATCHES/samsung/min_kdp/add-min_kdp-symbols.patch"
  215. if patch -p1 --dry-run < "$PATCH"; then
  216. patch -p1 --no-backup-if-mismatch < $PATCH
  217. fi
  218. cp "$KERNEL_PATCHES/samsung/min_kdp/min_kdp.c" drivers/min_kdp.c
  219. echo "obj-y += min_kdp.o" >> drivers/Makefile
  220. - name: Fix WiFi and Bluetooth on Xiaomi 6.6 GKI devices
  221. if: ${{ ( inputs.kernel_version == '6.6' ) }}
  222. working-directory: ${{ env.KERNEL_ROOT }}/common
  223. run: |
  224. SYMBOL_LIST=android/abi_gki_aarch64_xiaomi
  225. echo "device_find_any_child" >> $SYMBOL_LIST
  226. - name: Configure Kernel Options
  227. working-directory: ${{ env.KERNEL_ROOT }}
  228. run: |
  229. cat >> "${{ env.DEFCONFIG_FRAGMENT }}" << 'EOF'
  230. # KernelSU Configuration
  231. CONFIG_KSU=y
  232. CONFIG_KSU_SUSFS=y
  233. # KPatch Next Support
  234. CONFIG_KALLSYMS=y
  235. CONFIG_KALLSYMS_ALL=y
  236. # Mountify Support
  237. CONFIG_TMPFS_XATTR=y
  238. CONFIG_TMPFS_POSIX_ACL=y
  239. EOF
  240. # Networking Configuration
  241. #CONFIG_IP_NF_TARGET_TTL=y
  242. #CONFIG_IP6_NF_TARGET_HL=y
  243. #CONFIG_IP6_NF_MATCH_HL=y
  244. # BBR TCP Congestion Control
  245. #CONFIG_TCP_CONG_ADVANCED=y
  246. #CONFIG_TCP_CONG_BBR=y
  247. #CONFIG_NET_SCH_FQ=y
  248. ## CONFIG_TCP_CONG_BIC is not set
  249. ## CONFIG_TCP_CONG_WESTWOOD is not set
  250. ## CONFIG_TCP_CONG_HTCP is not set
  251. # IPSet Support
  252. #CONFIG_IP_SET=y
  253. #CONFIG_IP_SET_MAX=65534
  254. #CONFIG_IP_SET_BITMAP_IP=y
  255. #CONFIG_IP_SET_BITMAP_IPMAC=y
  256. #CONFIG_IP_SET_BITMAP_PORT=y
  257. #CONFIG_IP_SET_HASH_IP=y
  258. #CONFIG_IP_SET_HASH_IPMARK=y
  259. #CONFIG_IP_SET_HASH_IPPORT=y
  260. #CONFIG_IP_SET_HASH_IPPORTIP=y
  261. #CONFIG_IP_SET_HASH_IPPORTNET=y
  262. #CONFIG_IP_SET_HASH_IPMAC=y
  263. #CONFIG_IP_SET_HASH_MAC=y
  264. #CONFIG_IP_SET_HASH_NETPORTNET=y
  265. #CONFIG_IP_SET_HASH_NET=y
  266. #CONFIG_IP_SET_HASH_NETNET=y
  267. #CONFIG_IP_SET_HASH_NETPORT=y
  268. #CONFIG_IP_SET_HASH_NETIFACE=y
  269. #CONFIG_IP_SET_LIST_SET=y
  270. echo "Contents of ${{ env.DEFCONFIG_FRAGMENT }}:"
  271. cat "${{ env.DEFCONFIG_FRAGMENT }}"
  272. - name: Configure Audio Modules
  273. if: inputs.variant == 'Hakan'
  274. working-directory: ${{ env.KERNEL_ROOT }}
  275. run: |
  276. cat >> "${{ env.DEFCONFIG_FRAGMENT }}" << 'EOF'
  277. CONFIG_RFKILL=y
  278. CONFIG_CFG80211=y
  279. CONFIG_MAC80211=y
  280. EOF
  281. sed -i \
  282. -e '/_COMMON_GKI_MODULES_LIST = \[/,/^[[:space:]]*\]/{/^[[:space:]]*"lib\/crypto\/libarc4\.ko",[[:space:]]*$/d}' \
  283. -e '/_COMMON_GKI_MODULES_LIST = \[/,/^[[:space:]]*\]/{/^[[:space:]]*"net\/rfkill\/rfkill\.ko",[[:space:]]*$/d}' \
  284. common/modules.bzl
  285. - name: Configure SND
  286. if: inputs.variant == 'vTomsonek'
  287. working-directory: ${{ env.KERNEL_ROOT }}
  288. run: |
  289. cat >> "${{ env.DEFCONFIG_FRAGMENT }}" << 'EOF'
  290. # Sound Configuration
  291. CONFIG_SND=y
  292. CONFIG_SND_DRIVERS=y
  293. CONFIG_SND_PCM=y
  294. CONFIG_SND_TIMER=y
  295. CONFIG_SND_DYNAMIC_MINORS=y
  296. CONFIG_SND_PROC_FS=y
  297. CONFIG_SND_ALOOP=m
  298. CONFIG_USB_GADGET=y
  299. CONFIG_CONFIGFS_FS=y
  300. CONFIG_USB_CONFIGFS=y
  301. CONFIG_USB_LIBCOMPOSITE=m
  302. CONFIG_USB_AUDIO=m
  303. CONFIG_USB_CONFIGFS_F_UAC1=y
  304. CONFIG_USB_CONFIGFS_F_UAC2=y
  305. EOF
  306. # Add snd-aloop.ko to modules list
  307. echo "drivers/usb/gadget/legacy/g_audio.ko" >> common/android/gki_aarch64_modules
  308. echo "sound/drivers/snd-aloop.ko" >> common/android/gki_aarch64_modules
  309. #echo "drivers/usb/gadget/libcomposite.ko" >> common/android/gki_aarch64_modules
  310. if [[ -f common/modules.bzl ]]; then
  311. # Insert before the closing bracket of COMMON_GKI_MODULES_LIST or _COMMON_GKI_MODULES_LIST
  312. echo "Audio modules injection: adding to module list"
  313. if [[ "${{ inputs.android_version }}" == "android14" && "${{ inputs.kernel_version }}" == "5.15" && $SUBLEVEL -le 110 && "${{ inputs.os_patch_level }}" != "2023-09" ]] \
  314. || [[ "${{ inputs.android_version }}" == "android14" && "${{ inputs.kernel_version }}" == "6.1" && $SUBLEVEL -le 25 && "${{ inputs.os_patch_level }}" != "2023-09" ]]; then
  315. # snd-aloop
  316. sed -i '/COMMON_GKI_MODULES_LIST = \[/,/^[[:space:]]*\]/{/^[[:space:]]*\]$/i\ "sound/drivers/snd-aloop.ko",
  317. }' common/modules.bzl
  318. # USB Gadget Audio modules
  319. sed -i '/COMMON_GKI_MODULES_LIST = \[/,/^[[:space:]]*\]/{/^[[:space:]]*\]$/i\ "drivers/usb/gadget/libcomposite.ko",
  320. }' common/modules.bzl
  321. sed -i '/COMMON_GKI_MODULES_LIST = \[/,/^[[:space:]]*\]/{/^[[:space:]]*\]$/i\ "drivers/usb/gadget/legacy/g_audio.ko",
  322. }' common/modules.bzl
  323. else
  324. # snd-aloop
  325. sed -i '/_COMMON_GKI_MODULES_LIST = \[/,/^[[:space:]]*\]/{/^[[:space:]]*\]$/i\ "sound/drivers/snd-aloop.ko",
  326. }' common/modules.bzl
  327. # USB Gadget Audio modules
  328. sed -i '/_COMMON_GKI_MODULES_LIST = \[/,/^[[:space:]]*\]/{/^[[:space:]]*\]$/i\ "drivers/usb/gadget/libcomposite.ko",
  329. }' common/modules.bzl
  330. sed -i '/_COMMON_GKI_MODULES_LIST = \[/,/^[[:space:]]*\]/{/^[[:space:]]*\]$/i\ "drivers/usb/gadget/legacy/g_audio.ko",
  331. }' common/modules.bzl
  332. fi
  333. # Verify the injection was successful
  334. if grep -q '"sound/drivers/snd-aloop.ko"' common/modules.bzl && \
  335. grep -q '"drivers/usb/gadget/libcomposite.ko"' common/modules.bzl && \
  336. grep -q '"drivers/usb/gadget/legacy/g_audio.ko"' common/modules.bzl && \
  337. grep -q '"drivers/usb/gadget/configfs.ko"' common/modules.bzl; then
  338. echo "✓ Audio modules injection: successfully added all modules to list"
  339. else
  340. echo "✗ Audio modules injection: failed to add one or more modules"
  341. exit 1
  342. fi
  343. fi
  344. # Add symbols to abi_gki_aarch64
  345. #SYMBOL_LIST=common/android/abi_gki_aarch64
  346. #cat Wild_KSU/kernel/export_symbol.txt | awk '{sub("[ \t]+","");print " "$0}' >> $SYMBOL_LIST
  347. # ABI compare bypass per kernel/android version
  348. # Edit each block as needed per version
  349. if [[ "${{ inputs.android_version }}" == "android12" && "${{ inputs.kernel_version }}" == "5.10" ]]; then
  350. sed -i 's/^\s*exit 1$/ echo "Who Cares? Bypassing Now!"/' build/abi/compare_to_symbol_list
  351. elif [[ "${{ inputs.android_version }}" == "android13" && "${{ inputs.kernel_version }}" == "5.10" ]]; then
  352. sed -i 's/^\s*exit 1$/ echo "Who Cares? Bypassing Now!"/' build/kernel/abi/compare_to_symbol_list
  353. elif [[ "${{ inputs.android_version }}" == "android13" && "${{ inputs.kernel_version }}" == "5.15" ]]; then
  354. sed -i 's/^\s*exit 1$/ echo "Who Cares? Bypassing Now!"/' build/kernel/abi/compare_to_symbol_list
  355. elif [[ "${{ inputs.android_version }}" == "android14" && "${{ inputs.kernel_version }}" == "5.15" ]]; then
  356. 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
  357. elif [[ "${{ inputs.android_version }}" == "android14" && "${{ inputs.kernel_version }}" == "6.1" ]]; then
  358. 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
  359. elif [[ "${{ inputs.android_version }}" == "android15" && "${{ inputs.kernel_version }}" == "6.6" ]]; then
  360. 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
  361. fi
  362. - name: Append ashmem exports if missing
  363. if: ${{ inputs.android_version == 'android16' && inputs.kernel_version == '6.12' && false }}
  364. working-directory: ${{ env.KERNEL_ROOT }}
  365. run: |
  366. FILE=common/drivers/staging/android/ashmem.c
  367. if [[ -f "$FILE" ]] && ! grep -q 'is_ashmem_file' "$FILE"; then
  368. cat >>"$FILE" <<'EOF'
  369. bool is_ashmem_file(struct file *file) { return false; }
  370. int ashmem_area_name(struct file *file, char *name) { return 0; }
  371. long ashmem_area_size(struct file *file) { return 0; }
  372. struct file *ashmem_area_vmfile(struct file *file) { return NULL; }
  373. EXPORT_SYMBOL_GPL(is_ashmem_file);
  374. EXPORT_SYMBOL_GPL(ashmem_area_name);
  375. EXPORT_SYMBOL_GPL(ashmem_area_size);
  376. EXPORT_SYMBOL_GPL(ashmem_area_vmfile);
  377. EOF
  378. fi
  379. if [ -f common/drivers/android/binder/Makefile ]; then
  380. perl -i -0777 -pe 's/\$\(\s*CONFIG_ANDROID_BINDER_IPC_RUST\s*\)/m/' common/drivers/android/binder/Makefile
  381. #perl -i -ne 'print unless /CONFIG_ANDROID_BINDER_IPC_RUST_DUMMY/' common/drivers/android/binder/Makefile
  382. perl -i -pe 's/^rust_binder-\$\([^)]+\)\s*:=/rust_binder-y :=/' common/drivers/android/binder/Makefile
  383. cat common/drivers/android/Makefile
  384. cat common/drivers/android/binder/Makefile
  385. #perl -ni -e 'print unless /rust_toolchain\s*=\s*"\/\/build\/rust:linux_kernel_toolchain",/' common/BUILD.bazel
  386. #cat common/BUILD.bazel
  387. rustup set profile minimal
  388. rustup update nightly
  389. rustup default nightly
  390. rustup target add aarch64-unknown-none
  391. else
  392. perl -i -0777 -pe 's/\$\(\s*CONFIG_ANDROID_BINDER_IPC_RUST\s*\)/m/' common/drivers/android/Makefile
  393. cat common/drivers/android/Makefile
  394. fi
  395. - name: Change Kernel Name
  396. working-directory: ${{ env.KERNEL_ROOT }}
  397. run: |
  398. #Wild to Kernel Version (replace last instance only)
  399. if [[ "${{ inputs.kernel_version }}" == "5."* ]] || [[ "${{ inputs.kernel_version }}" == "6.1" ]]; then
  400. case ${{ matrix.build_type }} in
  401. MarionKernel)
  402. perl -i -0777 -pe 's/(.*)echo "\$res"/$1echo "\$res-Wild-MarionKernel"/s' ./common/scripts/setlocalversion
  403. ;;
  404. Hakan)
  405. perl -i -0777 -pe 's/(.*)echo "\$res"/$1echo "\$res-Wild-Hakan"/s' ./common/scripts/setlocalversion
  406. ;;
  407. *)
  408. perl -i -0777 -pe 's/(.*)echo "\$res"/$1echo "\$res-Wild"/s' ./common/scripts/setlocalversion
  409. ;;
  410. esac
  411. else
  412. perl -i -0777 -pe 's/(.*)echo "\$\{KERNELVERSION\}\$\{file_localversion\}\$\{config_localversion\}\$\{LOCALVERSION\}\$\{scm_version\}"/$1echo "\${KERNELVERSION}\${file_localversion}\${config_localversion}\${LOCALVERSION}-Wild\${scm_version}"/s' ./common/scripts/setlocalversion
  413. fi
  414. export KBUILD_BUILD_TIMESTAMP="$(date -u '+%a %b %e %H:%M:%S UTC %Y')"
  415. if [ -f "build/build.sh" ]; then
  416. #Remove Dirty Flag
  417. sed -i 's/-dirty//' ./common/scripts/setlocalversion
  418. else
  419. #Remove Dirty Flag
  420. sed -i "/stable_scmversion_cmd/s/-maybe-dirty//g" ./build/kernel/kleaf/impl/stamp.bzl
  421. sed -i 's/-dirty//' ./common/scripts/setlocalversion
  422. #Remove Abi Exports and Error
  423. rm -rf ./common/android/abi_gki_protected_exports_*
  424. perl -pi -e 's/^\s*"protected_exports_list"\s*:\s*"android\/abi_gki_protected_exports_aarch64",\s*$//;' ./common/BUILD.bazel
  425. fi
  426. cd $KERNEL_ROOT/common
  427. git config --global user.name "github-actions[bot]"
  428. git config --global user.email "github-actions[bot]@users.noreply.github.com"
  429. git add .
  430. git commit -m "Wild: Clean Dirty Flag"
  431. - name: Build Kernel
  432. working-directory: ${{ env.KERNEL_ROOT }}
  433. run: |
  434. set -ex
  435. #make -C common mrproper
  436. if [ -f "build/build.sh" ]; then
  437. GKI_DEFCONFIG_FRAGMENT="${{ env.DEFCONFIG_FRAGMENT }}" LTO=thin BUILD_CONFIG=common/build.config.gki.aarch64 build/build.sh || exit 1
  438. else
  439. if [[ "${{ inputs.android_version }}" == "android14" ]]; then
  440. tools/bazel build --config=fast --lto=thin --defconfig_fragment=//common:arch/arm64/configs/wild_gki.fragment //common:kernel_aarch64_dist || exit 1
  441. else
  442. tools/bazel build --config=fast --lto=none --defconfig_fragment=//common:arch/arm64/configs/wild_gki.fragment //common:kernel_aarch64_dist || exit 1
  443. fi
  444. fi
  445. - name: Prepare AnyKernel3 Zip
  446. run: |
  447. # Copy Image from normal build locations
  448. if [ -f "$KERNEL_ROOT/out/${{ inputs.android_version }}-${{ inputs.kernel_version }}/dist/Image" ]; then
  449. cp "$KERNEL_ROOT/out/${{ inputs.android_version }}-${{ inputs.kernel_version }}/dist/Image" "$ANYKERNEL3/Image"
  450. elif [ -f "$KERNEL_ROOT/bazel-bin/common/kernel_aarch64/Image" ]; then
  451. cp "$KERNEL_ROOT/bazel-bin/common/kernel_aarch64/Image" "$ANYKERNEL3/Image"
  452. else
  453. echo "Error: Image file not found in any expected location"
  454. exit 1
  455. fi
  456. - name: Copy snd-aloop module
  457. if: ${{ inputs.variant == 'vTomsonek' }}
  458. run: |
  459. if [ "${{ inputs.variant }}" = "vTomsonek" ]; then
  460. sed -i 's|^do\.modules=.*|do.modules=1|' ./AnyKernel3/anykernel.sh
  461. fi
  462. mkdir -p AnyKernel3/modules/data/adb/lkm
  463. if [[ "${{ inputs.android_version }}" == "android12" || "${{ inputs.android_version }}" == "android13" ]]; then
  464. SRC_DIR="$KERNEL_ROOT/out/${{ inputs.android_version }}-${{ inputs.kernel_version }}/dist"
  465. else
  466. SRC_DIR="$KERNEL_ROOT/bazel-bin/common/kernel_aarch64"
  467. fi
  468. cp "$SRC_DIR/snd-aloop.ko" "$ANYKERNEL3/modules/data/adb/lkm/"
  469. cp "$SRC_DIR/g_audio.ko" "$ANYKERNEL3/modules/data/adb/lkm/"
  470. - name: Scan and collect patch rejects
  471. if: ${{ always() }}
  472. run: |
  473. set -e
  474. CONFIG_DIR="$KERNEL_ROOT"
  475. REJECTS_DIR="$GITHUB_WORKSPACE/patch-rejects"
  476. mkdir -p "$REJECTS_DIR"
  477. # Find all .rej files under the configuration directory
  478. mapfile -t REJS < <(find "$CONFIG_DIR" -type f -name '*.rej')
  479. REJ_COUNT=${#REJS[@]}
  480. echo "Found $REJ_COUNT .rej files under $CONFIG_DIR"
  481. echo "REJ_COUNT=$REJ_COUNT" >> $GITHUB_ENV
  482. if [ "$REJ_COUNT" -gt 0 ]; then
  483. for REJ in "${REJS[@]}"; do
  484. # Relative path from $CONFIG
  485. REL="${REJ#"$CONFIG_DIR"/}"
  486. DEST="$REJECTS_DIR/$REL"
  487. mkdir -p "$(dirname "$DEST")"
  488. cp "$REJ" "$DEST"
  489. # Copy the associated original file alongside the .rej
  490. ORIG="${REJ%.rej}"
  491. if [ -f "$ORIG" ]; then
  492. ORIG_DEST="$REJECTS_DIR/${REL%.rej}"
  493. mkdir -p "$(dirname "$ORIG_DEST")"
  494. cp "$ORIG" "$ORIG_DEST"
  495. fi
  496. echo "$REL" >> "$REJECTS_DIR/index.txt"
  497. done
  498. fi
  499. - name: Upload Artifacts
  500. uses: actions/upload-artifact@v4
  501. with:
  502. name: ${{ env.FILE_NAME }}-AnyKernel3
  503. path: ./AnyKernel3/**
  504. if-no-files-found: ignore
  505. compression-level: 9
  506. - name: Upload Rejects
  507. if: ${{ always() && matrix.build_type != 'Bypass' && env.REJ_COUNT > 0 }}
  508. uses: actions/upload-artifact@v4
  509. with:
  510. name: ${{ env.FILE_NAME }}-Rejects
  511. path: patch-rejects/
  512. if-no-files-found: ignore
  513. compression-level: 9
  514. - name: Build Summary
  515. if: ${{ always() }}
  516. run: |
  517. echo "========================================"
  518. echo " Kernel Build Summary "
  519. echo "========================================"
  520. echo "Kernel Info:"
  521. echo "Android Version : ${{ inputs.android_version }}"
  522. echo "Kernel Version : ${{ inputs.kernel_version }}"
  523. echo "Sub Level : ${{ inputs.sub_level }}"
  524. echo "Sub level (Makefile): $SUBLEVEL"
  525. echo "Patch Level : ${{ inputs.os_patch_level }}"
  526. echo "========================================"
  527. echo "Branch Info:"
  528. echo "Repo Branch : common-${{ inputs.kernel_version }}-${{ inputs.android_version }}-${{ inputs.os_patch_level }}"
  529. echo "Deprecated : $DEPRECATED_BRANCH"
  530. echo "========================================"
  531. echo "Build Info:"
  532. echo "Build Type : ${{ matrix.build_type }}"
  533. echo "========================================"
  534. echo "Features Info:"
  535. echo "Features : ${{ inputs.feature_set || 'None' }}"
  536. echo "WKSU Commit : ${{ inputs.ksu_commit || 'canary' }}"
  537. echo "WKSU Tag : $KSU_GIT_TAG"
  538. echo "WKSU Version : $KSU_VERSION"
  539. echo "BBG Commit : $BBG_COMMIT"
  540. echo "BBG Version : $BBG_VERSION"
  541. echo "========================================"
  542. echo "Variant : ${{ inputs.variant || 'Standard' }}"
  543. echo "Features : ${{ inputs.feature_set || 'None' }}"
  544. echo "========================================"
  545. # End of workflow