build.yml 28 KB

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