build.yml 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500
  1. name: Build Script
  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. kernelsu_variant:
  21. required: true
  22. type: string
  23. kernelsu_branch:
  24. required: true
  25. type: string
  26. kernelsu_branch_other:
  27. required: false
  28. type: string
  29. revision:
  30. required: false
  31. type: string
  32. jobs:
  33. build-gki:
  34. runs-on: ubuntu-latest
  35. timeout-minutes: 120
  36. env:
  37. CCACHE_COMPILERCHECK: "%compiler% -dumpmachine; %compiler% -dumpversion"
  38. CCACHE_NOHASHDIR: "true"
  39. CCACHE_HARDLINK: "true"
  40. steps:
  41. - name: Set CONFIG Environment Variable
  42. run: |
  43. # Set CONFIG dynamically based on inputs values
  44. CONFIG="${{ inputs.android_version }}-${{ inputs.kernel_version }}-${{ inputs.sub_level }}"
  45. # Set CONFIG as an environment variable for future steps
  46. echo "CONFIG=$CONFIG" >> $GITHUB_ENV
  47. echo "CONFIG set to: $CONFIG"
  48. - name: Install ccache
  49. run: sudo apt update && sudo apt install -y ccache
  50. - name: Set up ccache
  51. run: |
  52. mkdir -p ~/.cache/bazel
  53. ccache --version
  54. ccache --max-size=2G
  55. ccache --set-config=compression=true
  56. echo "CCACHE_DIR=$HOME/.ccache" >> $GITHUB_ENV
  57. - name: Restore ccache from cache
  58. uses: actions/cache@v4
  59. with:
  60. path: ~/.ccache
  61. key: ${{ inputs.android_version }}-${{ inputs.kernel_version }}-${{ inputs.sub_level }}-ccache-${{ github.sha }}
  62. restore-keys: |
  63. ${{ inputs.android_version }}-${{ inputs.kernel_version }}-${{ inputs.sub_level }}-ccache-
  64. - name: Cache toolchain
  65. id: cache-toolchain
  66. uses: actions/cache@v4
  67. with:
  68. path: |
  69. kernel-build-tools
  70. mkbootimg
  71. key: toolchain-${{ runner.os }}-v1
  72. - name: Download toolchain (if cache not found)
  73. if: steps.cache-toolchain.outputs.cache-hit != 'true'
  74. run: |
  75. AOSP_MIRROR=https://android.googlesource.com
  76. BRANCH=main-kernel-build-2024
  77. git clone $AOSP_MIRROR/kernel/prebuilts/build-tools -b $BRANCH --depth 1 kernel-build-tools
  78. git clone $AOSP_MIRROR/platform/system/tools/mkbootimg -b $BRANCH --depth 1 mkbootimg
  79. - name: Set environment variables
  80. run: |
  81. echo "AVBTOOL=$GITHUB_WORKSPACE/kernel-build-tools/linux-x86/bin/avbtool" >> $GITHUB_ENV
  82. echo "MKBOOTIMG=$GITHUB_WORKSPACE/mkbootimg/mkbootimg.py" >> $GITHUB_ENV
  83. echo "UNPACK_BOOTIMG=$GITHUB_WORKSPACE/mkbootimg/unpack_bootimg.py" >> $GITHUB_ENV
  84. - name: Set boot sign key
  85. env:
  86. BOOT_SIGN_KEY: ${{ secrets.BOOT_SIGN_KEY }}
  87. run: |
  88. if [ ! -z "$BOOT_SIGN_KEY" ]; then
  89. echo "$BOOT_SIGN_KEY" > ./kernel-build-tools/linux-x86/share/avb/testkey_rsa2048.pem
  90. echo "BOOT_SIGN_KEY_PATH=$GITHUB_WORKSPACE/kernel-build-tools/linux-x86/share/avb/testkey_rsa2048.pem" >> $GITHUB_ENV
  91. else
  92. echo "BOOT_SIGN_KEY is not set. Using AOSP sign key..."
  93. echo "BOOT_SIGN_KEY_PATH=$GITHUB_WORKSPACE/kernel-build-tools/linux-x86/share/avb/testkey_rsa2048.pem" >> $GITHUB_ENV
  94. fi
  95. - name: Install Repo
  96. run: |
  97. mkdir -p ./git-repo
  98. echo "Downloading repo tool..."
  99. curl https://storage.googleapis.com/git-repo-downloads/repo > ./git-repo/repo
  100. chmod a+rx ./git-repo/repo
  101. echo "REPO=$GITHUB_WORKSPACE/./git-repo/repo" >> $GITHUB_ENV
  102. - name: Clone AnyKernel3 and Other Dependencies
  103. run: |
  104. echo "Cloning AnyKernel3 and other dependencies..."
  105. ANYKERNEL_BRANCH="gki-2.0"
  106. SUSFS_BRANCH="gki-${{ inputs.android_version }}-${{ inputs.kernel_version }}"
  107. echo "Using branch for AnyKernel3: $ANYKERNEL_BRANCH"
  108. echo "Using branch for SUSFS: $SUSFS_BRANCH"
  109. git clone https://github.com/WildPlusKernel/AnyKernel3.git -b "$ANYKERNEL_BRANCH"
  110. git clone https://gitlab.com/simonpunk/susfs4ksu.git -b "$SUSFS_BRANCH"
  111. git clone https://github.com/WildPlusKernel/kernel_patches.git
  112. - name: Check Disk Space Before Sync
  113. run: |
  114. echo "Disk space before kernel source sync:"
  115. df -h
  116. - name: Initialize and Sync Kernel Source
  117. run: |
  118. echo "Creating folder for configuration: $CONFIG..."
  119. mkdir -p "$CONFIG"
  120. cd "$CONFIG"
  121. echo "Initializing and syncing kernel source..."
  122. FORMATTED_BRANCH="${{ inputs.android_version }}-${{ inputs.kernel_version }}-${{ inputs.os_patch_level }}"
  123. $REPO init --depth=1 --u https://android.googlesource.com/kernel/manifest -b common-${FORMATTED_BRANCH} --repo-rev=v2.16
  124. REMOTE_BRANCH=$(git ls-remote https://android.googlesource.com/kernel/common ${FORMATTED_BRANCH})
  125. DEFAULT_MANIFEST_PATH=.repo/manifests/default.xml
  126. if grep -q deprecated <<< $REMOTE_BRANCH; then
  127. echo "Found deprecated branch: $FORMATTED_BRANCH"
  128. sed -i "s/\"${FORMATTED_BRANCH}\"/\"deprecated\/${FORMATTED_BRANCH}\"/g" $DEFAULT_MANIFEST_PATH
  129. fi
  130. $REPO --version
  131. $REPO --trace sync -c -j$(nproc --all) --no-tags --fail-fast
  132. - name: Determine the branch for KernelSU
  133. run: |
  134. case "${{ inputs.kernelsu_branch }}" in
  135. "Stable")
  136. echo "BRANCH=-" >> $GITHUB_ENV
  137. ;;
  138. "Dev")
  139. if [[ "${{ inputs.kernelsu_variant }}" =~ ^(KSU|MKSU)$ ]]; then
  140. echo "BRANCH=-s main" >> $GITHUB_ENV
  141. elif [[ "${{ inputs.kernelsu_variant }}" == "NEXT" ]]; then
  142. echo "BRANCH=-s next" >> $GITHUB_ENV
  143. fi
  144. ;;
  145. "Other")
  146. if [[ -n "${{ inputs.kernelsu_branch_other }}" ]]; then
  147. echo "BRANCH=-s ${{ inputs.kernelsu_branch_other }}" >> $GITHUB_ENV
  148. else
  149. echo "Error: Custom branch not provided for 'Other'" >&2
  150. exit 1
  151. fi
  152. ;;
  153. esac
  154. - name: Add KernelSU
  155. run: |
  156. echo "Changing to configuration directory: $CONFIG..."
  157. cd "$CONFIG"
  158. case "${{ inputs.kernelsu_variant }}" in
  159. "KSU" | "WILD")
  160. echo "Adding KernelSU Official..."
  161. curl -LSs "https://raw.githubusercontent.com/tiann/KernelSU/main/kernel/setup.sh" | bash ${{ env.BRANCH }}
  162. ;;
  163. "NEXT")
  164. echo "Adding KernelSU Next..."
  165. curl -LSs "https://raw.githubusercontent.com/KernelSU-Next/KernelSU-Next/next/kernel/setup.sh" | bash ${{ env.BRANCH }}
  166. ;;
  167. "MKSU")
  168. echo "Adding KernelSU MKSU..."
  169. curl -LSs "https://raw.githubusercontent.com/5ec1cff/KernelSU/main/kernel/setup.sh" | bash ${{ env.BRANCH }}
  170. ;;
  171. esac
  172. - name: Apply SUSFS Patches for KernelSU Variants
  173. run: |
  174. echo "Changing to configuration directory: $CONFIG..."
  175. cd "$CONFIG"
  176. echo "Applying SUSFS patches..."
  177. # Copy SUSFS patches
  178. cp ../susfs4ksu/kernel_patches/50_add_susfs_in_gki-${{ inputs.android_version }}-${{ inputs.kernel_version }}.patch ./common/
  179. cp ../susfs4ksu/kernel_patches/fs/* ./common/fs/
  180. cp ../susfs4ksu/kernel_patches/include/linux/* ./common/include/linux/
  181. case "${{ inputs.kernelsu_variant }}" in
  182. "KSU" | "WILD")
  183. echo "Applying SUSFS patches for Official KernelSU..."
  184. cd ./KernelSU
  185. cp ../../susfs4ksu/kernel_patches/KernelSU/10_enable_susfs_for_ksu.patch ./
  186. patch -p1 --forward --fuzz=3 < 10_enable_susfs_for_ksu.patch
  187. ;;
  188. "NEXT")
  189. echo "Applying SUSFS patches for KernelSU Next..."
  190. cd ./KernelSU-Next
  191. cp ../../kernel_patches/next/kernel-patch-susfs-v1.5.7-to-KernelSU-Next.patch ./
  192. patch -p1 --forward --fuzz=3 < kernel-patch-susfs-v1.5.7-to-KernelSU-Next.patch
  193. ;;
  194. "MKSU")
  195. echo "Applying SUSFS patches for MKSU..."
  196. cd ./KernelSU
  197. cp ../../kernel_patches/next/kernel-patch-susfs-v1.5.7-to-KernelSU-Next.patch ./
  198. patch -p1 --forward --fuzz=3 < kernel-patch-susfs-v1.5.7-to-KernelSU-Next.patch
  199. ;;
  200. esac
  201. cd ../common
  202. patch -p1 --fuzz=3 < 50_add_susfs_in_gki-${{ inputs.android_version }}-${{ inputs.kernel_version }}.patch || true
  203. - name: Apply Hooks Patches
  204. run: |
  205. echo "Changing to configuration directory: $CONFIG..."
  206. cd "$CONFIG/common"
  207. if [ "${{ inputs.kernelsu_variant }}" == "NEXT" ]; then
  208. echo "Applying hooks for KernelSU-Next..."
  209. cp ../../kernel_patches/next/syscall_hooks.patch ./
  210. patch -p1 -F 3 < syscall_hooks.patch
  211. elif [ "${{ inputs.kernelsu_variant }}" == "NEXT" ]; then
  212. echo "Applying hooks for KernelSU-Next..."
  213. cp ../../kernel_patches/wild/syscall_hooks.patch ./
  214. patch -p1 -F 3 < syscall_hooks.patch
  215. fi
  216. - name: Apply Hide Stuff Patches
  217. run: |
  218. echo "Changing to configuration directory: $CONFIG..."
  219. cd "$CONFIG/common"
  220. cp ../../kernel_patches/69_hide_stuff.patch ./
  221. patch -p1 -F 3 < 69_hide_stuff.patch
  222. - name: Add All Managers
  223. run: |
  224. cd "$CONFIG"
  225. case "${{ inputs.kernelsu_variant }}" in
  226. "KSU" | "WILD")
  227. echo "Applying Manager patch for Official KernelSU..."
  228. cd KernelSU
  229. cp ../kernel_patches/wild/manager.patch ./
  230. ;;
  231. "NEXT")
  232. echo "Applying Manager patch for KernelSU Next..."
  233. cd KernelSU-Next
  234. cp ../../kernel_patches/next/manager.patch ./
  235. ;;
  236. "MKSU")
  237. echo "Applying Manager patch for MKSU..."
  238. #cp ../kernel_patches/mksu/manager.patch .//
  239. ;;
  240. esac
  241. patch -p1 --fuzz=3 < manager.patch || echo "No Manager Patch"
  242. - name: Add Configuration Settings
  243. run: |
  244. echo "Changing to configuration directory: $CONFIG..."
  245. cd "$CONFIG"
  246. echo "Adding configuration settings to gki_defconfig..."
  247. # Add KSU configuration settings
  248. echo "CONFIG_KSU=y" >> ./common/arch/arm64/configs/gki_defconfig
  249. if [ "${{ inputs.kernelsu_variant }}" == "NEXT" ]; then
  250. echo "CONFIG_KSU_WITH_KPROBES=n" >> ./common/arch/arm64/configs/gki_defconfig
  251. fi
  252. # Add additional tmpfs config setting
  253. echo "CONFIG_TMPFS_XATTR=y" >> ./common/arch/arm64/configs/gki_defconfig
  254. echo "CONFIG_TMPFS_POSIX_ACL=y" >> ./common/arch/arm64/configs/gki_defconfig
  255. # Add additional config setting
  256. echo "CONFIG_IP_NF_TARGET_TTL=y" >> ./common/arch/arm64/configs/gki_defconfig
  257. echo "CONFIG_IP6_NF_TARGET_HL=y" >> ./common/arch/arm64/configs/gki_defconfig
  258. echo "CONFIG_IP6_NF_MATCH_HL=y" >> ./common/arch/arm64/configs/gki_defconfig
  259. # Add BBR Config
  260. echo "CONFIG_TCP_CONG_ADVANCED=y" >> ./common/arch/arm64/configs/gki_defconfig
  261. echo "CONFIG_TCP_CONG_BBR=y" >> ./common/arch/arm64/configs/gki_defconfig
  262. echo "CONFIG_NET_SCH_FQ=y" >> ./common/arch/arm64/configs/gki_defconfig
  263. echo "CONFIG_TCP_CONG_BIC=n" >> ./common/arch/arm64/configs/gki_defconfig
  264. echo "CONFIG_TCP_CONG_WESTWOOD=n" >> ./common/arch/arm64/configs/gki_defconfig
  265. echo "CONFIG_TCP_CONG_HTCP=n" >> ./common/arch/arm64/configs/gki_defconfig
  266. # Remove check_defconfig
  267. sed -i 's/check_defconfig//' ./common/build.config.gki
  268. - name: Add SUSFS Configuration Settings
  269. run: |
  270. echo "Changing to configuration directory: $CONFIG..."
  271. cd "$CONFIG"
  272. # Add SUSFS configuration settings
  273. echo "CONFIG_KSU_SUSFS=y" >> ./common/arch/arm64/configs/gki_defconfig
  274. echo "CONFIG_KSU_SUSFS_HAS_MAGIC_MOUNT=y" >> ./common/arch/arm64/configs/gki_defconfig
  275. echo "CONFIG_KSU_SUSFS_SUS_PATH=y" >> ./common/arch/arm64/configs/gki_defconfig
  276. echo "CONFIG_KSU_SUSFS_SUS_MOUNT=y" >> ./common/arch/arm64/configs/gki_defconfig
  277. echo "CONFIG_KSU_SUSFS_AUTO_ADD_SUS_KSU_DEFAULT_MOUNT=y" >> ./common/arch/arm64/configs/gki_defconfig
  278. echo "CONFIG_KSU_SUSFS_AUTO_ADD_SUS_BIND_MOUNT=y" >> ./common/arch/arm64/configs/gki_defconfig
  279. echo "CONFIG_KSU_SUSFS_SUS_KSTAT=y" >> ./common/arch/arm64/configs/gki_defconfig
  280. echo "CONFIG_KSU_SUSFS_SUS_OVERLAYFS=n" >> ./common/arch/arm64/configs/gki_defconfig
  281. echo "CONFIG_KSU_SUSFS_TRY_UMOUNT=y" >> ./common/arch/arm64/configs/gki_defconfig
  282. echo "CONFIG_KSU_SUSFS_AUTO_ADD_TRY_UMOUNT_FOR_BIND_MOUNT=y" >> ./common/arch/arm64/configs/gki_defconfig
  283. echo "CONFIG_KSU_SUSFS_SPOOF_UNAME=y" >> ./common/arch/arm64/configs/gki_defconfig
  284. echo "CONFIG_KSU_SUSFS_ENABLE_LOG=y" >> ./common/arch/arm64/configs/gki_defconfig
  285. echo "CONFIG_KSU_SUSFS_HIDE_KSU_SUSFS_SYMBOLS=y" >> ./common/arch/arm64/configs/gki_defconfig
  286. echo "CONFIG_KSU_SUSFS_SPOOF_CMDLINE_OR_BOOTCONFIG=y" >> ./common/arch/arm64/configs/gki_defconfig
  287. echo "CONFIG_KSU_SUSFS_OPEN_REDIRECT=y" >> ./common/arch/arm64/configs/gki_defconfig
  288. if [ "${{ inputs.kernelsu_variant }}" == "NEXT" ]; then
  289. echo "CONFIG_KSU_SUSFS_SUS_SU=n" >> ./common/arch/arm64/configs/gki_defconfig
  290. else
  291. echo "CONFIG_KSU_SUSFS_SUS_SU=y" >> ./common/arch/arm64/configs/gki_defconfig
  292. fi
  293. - name: Change Kernel Name
  294. run: |
  295. cd "$CONFIG"
  296. # modify UTS_VERSION
  297. perl -pi -e 's{UTS_VERSION="\$\(echo \$UTS_VERSION \$CONFIG_FLAGS \$TIMESTAMP \| cut -b -\$UTS_LEN\)"}{UTS_VERSION="#1 SMP PREEMPT Sat Apr 20 04:20:00 UTC 2024"}' ./common/scripts/mkcompile_h
  298. sed -i '$s|echo "\$res"|echo "\$res-Wild"|' ./common/scripts/setlocalversion
  299. if [ -f "build/build.sh" ]; then
  300. sed -i 's/-dirty//' ./common/scripts/setlocalversion
  301. else
  302. sed -i '/^[[:space:]]*"protected_exports_list"[[:space:]]*:[[:space:]]*"android\/abi_gki_protected_exports_aarch64",$/d' ./common/BUILD.bazel
  303. rm -rf ./common/android/abi_gki_protected_exports_*
  304. sed -i "/stable_scmversion_cmd/s/-maybe-dirty//g" ./build/kernel/kleaf/impl/stamp.bzl
  305. sed -E -i '/^CONFIG_LOCALVERSION=/ s/(.*)"$/\1-Wild"/' ./common/arch/arm64/configs/gki_defconfig
  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 CC="/usr/bin/ccache clang" || exit 1
  315. else
  316. tools/bazel build --disk_cache=/home/runner/.cache/bazel --config=fast --lto=thin //common:kernel_aarch64_dist || exit 1
  317. fi
  318. ccache --show-stats
  319. - name: Create Bootimgs Folder and Copy Images for Android 12/13
  320. if: ${{ inputs.android_version == 'android12' || inputs.android_version == 'android13' }}
  321. run: |
  322. mkdir bootimgs
  323. echo "Creating bootimgs folder and copying images..."
  324. cp ./$CONFIG/out/${{ inputs.android_version }}-${{ inputs.kernel_version }}/dist/Image ./bootimgs
  325. cp ./$CONFIG/out/${{ inputs.android_version }}-${{ inputs.kernel_version }}/dist/Image.lz4 ./bootimgs
  326. cp ./$CONFIG/out/${{ inputs.android_version }}-${{ inputs.kernel_version }}/dist/Image ./
  327. cp ./$CONFIG/out/${{ inputs.android_version }}-${{ inputs.kernel_version }}/dist/Image.lz4 ./
  328. # Create gzip of the Image file
  329. gzip -n -k -f -9 ./Image > ./Image.gz
  330. - name: Create Bootimgs Folder and Copy Images for Android 14/15
  331. if: ${{ inputs.android_version == 'android14' || inputs.android_version == 'android15' }}
  332. run: |
  333. mkdir bootimgs
  334. echo "Creating bootimgs folder and copying images..."
  335. cp ./$CONFIG/bazel-bin/common/kernel_aarch64/Image ./bootimgs
  336. cp ./$CONFIG/bazel-bin/common/kernel_aarch64/Image.lz4 ./bootimgs
  337. cp ./$CONFIG/bazel-bin/common/kernel_aarch64/Image ./
  338. cp ./$CONFIG/bazel-bin/common/kernel_aarch64/Image.lz4 ./
  339. # Create gzip of the Image file
  340. gzip -n -k -f -9 ./Image > ./Image.gz
  341. - name: Create ZIP Files for Different Formats
  342. run: |
  343. echo "Creating zip files for all formats..."
  344. cd ./AnyKernel3
  345. # Create and upload zip for each format
  346. ZIP_NAME="${{ inputs.kernelsu_variant }}-${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ inputs.sub_level }}-${{ inputs.os_patch_level }}-AnyKernel3.zip"
  347. echo "Creating zip file: $ZIP_NAME..."
  348. mv ../Image ./Image
  349. zip -r "../$ZIP_NAME" ./*
  350. rm ./Image
  351. ZIP_NAME="${{ inputs.kernelsu_variant }}-${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ inputs.sub_level }}-${{ inputs.os_patch_level }}-AnyKernel3-lz4.zip"
  352. echo "Creating zip file: $ZIP_NAME..."
  353. mv ../Image.lz4 ./Image.lz4
  354. zip -r "../$ZIP_NAME" ./*
  355. rm ./Image.lz4
  356. ZIP_NAME="${{ inputs.kernelsu_variant }}-${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ inputs.sub_level }}-${{ inputs.os_patch_level }}-AnyKernel3-gz.zip"
  357. echo "Creating zip file: $ZIP_NAME..."
  358. mv ../Image.gz ./Image.gz
  359. zip -r "../$ZIP_NAME" ./*
  360. rm ./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. GKI_URL=https://dl.google.com/android/gki/gki-certified-boot-android12-5.10-"${{ inputs.os_patch_level }}"_"${{ inputs.revision }}".zip
  367. FALLBACK_URL=https://dl.google.com/android/gki/gki-certified-boot-android12-5.10-2023-01_r1.zip
  368. # Check if the GKI URL is available
  369. echo "Checking if GKI kernel URL is reachable: $GKI_URL"
  370. status=$(curl -sL -w "%{http_code}" "$GKI_URL" -o /dev/null)
  371. if [ "$status" = "200" ]; then
  372. echo "[+] Downloading from GKI_URL"
  373. curl -Lo gki-kernel.zip "$GKI_URL"
  374. else
  375. echo "[+] $GKI_URL not found, using $FALLBACK_URL"
  376. curl -Lo gki-kernel.zip "$FALLBACK_URL"
  377. fi
  378. # Unzip the downloaded kernel and remove the zip
  379. echo "Unzipping the downloaded kernel..."
  380. unzip gki-kernel.zip && rm gki-kernel.zip
  381. echo "Unpacking boot.img..."
  382. FULL_PATH=$(pwd)/boot-5.10.img
  383. echo "Unpacking using: $FULL_PATH"
  384. echo "Running unpack_bootimg.py..."
  385. $UNPACK_BOOTIMG --boot_img="$FULL_PATH"
  386. # Create gzip of the Image file
  387. gzip -n -k -f -9 ./Image > ./Image.gz
  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 ../${{ inputs.kernelsu_variant }}-${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ inputs.sub_level }}-${{ inputs.os_patch_level }}-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 ../${{ inputs.kernelsu_variant }}-${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ inputs.sub_level }}-${{ inputs.os_patch_level }}-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 ../${{ inputs.kernelsu_variant }}-${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ inputs.sub_level }}-${{ inputs.os_patch_level }}-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. # Create gzip of the Image file
  405. gzip -n -k -f -9 ./Image > ./Image.gz
  406. echo "Building boot.img"
  407. $MKBOOTIMG --header_version 4 --kernel Image --output boot.img
  408. $AVBTOOL add_hash_footer --partition_name boot --partition_size $((64 * 1024 * 1024)) --image boot.img --algorithm SHA256_RSA2048 --key $BOOT_SIGN_KEY_PATH
  409. cp ./boot.img ../${{ inputs.kernelsu_variant }}-${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ inputs.sub_level }}-${{ inputs.os_patch_level }}-boot.img
  410. echo "Building boot-gz.img"
  411. $MKBOOTIMG --header_version 4 --kernel Image.gz --output boot-gz.img
  412. $AVBTOOL add_hash_footer --partition_name boot --partition_size $((64 * 1024 * 1024)) --image boot-gz.img --algorithm SHA256_RSA2048 --key $BOOT_SIGN_KEY_PATH
  413. cp ./boot-gz.img ../${{ inputs.kernelsu_variant }}-${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ inputs.sub_level }}-${{ inputs.os_patch_level }}-boot-gz.img
  414. echo "Building boot-lz4.img"
  415. $MKBOOTIMG --header_version 4 --kernel Image.lz4 --output boot-lz4.img
  416. $AVBTOOL add_hash_footer --partition_name boot --partition_size $((64 * 1024 * 1024)) --image boot-lz4.img --algorithm SHA256_RSA2048 --key $BOOT_SIGN_KEY_PATH
  417. cp ./boot-lz4.img ../${{ inputs.kernelsu_variant }}-${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ inputs.sub_level }}-${{ inputs.os_patch_level }}-boot-lz4.img
  418. - name: Compress all img files with gzip
  419. run: |
  420. for image in *.img; do
  421. gzip -vnf9 "$image"
  422. done
  423. - name: Upload Build Artifacts
  424. uses: actions/upload-artifact@v4
  425. with:
  426. name: ${{ inputs.kernelsu_variant }}-kernel-${{ env.CONFIG }}
  427. path: |
  428. *.zip
  429. *.img.gz
  430. *Image*