build.yml 32 KB

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