build.yml 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526
  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. revision:
  21. required: false
  22. type: string
  23. jobs:
  24. build-gki:
  25. runs-on: ubuntu-latest
  26. timeout-minutes: 120
  27. strategy:
  28. matrix:
  29. apply_symbol_fix: [true, false]
  30. steps:
  31. # # - name: Maximize Build Space
  32. # uses: AdityaGarg8/remove-unwanted-software@v5
  33. # with:
  34. # remove-dotnet: 'true' # Frees ~2 GB
  35. # remove-android: 'true' # Frees ~9 GB
  36. # remove-haskell: 'true' # Frees ~5.2 GB
  37. # remove-codeql: 'true' # Frees ~5.4 GB
  38. # remove-docker-images: 'true' # Frees ~3.2 GB
  39. # remove-large-packages: 'true' # Frees ~3.1 GB
  40. # remove-swapfile: 'true' # Frees ~4 GB
  41. # remove-cached-tools: 'false' # Avoid unless confirmed safe
  42. # verbose: 'true' # Enable detailed logging
  43. - name: Set CONFIG Environment Variable
  44. run: |
  45. # Set CONFIG dynamically based on inputs values
  46. CONFIG="${{ inputs.android_version }}-${{ inputs.kernel_version }}-${{ inputs.sub_level }}"
  47. # Set CONFIG as an environment variable for future steps
  48. echo "CONFIG=$CONFIG" >> $GITHUB_ENV
  49. - name: Setup Build Environment
  50. run: |
  51. sudo apt update && sudo apt install -y libelf-dev libssl-dev build-essential
  52. AOSP_MIRROR=https://android.googlesource.com
  53. BRANCH=main-kernel-2025
  54. git clone $AOSP_MIRROR/kernel/prebuilts/build-tools -b $BRANCH --depth 1 kernel-build-tools &
  55. git clone $AOSP_MIRROR/platform/system/tools/mkbootimg -b $BRANCH --depth 1 mkbootimg &
  56. wait
  57. echo "AVBTOOL=$GITHUB_WORKSPACE/kernel-build-tools/linux-x86/bin/avbtool" >> $GITHUB_ENV
  58. echo "MKBOOTIMG=$GITHUB_WORKSPACE/mkbootimg/mkbootimg.py" >> $GITHUB_ENV
  59. echo "UNPACK_BOOTIMG=$GITHUB_WORKSPACE/mkbootimg/unpack_bootimg.py" >> $GITHUB_ENV
  60. echo "BOOT_SIGN_KEY_PATH=$GITHUB_WORKSPACE/kernel-build-tools/linux-x86/share/avb/testkey_rsa2048.pem" >> $GITHUB_ENV
  61. echo "PATH=$GITHUB_WORKSPACE/kernel-build-tools/linux-x86/bin:$PATH" >> $GITHUB_ENV
  62. mkdir -p ./git-repo
  63. curl https://storage.googleapis.com/git-repo-downloads/repo > ./git-repo/repo
  64. chmod a+rx ./git-repo/repo
  65. echo "REPO=$GITHUB_WORKSPACE/./git-repo/repo" >> $GITHUB_ENV
  66. - name: Set boot sign key
  67. env:
  68. BOOT_SIGN_KEY: ${{ secrets.BOOT_SIGN_KEY }}
  69. run: |
  70. if [ ! -z "$BOOT_SIGN_KEY" ]; then
  71. echo "$BOOT_SIGN_KEY" > ./kernel-build-tools/linux-x86/share/avb/testkey_rsa2048.pem
  72. fi
  73. - name: Clone AnyKernel3 and Other Dependencies
  74. run: |
  75. ANYKERNEL_BRANCH="gki-2.0"
  76. SUSFS_BRANCH="gki-${{ inputs.android_version }}-${{ inputs.kernel_version }}"
  77. git clone https://github.com/WildKernels/AnyKernel3.git -b "$ANYKERNEL_BRANCH"
  78. git clone https://github.com/WildKernels/kernel_patches.git
  79. git clone https://gitlab.com/simonpunk/susfs4ksu.git -b "$SUSFS_BRANCH"
  80. ## Checkout specific commits for certain Android/kernel version combinations
  81. #if [ "${{ inputs.android_version }}-${{ inputs.kernel_version }}" = "android12-5.10" ]; then
  82. # cd susfs4ksu
  83. # git checkout 0ed20c1656af7806a1760837ad320e62a8fb40fd
  84. # cd ..
  85. #elif [ "${{ inputs.android_version }}-${{ inputs.kernel_version }}" = "android13-5.10" ]; then
  86. # cd susfs4ksu
  87. # git checkout 19e5b616464577c986e079cea0700428422bccb5
  88. # cd ..
  89. #elif [ "${{ inputs.android_version }}-${{ inputs.kernel_version }}" = "android13-5.15" ]; then
  90. # cd susfs4ksu
  91. # git checkout b443e5be35cd8275b97a776f8cc84fbbf8169749
  92. # cd ..
  93. #elif [ "${{ inputs.android_version }}-${{ inputs.kernel_version }}" = "android14-5.15" ]; then
  94. # cd susfs4ksu
  95. # git checkout 40823c6a92d072721c2c05f37776f69e3689ce8f
  96. # cd ..
  97. #elif [ "${{ inputs.android_version }}-${{ inputs.kernel_version }}" = "android14-6.1" ]; then
  98. # cd susfs4ksu
  99. # git checkout 0e19a05277d28182c7b653580117145c53e69e92
  100. # cd ..
  101. #elif [ "${{ inputs.android_version }}-${{ inputs.kernel_version }}" = "android15-6.6" ]; then
  102. # cd susfs4ksu
  103. # git checkout ef036830ec9d56035d63d328185281c09726b20f
  104. # cd ..
  105. #fi
  106. - name: Initialize and Sync Kernel Source
  107. run: |
  108. mkdir -p "$CONFIG"
  109. cd "$CONFIG"
  110. FORMATTED_BRANCH="${{ inputs.android_version }}-${{ inputs.kernel_version }}-${{ inputs.os_patch_level }}"
  111. $REPO init --depth=1 --u https://android.googlesource.com/kernel/manifest -b common-${FORMATTED_BRANCH} --repo-rev=v2.16
  112. REMOTE_BRANCH=$(git ls-remote https://android.googlesource.com/kernel/common ${FORMATTED_BRANCH})
  113. DEFAULT_MANIFEST_PATH=.repo/manifests/default.xml
  114. if grep -q deprecated <<< $REMOTE_BRANCH; then
  115. sed -i "s/\"${FORMATTED_BRANCH}\"/\"deprecated\/${FORMATTED_BRANCH}\"/g" $DEFAULT_MANIFEST_PATH
  116. fi
  117. $REPO --trace sync -c -j$(nproc --all) --no-tags --fail-fast
  118. - name: Extract Actual Sublevel for LTS Builds
  119. if: inputs.sub_level == 'X'
  120. run: |
  121. cd "$CONFIG/common"
  122. if [ -f "Makefile" ]; then
  123. ACTUAL_SUBLEVEL=$(grep '^SUBLEVEL = ' Makefile | awk '{print $3}')
  124. if [ -n "$ACTUAL_SUBLEVEL" ]; then
  125. OLD_CONFIG="$CONFIG"
  126. NEW_CONFIG="${{ inputs.android_version }}-${{ inputs.kernel_version }}-$ACTUAL_SUBLEVEL"
  127. echo "CONFIG=$NEW_CONFIG" >> $GITHUB_ENV
  128. echo "ACTUAL_SUBLEVEL=$ACTUAL_SUBLEVEL" >> $GITHUB_ENV
  129. cd ../..
  130. if [ -d "$OLD_CONFIG" ]; then
  131. mv "$OLD_CONFIG" "$NEW_CONFIG"
  132. fi
  133. fi
  134. fi
  135. - name: Apply glibc 2.38 Compatibility Fix
  136. if: inputs.android_version == 'android14' && inputs.kernel_version == '6.1'
  137. run: |
  138. if [ ! -e build/build.sh ]; then
  139. GLIBC_VERSION=$(ldd --version 2>/dev/null | head -n 1 | awk '{print $NF}')
  140. if [ "$(printf '%s\n' "2.38" "$GLIBC_VERSION" | sort -V | head -n1)" = "2.38" ]; then
  141. cd $CONFIG/common/ && 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. fi
  143. fi
  144. - name: Fix Less Then 6.6.50 Builds
  145. if: inputs.android_version == 'android15' && inputs.kernel_version == '6.6'
  146. run: |
  147. cd "$CONFIG/common"
  148. if ! grep -qxF '#include <trace/hooks/fs.h>' ./fs/namespace.c; then
  149. sed -i '/#include <trace\/hooks\/blk.h>/a #include <trace\/hooks\/fs.h>' ./fs/namespace.c
  150. fi
  151. - name: Apply ptrace patch for older kernels
  152. if: fromJSON(inputs.kernel_version) < 5.16
  153. run: |
  154. cd "$CONFIG/common"
  155. patch -p1 -F 3 < "../../kernel_patches/gki_ptrace.patch"
  156. - name: Add KernelSU
  157. run: |
  158. cd "$CONFIG"
  159. curl -LSs "https://raw.githubusercontent.com/WildKernels/Wild_KSU/wild/kernel/setup.sh" | bash -s wild
  160. - name: Apply SUSFS Patches for KernelSU Variants
  161. run: |
  162. cd "$CONFIG"
  163. # Apply core SUSFS patches
  164. cp ../susfs4ksu/kernel_patches/50_add_susfs_in_gki-${{ inputs.android_version }}-${{ inputs.kernel_version }}.patch ./common/
  165. cd common
  166. patch -p1 --forward < 50_add_susfs_in_gki-${{ inputs.android_version }}-${{ inputs.kernel_version }}.patch
  167. cd ..
  168. cp ../susfs4ksu/kernel_patches/fs/* ./common/fs/
  169. cp ../susfs4ksu/kernel_patches/include/linux/* ./common/include/linux/
  170. # Apply KSU integration patches
  171. cd ./Wild_KSU
  172. cp ../../susfs4ksu/kernel_patches/KernelSU/10_enable_susfs_for_ksu.patch .
  173. #cp ../../kernel_patches/wild/susfs_fix_patches/v1.5.10/10_enable_susfs_for_ksu.patch ./
  174. patch -p1 --forward < 10_enable_susfs_for_ksu.patch || true
  175. # Apply compatibility fixes
  176. cp ../../kernel_patches/wild/susfs_fix_patches/v1.5.10/fix_core_hook.c.patch ./
  177. patch -p1 --forward --fuzz=3 < fix_core_hook.c.patch
  178. ## Skip fix_rules.c.patch for Android 14 with kernel 6.1
  179. #if [ "${{ inputs.android_version }}" != "android14" ] && [ "${{ inputs.kernel_version }}" != "6.1" ]; then
  180. # cp ../../kernel_patches/wild/susfs_fix_patches/v1.5.10/fix_rules.c.patch ./
  181. # patch -p1 --forward < fix_rules.c.patch
  182. #fi
  183. cp ../../kernel_patches/wild/susfs_fix_patches/v1.5.10/fix_sucompat.c.patch ./
  184. patch -p1 --forward < fix_sucompat.c.patch
  185. cp ../../kernel_patches/wild/susfs_fix_patches/v1.5.10/fix_kernel_compat.c.patch ./
  186. patch -p1 --forward < fix_kernel_compat.c.patch
  187. - name: Getting KernelSU Version
  188. run: |
  189. cd "$CONFIG/Wild_KSU/kernel"
  190. BASE_VERSION=10200
  191. COMMIT_COUNT=$(/usr/bin/git rev-list --count HEAD)
  192. KSU_VERSION=$(expr $COMMIT_COUNT "+" $BASE_VERSION)
  193. echo "KSUVER=$KSU_VERSION" >> $GITHUB_ENV
  194. - name: Apply Hooks Patches
  195. run: |
  196. cd "$CONFIG/common"
  197. cp ../../kernel_patches/wild/hooks/scope_min_manual_hooks_v1.4.patch ./
  198. patch -p1 --forward -F 3 < scope_min_manual_hooks_v1.4.patch
  199. - name: Add BBG
  200. run: |
  201. cd "$CONFIG/kernel_platform"
  202. echo "Adding BBG..."
  203. wget -O- https://github.com/vc-teahouse/Baseband-guard/raw/main/setup.sh | bash
  204. echo "CONFIG_BBG=y" >> common/arch/arm64/configs/gki_defconfig
  205. sed -i '/^config LSM$/,/^help$/{ /^[[:space:]]*default/ { /baseband_guard/! s/landlock/landlock,baseband_guard/ } }' common/security/Kconfig
  206. - name: Apply Module Symbol Version Fix Patch
  207. if: ${{ matrix.apply_symbol_fix }}
  208. run: |
  209. if [[ "${{ inputs.kernel_version }}" == "6.1" || "${{ inputs.kernel_version }}" == "6.6" ]]; then
  210. cd "$CONFIG/common/kernel/module"
  211. #sed -i 's/pr_warn("%s: disagrees about version of symbol %s\\n"/pr_warn("%s: disagrees about version of symbol %s, but ignore...\\n"/' version.c
  212. sed -i '/bad_version:/{:a;n;/return 0;/{s/return 0;/return 1;/;b};ba}' version.c
  213. else
  214. cd "$CONFIG/common/kernel"
  215. #sed -i 's/pr_warn("%s: disagrees about version of symbol %s\\n"/pr_warn("%s: disagrees about version of symbol %s, but ignore...\\n"/' module.c
  216. sed -i '/bad_version:/{:a;n;/return 0;/{s/return 0;/return 1;/;b};ba}' module.c
  217. fi
  218. - name: Fix WiFi and Bluetooth on Samsung 6.6 GKI devices
  219. if: ${{ ( inputs.kernel_version == '6.6' ) }}
  220. run: |
  221. SYMBOL_LIST=$CONFIG/common/android/abi_gki_aarch64_galaxy
  222. echo "kdp_set_cred_non_rcu" >> $SYMBOL_LIST
  223. echo "kdp_usecount_dec_and_test" >> $SYMBOL_LIST
  224. echo "kdp_usecount_inc" >> $SYMBOL_LIST
  225. cd $CONFIG/common
  226. PATCH="../../kernel_patches/samsung/min_kdp/add-min_kdp-symbols.patch"
  227. if patch -p1 --dry-run < $PATCH; then
  228. patch -p1 --no-backup-if-mismatch < $PATCH
  229. fi
  230. cd drivers
  231. cp "../../../kernel_patches/samsung/min_kdp/min_kdp.c" min_kdp.c
  232. echo "obj-y += min_kdp.o" >> Makefile
  233. - name: Apply Kernel Configuration
  234. run: |
  235. cd "$CONFIG"
  236. defconfig="./common/arch/arm64/configs/gki_defconfig"
  237. echo "Applying kernel configurations one by one..."
  238. # KernelSU Core Configuration
  239. echo "CONFIG_KSU=y" >> "$defconfig"
  240. echo "CONFIG_KSU_KPROBES_HOOK=n" >> "$defconfig"
  241. # Mountify Support
  242. echo "CONFIG_TMPFS_XATTR=y" >> "$defconfig"
  243. echo "CONFIG_TMPFS_POSIX_ACL=y" >> "$defconfig"
  244. # Networking Configuration
  245. echo "CONFIG_IP_NF_TARGET_TTL=y" >> "$defconfig"
  246. echo "CONFIG_IP6_NF_TARGET_HL=y" >> "$defconfig"
  247. echo "CONFIG_IP6_NF_MATCH_HL=y" >> "$defconfig"
  248. # BBR TCP Congestion Control
  249. echo "CONFIG_TCP_CONG_ADVANCED=y" >> "$defconfig"
  250. echo "CONFIG_TCP_CONG_BBR=y" >> "$defconfig"
  251. echo "CONFIG_NET_SCH_FQ=y" >> "$defconfig"
  252. echo "CONFIG_TCP_CONG_BIC=n" >> "$defconfig"
  253. echo "CONFIG_TCP_CONG_WESTWOOD=n" >> "$defconfig"
  254. echo "CONFIG_TCP_CONG_HTCP=n" >> "$defconfig"
  255. # IPSet support
  256. echo "CONFIG_IP_SET=y" >> "$defconfig"
  257. echo "CONFIG_IP_SET_MAX=256" >> "$defconfig"
  258. echo "CONFIG_IP_SET_BITMAP_IP=y" >> "$defconfig"
  259. echo "CONFIG_IP_SET_BITMAP_IPMAC=y" >> "$defconfig"
  260. echo "CONFIG_IP_SET_BITMAP_PORT=y" >> "$defconfig"
  261. echo "CONFIG_IP_SET_HASH_IP=y" >> "$defconfig"
  262. echo "CONFIG_IP_SET_HASH_IPPORT=y" >> "$defconfig"
  263. echo "CONFIG_IP_SET_HASH_IPPORTIP=y" >> "$defconfig"
  264. echo "CONFIG_IP_SET_HASH_IPPORTNET=y" >> "$defconfig"
  265. echo "CONFIG_IP_SET_HASH_NET=y" >> "$defconfig"
  266. echo "CONFIG_IP_SET_HASH_NETNET=y" >> "$defconfig"
  267. echo "CONFIG_IP_SET_HASH_NETPORT=y" >> "$defconfig"
  268. echo "CONFIG_IP_SET_HASH_NETIFACE=y" >> "$defconfig"
  269. # SUSFS Configuration
  270. echo "CONFIG_KSU_SUSFS=y" >> "$defconfig"
  271. echo "CONFIG_KSU_SUSFS_HAS_MAGIC_MOUNT=y" >> "$defconfig"
  272. echo "CONFIG_KSU_SUSFS_SUS_PATH=y" >> "$defconfig"
  273. echo "CONFIG_KSU_SUSFS_SUS_MOUNT=y" >> "$defconfig"
  274. # SUSFS Auto Mount Features
  275. echo "CONFIG_KSU_SUSFS_AUTO_ADD_SUS_KSU_DEFAULT_MOUNT=y" >> "$defconfig"
  276. echo "CONFIG_KSU_SUSFS_AUTO_ADD_SUS_BIND_MOUNT=y" >> "$defconfig"
  277. echo "CONFIG_KSU_SUSFS_TRY_UMOUNT=y" >> "$defconfig"
  278. echo "CONFIG_KSU_SUSFS_AUTO_ADD_TRY_UMOUNT_FOR_BIND_MOUNT=y" >> "$defconfig"
  279. # SUSFS Advanced Features
  280. echo "CONFIG_KSU_SUSFS_SUS_KSTAT=y" >> "$defconfig"
  281. echo "CONFIG_KSU_SUSFS_SUS_OVERLAYFS=n" >> "$defconfig"
  282. echo "CONFIG_KSU_SUSFS_SPOOF_UNAME=y" >> "$defconfig"
  283. echo "CONFIG_KSU_SUSFS_SPOOF_CMDLINE_OR_BOOTCONFIG=y" >> "$defconfig"
  284. echo "CONFIG_KSU_SUSFS_OPEN_REDIRECT=y" >> "$defconfig"
  285. # SUSFS Debugging and Security
  286. echo "CONFIG_KSU_SUSFS_ENABLE_LOG=y" >> "$defconfig"
  287. echo "CONFIG_KSU_SUSFS_HIDE_KSU_SUSFS_SYMBOLS=y" >> "$defconfig"
  288. echo "CONFIG_KSU_SUSFS_SUS_SU=n" >> "$defconfig"
  289. # Build Optimization Configuration
  290. echo "CONFIG_LTO_CLANG_THIN=y" >> "$defconfig"
  291. echo "CONFIG_LTO_CLANG=y" >> "$defconfig"
  292. echo "CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE=y" >> "$defconfig"
  293. echo "CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3=n" >> "$defconfig"
  294. # Remove check_defconfig
  295. sed -i 's/check_defconfig//' ./common/build.config.gki
  296. - name: Change Kernel Name
  297. run: |
  298. cd "$CONFIG"
  299. perl -pi -e 's/-dirty//' ./common/scripts/setlocalversion
  300. perl -pi -e 's/-maybe-dirty//g' ./build/kernel/kleaf/impl/stamp.bzl
  301. #Set Kernel Timestamp
  302. perl -pi -e 's{UTS_VERSION="\$\(echo \$UTS_VERSION \$CONFIG_FLAGS \$TIMESTAMP \| cut -b -\$UTS_LEN\)"}{UTS_VERSION="#1 SMP PREEMPT Sun Apr 20 04:20:00 UTC 2025"}' ./common/scripts/mkcompile_h
  303. #Set Kernel Name
  304. if [ "${{ inputs.kernel_version }}" = "6.6" ]; then
  305. perl -0777 -pi -e 's/(echo "\$\{KERNELVERSION\}\$\{file_localversion\}\$\{config_localversion\}\$\{LOCALVERSION\}\$\{scm_version\}")/echo "\$\{KERNELVERSION\}\$\{file_localversion\}\$\{config_localversion\}\$\{LOCALVERSION\}\$\{scm_version\}-Wild"/s' ./common/scripts/setlocalversion
  306. else
  307. perl -0777 -pi -e 's/(echo "\$res")(?!.*echo "\$res")/echo "\$res-Wild"/s' ./common/scripts/setlocalversion
  308. fi
  309. #Set Kernel Timestamp
  310. perl -pi -e 's/build-timestamp = \$\(or \$\(KBUILD_BUILD_TIMESTAMP\), \$\(build-timestamp-auto\)\)/build-timestamp = "Sun Apr 20 04:20:00 UTC 2025"/' ./common/init/Makefile
  311. #Remove Abi Exports and Error
  312. rm -rf ./common/android/abi_gki_protected_exports_*
  313. perl -pi -e 's/^\s*"protected_exports_list"\s*:\s*"android\/abi_gki_protected_exports_aarch64",\s*$//;' ./common/BUILD.bazel
  314. - name: Build
  315. run : |
  316. set -e
  317. set -x
  318. cd "$CONFIG"
  319. echo "Building the kernel..."
  320. if [ -f "build/build.sh" ]; then
  321. LTO=thin BUILD_CONFIG=common/build.config.gki.aarch64 build/build.sh || exit 1
  322. else
  323. tools/bazel build --config=fast --lto=thin //common:kernel_aarch64_dist || exit 1
  324. fi
  325. - name: Create AK3 ZIP
  326. run: |
  327. # Copy Image from normal build locations
  328. if [ -f "./$CONFIG/out/${{ inputs.android_version }}-${{ inputs.kernel_version }}/dist/Image" ]; then
  329. cp ./$CONFIG/out/${{ inputs.android_version }}-${{ inputs.kernel_version }}/dist/Image AnyKernel3/Image
  330. elif [ -f "./$CONFIG/bazel-bin/common/kernel_aarch64/Image" ]; then
  331. cp ./$CONFIG/bazel-bin/common/kernel_aarch64/Image AnyKernel3/Image
  332. else
  333. echo "Error: Image file not found in any expected location"
  334. exit 1
  335. fi
  336. cd AnyKernel3
  337. # Use actual sublevel for LTS builds if available
  338. SUBLEVEL_FOR_NAME="${{ inputs.sub_level }}"
  339. if [ -n "$ACTUAL_SUBLEVEL" ]; then
  340. SUBLEVEL_FOR_NAME="$ACTUAL_SUBLEVEL"
  341. fi
  342. ZIP_NAME="WKSU-$KSUVER-${{ inputs.android_version }}-${{ inputs.kernel_version }}.$SUBLEVEL_FOR_NAME-${{ inputs.os_patch_level }}-AnyKernel3.zip"
  343. zip -r "../$ZIP_NAME" ./*
  344. - name: Create Bootimgs Folder and Copy Images for Android 12/13
  345. if: ${{ inputs.android_version == 'android12' || inputs.android_version == 'android13' }}
  346. run: |
  347. mkdir bootimgs
  348. echo "Creating bootimgs folder and copying images..."
  349. cp ./$CONFIG/out/${{ inputs.android_version }}-${{ inputs.kernel_version }}/dist/Image ./bootimgs
  350. cp ./$CONFIG/out/${{ inputs.android_version }}-${{ inputs.kernel_version }}/dist/Image.lz4 ./bootimgs
  351. cp ./$CONFIG/out/${{ inputs.android_version }}-${{ inputs.kernel_version }}/dist/Image ./
  352. cp ./$CONFIG/out/${{ inputs.android_version }}-${{ inputs.kernel_version }}/dist/Image.lz4 ./
  353. # Create gzip of the Image file
  354. gzip -n -k -f -9 ./Image > ./Image.gz
  355. gzip -n -k -f -9 ./Image > ./bootimgs/Image.gz
  356. - name: Create Bootimgs Folder and Copy Images for Android 14/15
  357. if: ${{ inputs.android_version == 'android14' || inputs.android_version == 'android15' }}
  358. run: |
  359. mkdir bootimgs
  360. echo "Creating bootimgs folder and copying images..."
  361. cp ./$CONFIG/bazel-bin/common/kernel_aarch64/Image ./bootimgs
  362. cp ./$CONFIG/bazel-bin/common/kernel_aarch64/Image.lz4 ./bootimgs
  363. cp ./$CONFIG/bazel-bin/common/kernel_aarch64/Image ./
  364. cp ./$CONFIG/bazel-bin/common/kernel_aarch64/Image.lz4 ./
  365. # Create gzip of the Image file
  366. gzip -n -k -f -9 ./Image > ./Image.gz
  367. gzip -n -k -f -9 ./Image > ./bootimgs/Image.gz
  368. - name: Android 12 boot image build script
  369. if: ${{ inputs.android_version == 'android12' }}
  370. run: |
  371. echo "Changing to configuration directory: $CONFIG..."
  372. cd bootimgs
  373. # Prepare sublevel for naming
  374. SUBLEVEL_FOR_NAME="${{ inputs.sub_level }}"
  375. if [ -n "$ACTUAL_SUBLEVEL" ]; then
  376. SUBLEVEL_FOR_NAME="$ACTUAL_SUBLEVEL"
  377. fi
  378. GKI_URL=https://dl.google.com/android/gki/gki-certified-boot-android12-5.10-"${{ inputs.os_patch_level }}"_"${{ inputs.revision }}".zip
  379. FALLBACK_URL=https://dl.google.com/android/gki/gki-certified-boot-android12-5.10-2023-01_r1.zip
  380. # Check if the GKI URL is available
  381. echo "Checking if GKI kernel URL is reachable: $GKI_URL"
  382. status=$(curl -sL -w "%{http_code}" "$GKI_URL" -o /dev/null)
  383. if [ "$status" = "200" ]; then
  384. echo "[+] Downloading from GKI_URL"
  385. curl -Lo gki-kernel.zip "$GKI_URL"
  386. else
  387. echo "[+] $GKI_URL not found, using $FALLBACK_URL"
  388. curl -Lo gki-kernel.zip "$FALLBACK_URL"
  389. fi
  390. # Unzip the downloaded kernel and remove the zip
  391. echo "Unzipping the downloaded kernel..."
  392. unzip gki-kernel.zip && rm gki-kernel.zip
  393. echo "Unpacking boot.img..."
  394. FULL_PATH=$(pwd)/boot-5.10.img
  395. echo "Unpacking using: $FULL_PATH"
  396. echo "Running unpack_bootimg.py..."
  397. $UNPACK_BOOTIMG --boot_img="$FULL_PATH"
  398. echo "Building boot.img"
  399. $MKBOOTIMG --header_version 4 --kernel Image --output boot.img --ramdisk out/ramdisk --os_version 12.0.0 --os_patch_level "${{ inputs.os_patch_level }}"
  400. $AVBTOOL add_hash_footer --partition_name boot --partition_size $((64 * 1024 * 1024)) --image boot.img --algorithm SHA256_RSA2048 --key $BOOT_SIGN_KEY_PATH
  401. cp ./boot.img ../WKSU-$KSUVER-${{ inputs.android_version }}-${{ inputs.kernel_version }}.$SUBLEVEL_FOR_NAME-${{ inputs.os_patch_level }}-boot.img
  402. echo "Building boot-gz.img"
  403. $MKBOOTIMG --header_version 4 --kernel Image.gz --output boot-gz.img --ramdisk out/ramdisk --os_version 12.0.0 --os_patch_level "${{ inputs.os_patch_level }}"
  404. $AVBTOOL add_hash_footer --partition_name boot --partition_size $((64 * 1024 * 1024)) --image boot-gz.img --algorithm SHA256_RSA2048 --key $BOOT_SIGN_KEY_PATH
  405. cp ./boot-gz.img ../WKSU-$KSUVER-${{ inputs.android_version }}-${{ inputs.kernel_version }}.$SUBLEVEL_FOR_NAME-${{ inputs.os_patch_level }}-boot-gz.img
  406. echo "Building boot-lz4.img"
  407. $MKBOOTIMG --header_version 4 --kernel Image.lz4 --output boot-lz4.img --ramdisk out/ramdisk --os_version 12.0.0 --os_patch_level "${{ inputs.os_patch_level }}"
  408. $AVBTOOL add_hash_footer --partition_name boot --partition_size $((64 * 1024 * 1024)) --image boot-lz4.img --algorithm SHA256_RSA2048 --key $BOOT_SIGN_KEY_PATH
  409. cp ./boot-lz4.img ../WKSU-$KSUVER-${{ inputs.android_version }}-${{ inputs.kernel_version }}.$SUBLEVEL_FOR_NAME-${{ inputs.os_patch_level }}-boot-lz4.img
  410. - name: Android 13/14/15 boot image build script
  411. if: ${{ inputs.android_version == 'android13' || inputs.android_version == 'android14' || inputs.android_version == 'android15' }}
  412. run: |
  413. cd bootimgs
  414. # Prepare sublevel for naming
  415. SUBLEVEL_FOR_NAME="${{ inputs.sub_level }}"
  416. if [ -n "$ACTUAL_SUBLEVEL" ]; then
  417. SUBLEVEL_FOR_NAME="$ACTUAL_SUBLEVEL"
  418. fi
  419. echo "Building boot.img"
  420. $MKBOOTIMG --header_version 4 --kernel Image --output boot.img
  421. $AVBTOOL add_hash_footer --partition_name boot --partition_size $((64 * 1024 * 1024)) --image boot.img --algorithm SHA256_RSA2048 --key $BOOT_SIGN_KEY_PATH
  422. cp ./boot.img ../WKSU-$KSUVER-${{ inputs.android_version }}-${{ inputs.kernel_version }}.$SUBLEVEL_FOR_NAME-${{ inputs.os_patch_level }}-boot.img
  423. echo "Building boot-gz.img"
  424. $MKBOOTIMG --header_version 4 --kernel Image.gz --output boot-gz.img
  425. $AVBTOOL add_hash_footer --partition_name boot --partition_size $((64 * 1024 * 1024)) --image boot-gz.img --algorithm SHA256_RSA2048 --key $BOOT_SIGN_KEY_PATH
  426. cp ./boot-gz.img ../WKSU-$KSUVER-${{ inputs.android_version }}-${{ inputs.kernel_version }}.$SUBLEVEL_FOR_NAME-${{ inputs.os_patch_level }}-boot-gz.img
  427. echo "Building boot-lz4.img"
  428. $MKBOOTIMG --header_version 4 --kernel Image.lz4 --output boot-lz4.img
  429. $AVBTOOL add_hash_footer --partition_name boot --partition_size $((64 * 1024 * 1024)) --image boot-lz4.img --algorithm SHA256_RSA2048 --key $BOOT_SIGN_KEY_PATH
  430. cp ./boot-lz4.img ../WKSU-$KSUVER-${{ inputs.android_version }}-${{ inputs.kernel_version }}.$SUBLEVEL_FOR_NAME-${{ inputs.os_patch_level }}-boot-lz4.img
  431. - name: Upload Build Artifacts
  432. uses: actions/upload-artifact@v4
  433. with:
  434. name: WKSU-${{ env.KSUVER }}-${{ matrix.apply_symbol_fix && 'SymbolFix'}}-${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ env.ACTUAL_SUBLEVEL || inputs.sub_level }}-${{ inputs.os_patch_level }}-
  435. path: |
  436. *.zip
  437. *.img