build.yml 24 KB

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