gki-kernel.yml 22 KB

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