gki-kernel.yml 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481
  1. name: GKI Kernel Build
  2. permissions:
  3. contents: write # Allow writing to repository contents (for pushing tags)
  4. actions: write # Allows triggering actions
  5. on:
  6. workflow_call: # This allows this workflow to be called from another workflow
  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. runner:
  21. required: true
  22. type: string
  23. lto_type:
  24. required: true
  25. type: string
  26. kernelsu_variant:
  27. required: true
  28. type: string
  29. kernelsu_branch:
  30. required: true
  31. type: string
  32. kernelsu_branch_other:
  33. required: false
  34. type: string
  35. jobs:
  36. build-kernel-kernelsu-susfs:
  37. runs-on: ${{ inputs.runner }}
  38. steps:
  39. - name: Maximize build space
  40. if: ${{ inputs.runner == 'ubuntu-22.04' }}
  41. uses: easimon/maximize-build-space@master
  42. with:
  43. root-reserve-mb: 8192
  44. temp-reserve-mb: 2048
  45. swap-size-mb: 8192
  46. remove-dotnet: "true"
  47. remove-android: "true"
  48. remove-haskell: "true"
  49. remove-codeql: "true"
  50. - name: Clean up workspace
  51. run: rm -rf ${{ github.workspace }}/*
  52. - name: Set CONFIG Environment Variable
  53. run: |
  54. # Set CONFIG dynamically based on inputs values
  55. CONFIG="${{ inputs.android_version }}-${{ inputs.kernel_version }}-${{ inputs.sub_level }}"
  56. # Set CONFIG as an environment variable for future steps
  57. echo "CONFIG=$CONFIG" >> $GITHUB_ENV
  58. echo "CONFIG set to: $CONFIG"
  59. - name: Cache toolchain
  60. id: cache-toolchain
  61. uses: actions/cache@v4
  62. with:
  63. path: |
  64. kernel-build-tools
  65. mkbootimg
  66. key: toolchain-${{ runner.os }}-v1
  67. # Step 2: Download toolchain if cache was not found
  68. - name: Download toolchain (if cache not found)
  69. if: steps.cache-toolchain.outputs.cache-hit != 'true'
  70. run: |
  71. AOSP_MIRROR=https://android.googlesource.com
  72. BRANCH=main-kernel-build-2024
  73. git clone $AOSP_MIRROR/kernel/prebuilts/build-tools -b $BRANCH --depth 1 kernel-build-tools
  74. git clone $AOSP_MIRROR/platform/system/tools/mkbootimg -b $BRANCH --depth 1 mkbootimg
  75. - name: Set environment variables
  76. run: |
  77. echo "AVBTOOL=$GITHUB_WORKSPACE/kernel-build-tools/linux-x86/bin/avbtool" >> $GITHUB_ENV
  78. echo "MKBOOTIMG=$GITHUB_WORKSPACE/mkbootimg/mkbootimg.py" >> $GITHUB_ENV
  79. echo "UNPACK_BOOTIMG=$GITHUB_WORKSPACE/mkbootimg/unpack_bootimg.py" >> $GITHUB_ENV
  80. - name: Set boot sign key
  81. env:
  82. BOOT_SIGN_KEY: ${{ secrets.BOOT_SIGN_KEY }}
  83. run: |
  84. if [ ! -z "$BOOT_SIGN_KEY" ]; then
  85. echo "$BOOT_SIGN_KEY" > ./kernel-build-tools/linux-x86/share/avb/testkey_rsa2048.pem
  86. echo "BOOT_SIGN_KEY_PATH=$GITHUB_WORKSPACE/kernel-build-tools/linux-x86/share/avb/testkey_rsa2048.pem" >> $GITHUB_ENV
  87. else
  88. echo "BOOT_SIGN_KEY is not set. Exiting..."
  89. exit 1
  90. fi
  91. - name: Install Repo
  92. run: |
  93. # Install dependencies
  94. mkdir -p ./git-repo
  95. curl https://storage.googleapis.com/git-repo-downloads/repo > ./git-repo/repo
  96. chmod a+rx ./git-repo/repo
  97. echo "REPO=$GITHUB_WORKSPACE/./git-repo/repo" >> $GITHUB_ENV
  98. - name: Clone AnyKernel3 and Other Dependencies
  99. run: |
  100. echo "Cloning AnyKernel3 and other dependencies..."
  101. # Define the branch names using the inputs values
  102. ANYKERNEL_BRANCH="${{ inputs.android_version }}-${{ inputs.kernel_version }}"
  103. SUSFS_BRANCH="gki-${{ inputs.android_version }}-${{ inputs.kernel_version }}"
  104. # Debug print the branches
  105. echo "Using branch for AnyKernel3: $ANYKERNEL_BRANCH"
  106. echo "Using branch for SUSFS: $SUSFS_BRANCH"
  107. # Clone repositories using the branch names
  108. git clone https://github.com/WildPlusKernel/AnyKernel3.git -b "$ANYKERNEL_BRANCH"
  109. git clone https://gitlab.com/simonpunk/susfs4ksu.git -b "$SUSFS_BRANCH"
  110. git clone https://github.com/WildPlusKernel/kernel_patches.git
  111. git clone https://github.com/firelzrd/bore-scheduler.git
  112. - name: Set CONFIG Environment Variable
  113. run: |
  114. # Set CONFIG dynamically based on inputs values
  115. CONFIG="${{ inputs.android_version }}-${{ inputs.kernel_version }}-${{ inputs.sub_level }}"
  116. # Set CONFIG as an environment variable for future steps
  117. echo "CONFIG=$CONFIG" >> $GITHUB_ENV
  118. echo "CONFIG set to: $CONFIG"
  119. - name: Initialize and Sync Kernel Source
  120. run: |
  121. echo "Creating folder for configuration: $CONFIG..."
  122. mkdir -p "$CONFIG"
  123. cd "$CONFIG"
  124. # Initialize and sync kernel source
  125. echo "Initializing and syncing kernel source..."
  126. FORMATTED_BRANCH="${{ inputs.android_version }}-${{ inputs.kernel_version }}-${{ inputs.os_patch_level }}"
  127. $REPO init --depth=1 --u https://android.googlesource.com/kernel/manifest -b common-${FORMATTED_BRANCH} --repo-rev=v2.16
  128. REMOTE_BRANCH=$(git ls-remote https://android.googlesource.com/kernel/common ${FORMATTED_BRANCH})
  129. DEFAULT_MANIFEST_PATH=.repo/manifests/default.xml
  130. # Check if branch is deprecated
  131. if grep -q deprecated <<< $REMOTE_BRANCH; then
  132. echo "Found deprecated branch: $FORMATTED_BRANCH"
  133. sed -i "s/\"${FORMATTED_BRANCH}\"/\"deprecated\/${FORMATTED_BRANCH}\"/g" $DEFAULT_MANIFEST_PATH
  134. fi
  135. # Sync repo and apply patches
  136. $REPO --version
  137. $REPO --trace sync -c -j$(nproc --all) --no-tags --fail-fast
  138. - name: Determine the branch for KernelSU
  139. run: |
  140. if [[ "${{ inputs.kernelsu_branch }}" == "Stable" ]]; then
  141. echo "BRANCH=-" >> $GITHUB_ENV
  142. elif [[ "${{ inputs.kernelsu_branch }}" == "Dev" && ( "${{ inputs.kernelsu_variant }}" == "Official" || "${{ inputs.kernelsu_variant }}" == "MKSU" ) ]]; then
  143. echo "BRANCH=-s main" >> $GITHUB_ENV
  144. elif [[ "${{ inputs.kernelsu_branch }}" == "Dev" && "${{ inputs.kernelsu_variant }}" == "Next" ]]; then
  145. echo "BRANCH=-s main" >> $GITHUB_ENV
  146. elif [[ "${{ inputs.kernelsu_branch }}" == "Other" && -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. - name: Add KernelSU
  153. run: |
  154. echo "Changing to configuration directory: $CONFIG..."
  155. cd "$CONFIG"
  156. if [ "${{ inputs.kernelsu_variant }}" == "Official" ]; then
  157. echo "Adding KernelSU Official..."
  158. curl -LSs "https://raw.githubusercontent.com/tiann/KernelSU/main/kernel/setup.sh" | bash $BRANCH
  159. elif [ "${{ inputs.kernelsu_variant }}" == "Next" ]; then
  160. echo "Adding KernelSU Next..."
  161. curl -LSs "https://raw.githubusercontent.com/rifsxd/KernelSU-Next/next/kernel/setup.sh" | bash $BRANCH
  162. elif [ "${{ inputs.kernelsu_variant }}" == "MKSU" ]; then
  163. echo "Adding KernelSU MKSU..."
  164. curl -LSs "https://raw.githubusercontent.com/5ec1cff/KernelSU/main/kernel/setup.sh" | bash $BRANCH
  165. # Revert commit of remove pts_unix98_lookup_pre
  166. cd KernelSU
  167. git revert -m 1 $(git log --grep="remove devpts hook" --pretty=format:"%h") -n
  168. KSU_VERSION=$(expr $(/usr/bin/git rev-list --count HEAD) "+" 12063)
  169. echo "KSUVER=$KSU_VERSION" >> $GITHUB_ENV
  170. sed -i "s/DKSU_VERSION=16/DKSU_VERSION=${KSU_VERSION}/" kernel/Makefile
  171. else
  172. echo "Invalid KernelSU variant selected!"
  173. exit 1
  174. fi
  175. - name: Apply SUSFS Patches for KernelSU Variants
  176. run: |
  177. echo "Changing to configuration directory: $CONFIG..."
  178. cd "$CONFIG"
  179. echo "Applying SUSFS patches..."
  180. # Copy SUSFS patches
  181. cp ../susfs4ksu/kernel_patches/50_add_susfs_in_gki-${{ inputs.android_version }}-${{ inputs.kernel_version }}.patch ./common/
  182. cp ../susfs4ksu/kernel_patches/fs/* ./common/fs/
  183. cp ../susfs4ksu/kernel_patches/include/linux/* ./common/include/linux/
  184. if [ "${{ inputs.kernelsu_variant }}" == "Official" ]; then
  185. echo "Applying SUSFS patches for Official KernelSU..."
  186. cp ../susfs4ksu/kernel_patches/KernelSU/10_enable_susfs_for_ksu.patch ./KernelSU/
  187. cd ./KernelSU
  188. patch -p1 --forward < 10_enable_susfs_for_ksu.patch
  189. elif [ "${{ inputs.kernelsu_variant }}" == "Next" ]; then
  190. echo "Applying SUSFS patches for KernelSU-Next..."
  191. cd ./KernelSU-Next
  192. cp ../../kernel_patches/KernelSU-Next-Implement-SUSFS-v1.5.5-Universal.patch ./
  193. patch -p1 --forward < KernelSU-Next-Implement-SUSFS-v1.5.5-Universal.patch || true
  194. elif [ "${{ inputs.kernelsu_variant }}" == "MKSU" ]; then
  195. echo "Applying SUSFS patches for MKSU..."
  196. cp ../susfs4ksu/kernel_patches/KernelSU/10_enable_susfs_for_ksu.patch ./KernelSU/
  197. cd ./KernelSU
  198. patch -p1 --forward < 10_enable_susfs_for_ksu.patch || true
  199. echo "Applying MKSU specific SUSFS patch..."
  200. cp ../../kernel_patches/mksu_susfs.patch ../KernelSU/
  201. patch -p1 < mksu_susfs.patch
  202. else
  203. echo "Invalid KernelSU variant selected!"
  204. exit 1
  205. fi
  206. # Change to common directory and apply common SUSFS patch
  207. cd ../common
  208. patch -p1 < 50_add_susfs_in_gki-${{ inputs.android_version }}-${{ inputs.kernel_version }}.patch || true
  209. - name: Apply Hide Stuff Patches
  210. run: |
  211. echo "Changing to configuration directory: $CONFIG..."
  212. cd "$CONFIG/common"
  213. # Apply additional patch
  214. cp ../../kernel_patches/69_hide_stuff.patch ./
  215. patch -p1 -F 3 < 69_hide_stuff.patch
  216. - name: BORE?
  217. run: |
  218. echo "Changing to configuration directory: $CONFIG..."
  219. cd "$CONFIG/common"
  220. if [[ "${{ inputs.kernel_version }}" == "5.10" || ( "${{ inputs.kernel_version }}" == "5.15" && "${{ inputs.android_version }}" == "android13" ) ]]; then
  221. cp ../../kernel_patches/0001-linux5.10.y-bore5.1.0.patch ./
  222. cp ../../kernel_patches/0002-constgran-vanilla-max-android-5.10.patch ./
  223. echo "Patch1"
  224. patch -p1 -F 3 < 0001-linux5.15.y-bore5.1.0.patch
  225. echo "Patch2"
  226. patch -p1 -F 3 < 0002-constgran-vanilla-max-android-5.10.patch
  227. elif [[ "${{ inputs.kernel_version }}" == "5.15" && "${{ inputs.android_version }}" == "android14" && "${{ inputs.sub_level }}" < "144" ]]; then
  228. cp ../../kernel_patches/0001-linux5.15.y-bore5.1.0.patch ./
  229. cp ../../kernel_patches/0002-constgran-vanilla-max-android-5.10.patch ./
  230. echo "Patch1"
  231. patch -p1 -F 3 < 0001-linux5.15.y-bore5.1.0.patch
  232. echo "Patch2"
  233. patch -p1 -F 3 < 0002-constgran-vanilla-max-android-5.10.patch
  234. elif [[ "${{ inputs.kernel_version }}" == "5.15" ]]; then
  235. cp ../../kernel_patches/0001-linux5.15.y-bore5.1.0.patch ./
  236. cp ../../kernel_patches/0002-constgran-vanilla-max-android-5.15.patch ./
  237. echo "Patch1"
  238. patch -p1 -F 3 < 0001-linux5.15.y-bore5.1.0.patch
  239. echo "Patch2"
  240. patch -p1 -F 3 < 0002-constgran-vanilla-max-android-5.15.patch
  241. elif [[ "${{ inputs.kernel_version }}" == "6.1" ]]; then
  242. cp ../../bore-scheduler/patches/legacy/linux-6.1-bore/0001-linux6.1.y-bore5.1.0.patch ./
  243. cp ../../kernel_patches/0002-constgran-vanilla-max-android.patch ./
  244. echo "Patch1"
  245. patch -p1 -F 3 < 0001-linux6.1.y-bore5.1.0.patch
  246. echo "Patch2"
  247. patch -p1 -F 3 < 0002-constgran-vanilla-max-android.patch
  248. elif [[ "${{ inputs.kernel_version }}" == "6.6" ]]; then
  249. cp ../../bore-scheduler/patches/stable/linux-6.6-bore/0001-linux6.6.67-bore5.9.6.patch ./
  250. echo "Patch1"
  251. patch -p1 -F 3 < 0001-linux6.6.67-bore5.9.6.patch
  252. fi
  253. - name: Add SUSFS Configuration Settings
  254. run: |
  255. echo "Changing to configuration directory: $CONFIG..."
  256. cd "$CONFIG"
  257. echo "Adding configuration settings to gki_defconfig..."
  258. # Add SUSFS configuration settings
  259. echo "CONFIG_KSU=y" >> ./common/arch/arm64/configs/gki_defconfig
  260. echo "CONFIG_KSU_SUSFS=y" >> ./common/arch/arm64/configs/gki_defconfig
  261. echo "CONFIG_KSU_SUSFS_HAS_MAGIC_MOUNT=y" >> ./common/arch/arm64/configs/gki_defconfig
  262. echo "CONFIG_KSU_SUSFS_SUS_PATH=y" >> ./common/arch/arm64/configs/gki_defconfig
  263. echo "CONFIG_KSU_SUSFS_SUS_MOUNT=y" >> ./common/arch/arm64/configs/gki_defconfig
  264. echo "CONFIG_KSU_SUSFS_AUTO_ADD_SUS_KSU_DEFAULT_MOUNT=y" >> ./common/arch/arm64/configs/gki_defconfig
  265. echo "CONFIG_KSU_SUSFS_AUTO_ADD_SUS_BIND_MOUNT=y" >> ./common/arch/arm64/configs/gki_defconfig
  266. echo "CONFIG_KSU_SUSFS_SUS_KSTAT=y" >> ./common/arch/arm64/configs/gki_defconfig
  267. echo "CONFIG_KSU_SUSFS_SUS_OVERLAYFS=n" >> ./common/arch/arm64/configs/gki_defconfig
  268. echo "CONFIG_KSU_SUSFS_TRY_UMOUNT=y" >> ./common/arch/arm64/configs/gki_defconfig
  269. echo "CONFIG_KSU_SUSFS_AUTO_ADD_TRY_UMOUNT_FOR_BIND_MOUNT=y" >> ./common/arch/arm64/configs/gki_defconfig
  270. echo "CONFIG_KSU_SUSFS_SPOOF_UNAME=y" >> ./common/arch/arm64/configs/gki_defconfig
  271. echo "CONFIG_KSU_SUSFS_ENABLE_LOG=y" >> ./common/arch/arm64/configs/gki_defconfig
  272. echo "CONFIG_KSU_SUSFS_HIDE_KSU_SUSFS_SYMBOLS=y" >> ./common/arch/arm64/configs/gki_defconfig
  273. echo "CONFIG_KSU_SUSFS_SPOOF_CMDLINE_OR_BOOTCONFIG=y" >> ./common/arch/arm64/configs/gki_defconfig
  274. echo "CONFIG_KSU_SUSFS_OPEN_REDIRECT=y" >> ./common/arch/arm64/configs/gki_defconfig
  275. echo "CONFIG_KSU_SUSFS_SUS_SU=y" >> ./common/arch/arm64/configs/gki_defconfig
  276. # Add additional tmpfs config setting
  277. echo "CONFIG_TMPFS_XATTR=y" >> ./common/arch/arm64/configs/gki_defconfig
  278. echo "CONFIG_TMPFS_POSIX_ACL=y" >> ./common/arch/arm64/configs/gki_defconfig
  279. # Remove check_defconfig
  280. sed -i 's/check_defconfig//' ./common/build.config.gki
  281. - name: Build the Kernel
  282. run: |
  283. echo "Changing to configuration directory: $CONFIG..."
  284. cd "$CONFIG"
  285. sed -i '$s|echo "\$res"|echo "\$res-Wild+"|' ./common/scripts/setlocalversion
  286. # Run perl command to modify UTS_VERSION
  287. 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
  288. echo "Building the kernel..."
  289. if [ -f "build/build.sh" ]; then
  290. sed -i 's/-dirty//' ./common/scripts/setlocalversion
  291. LTO=${{ inputs.lto_type }} BUILD_CONFIG=common/build.config.gki.aarch64 build/build.sh
  292. else
  293. rm -rf ./common/android/abi_gki_protected_exports_*
  294. sed -i "/stable_scmversion_cmd/s/-maybe-dirty//g" ./build/kernel/kleaf/impl/stamp.bzl
  295. tools/bazel build --config=fast --lto=${{ inputs.lto_type }} //common:kernel_aarch64_dist
  296. fi
  297. - name: Create Bootimgs Folder and Copy Images
  298. if: ${{ inputs.android_version == 'android12' || inputs.android_version == 'android13' }}
  299. run: |
  300. echo "Changing to configuration directory: $CONFIG..."
  301. mkdir bootimgs
  302. echo "Creating bootimgs folder and copying images..."
  303. cp ./$CONFIG/out/${{ inputs.android_version }}-${{ inputs.kernel_version }}/dist/Image ./bootimgs
  304. cp ./$CONFIG/out/${{ inputs.android_version }}-${{ inputs.kernel_version }}/dist/Image.lz4 ./bootimgs
  305. cp ./$CONFIG/out/${{ inputs.android_version }}-${{ inputs.kernel_version }}/dist/Image ./
  306. cp ./$CONFIG/out/${{ inputs.android_version }}-${{ inputs.kernel_version }}/dist/Image.lz4 ./
  307. # Create gzip of the Image file
  308. gzip -n -k -f -9 ./Image > ./Image.gz
  309. - name: Create Bootimgs Folder and Copy Images
  310. if: ${{ inputs.android_version == 'android14' || inputs.android_version == 'android15' }}
  311. run: |
  312. echo "Changing to configuration directory: $CONFIG..."
  313. mkdir bootimgs
  314. echo "Creating bootimgs folder and copying images..."
  315. cp ./$CONFIG/bazel-bin/common/kernel_aarch64/Image ./bootimgs
  316. cp ./$CONFIG/bazel-bin/common/kernel_aarch64/Image.lz4 ./bootimgs
  317. cp ./$CONFIG/bazel-bin/common/kernel_aarch64/Image ./
  318. cp ./$CONFIG/bazel-bin/common/kernel_aarch64/Image.lz4 ./
  319. # Create gzip of the Image file
  320. gzip -n -k -f -9 ./Image > ./Image.gz
  321. - name: Create ZIP Files for Different Formats
  322. run: |
  323. echo "Creating zip files for all formats..."
  324. cd ./AnyKernel3
  325. # Create and upload zip for each format
  326. ZIP_NAME="${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ inputs.sub_level }}-${{ inputs.os_patch_level }}-AnyKernel3.zip"
  327. echo "Creating zip file: $ZIP_NAME..."
  328. mv ../Image ./Image
  329. zip -r "../$ZIP_NAME" ./*
  330. rm ./Image
  331. ZIP_NAME="${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ inputs.sub_level }}-${{ inputs.os_patch_level }}-AnyKernel3-lz4.zip"
  332. echo "Creating zip file: $ZIP_NAME..."
  333. mv ../Image.lz4 ./Image.lz4
  334. zip -r "../$ZIP_NAME" ./*
  335. rm ./Image.lz4
  336. ZIP_NAME="${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ inputs.sub_level }}-${{ inputs.os_patch_level }}-AnyKernel3-gz.zip"
  337. echo "Creating zip file: $ZIP_NAME..."
  338. mv ../Image.gz ./Image.gz
  339. zip -r "../$ZIP_NAME" ./*
  340. rm ./Image.gz
  341. - name: Run Boot Image ${{ inputs.android_version }} Build Script
  342. if: ${{ inputs.android_version == 'android12' }}
  343. run: |
  344. echo "Changing to configuration directory: $CONFIG..."
  345. cd bootimgs
  346. GKI_URL=https://dl.google.com/android/gki/gki-certified-boot-android12-5.10-"${{ inputs.os_patch_level }}"_r1.zip
  347. FALLBACK_URL=https://dl.google.com/android/gki/gki-certified-boot-android12-5.10-2023-01_r1.zip
  348. # Check if the GKI URL is available
  349. echo "Checking if GKI kernel URL is reachable: $GKI_URL"
  350. status=$(curl -sL -w "%{http_code}" "$GKI_URL" -o /dev/null)
  351. if [ "$status" = "200" ]; then
  352. echo "[+] Downloading from GKI_URL"
  353. curl -Lo gki-kernel.zip "$GKI_URL"
  354. else
  355. echo "[+] $GKI_URL not found, using $FALLBACK_URL"
  356. curl -Lo gki-kernel.zip "$FALLBACK_URL"
  357. fi
  358. # Unzip the downloaded kernel and remove the zip
  359. echo "Unzipping the downloaded kernel..."
  360. unzip gki-kernel.zip && rm gki-kernel.zip
  361. echo "Unpacking boot.img..."
  362. FULL_PATH=$(pwd)/boot-5.10.img
  363. echo "Unpacking using: $FULL_PATH"
  364. echo "Running unpack_bootimg.py..."
  365. $UNPACK_BOOTIMG --boot_img="$FULL_PATH"
  366. echo "Building Image.gz"
  367. gzip -n -k -f -9 ./Image > ./Image.gz
  368. echo "Building boot.img"
  369. $MKBOOTIMG --header_version 4 --kernel Image --output boot.img --ramdisk out/ramdisk --os_version 12.0.0 --os_patch_level "${{ inputs.os_patch_level }}"
  370. $AVBTOOL add_hash_footer --partition_name boot --partition_size $((64 * 1024 * 1024)) --image boot.img --algorithm SHA256_RSA2048 --key $BOOT_SIGN_KEY_PATH
  371. cp ./boot.img ../${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ inputs.sub_level }}-${{ inputs.os_patch_level }}-boot.img
  372. echo "Building boot-gz.img"
  373. $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 }}"
  374. $AVBTOOL add_hash_footer --partition_name boot --partition_size $((64 * 1024 * 1024)) --image boot-gz.img --algorithm SHA256_RSA2048 --key $BOOT_SIGN_KEY_PATH
  375. cp ./boot-gz.img ../${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ inputs.sub_level }}-${{ inputs.os_patch_level }}-boot-gz.img
  376. echo "Building boot-lz4.img"
  377. $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 }}"
  378. $AVBTOOL add_hash_footer --partition_name boot --partition_size $((64 * 1024 * 1024)) --image boot-lz4.img --algorithm SHA256_RSA2048 --key $BOOT_SIGN_KEY_PATH
  379. cp ./boot-lz4.img ../${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ inputs.sub_level }}-${{ inputs.os_patch_level }}-boot-lz4.img
  380. - name: Run Boot Image ${{ inputs.android_version }} Build Script
  381. if: ${{ inputs.android_version == 'android13' || inputs.android_version == 'android14' || inputs.android_version == 'android15' }}
  382. run: |
  383. cd bootimgs
  384. echo "Building Image.gz"
  385. gzip -n -k -f -9 ./Image > ./Image.gz
  386. echo "Building boot.img"
  387. $MKBOOTIMG --header_version 4 --kernel Image --output boot.img
  388. $AVBTOOL add_hash_footer --partition_name boot --partition_size $((64 * 1024 * 1024)) --image boot.img --algorithm SHA256_RSA2048 --key $BOOT_SIGN_KEY_PATH
  389. cp ./boot.img ../${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ inputs.sub_level }}-${{ inputs.os_patch_level }}-boot.img
  390. echo "Building boot-gz.img"
  391. $MKBOOTIMG --header_version 4 --kernel Image.gz --output boot-gz.img
  392. $AVBTOOL add_hash_footer --partition_name boot --partition_size $((64 * 1024 * 1024)) --image boot-gz.img --algorithm SHA256_RSA2048 --key $BOOT_SIGN_KEY_PATH
  393. cp ./boot-gz.img ../${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ inputs.sub_level }}-${{ inputs.os_patch_level }}-boot-gz.img
  394. echo "Building boot-lz4.img"
  395. $MKBOOTIMG --header_version 4 --kernel Image.lz4 --output boot-lz4.img
  396. $AVBTOOL add_hash_footer --partition_name boot --partition_size $((64 * 1024 * 1024)) --image boot-lz4.img --algorithm SHA256_RSA2048 --key $BOOT_SIGN_KEY_PATH
  397. cp ./boot-lz4.img ../${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ inputs.sub_level }}-${{ inputs.os_patch_level }}-boot-lz4.img
  398. - name: Upload Build Artifacts
  399. uses: actions/upload-artifact@v4
  400. with:
  401. name: kernel-${{ env.CONFIG }}
  402. path: |
  403. *.zip
  404. *.img