build.yml 24 KB

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