build.yml 25 KB

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