build.yml 26 KB

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