build.yml 31 KB

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