build.yml 32 KB

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