build.yml 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518
  1. name: Build Script
  2. permissions:
  3. contents: write
  4. actions: write
  5. on:
  6. workflow_call:
  7. inputs:
  8. android_version:
  9. required: true
  10. type: string
  11. kernel_version:
  12. required: true
  13. type: string
  14. sub_level:
  15. required: true
  16. type: string
  17. os_patch_level:
  18. required: true
  19. type: string
  20. kernelsu_variant:
  21. required: true
  22. type: string
  23. kernelsu_branch:
  24. required: true
  25. type: string
  26. kernelsu_branch_other:
  27. required: false
  28. type: string
  29. revision:
  30. required: false
  31. type: string
  32. jobs:
  33. build-gki:
  34. runs-on: ubuntu-latest
  35. timeout-minutes: 120
  36. env:
  37. CCACHE_COMPILERCHECK: "%compiler% -dumpmachine; %compiler% -dumpversion"
  38. CCACHE_NOHASHDIR: "true"
  39. CCACHE_HARDLINK: "true"
  40. steps:
  41. - name: Set CONFIG Environment Variable
  42. run: |
  43. # Set CONFIG dynamically based on inputs values
  44. CONFIG="${{ inputs.android_version }}-${{ inputs.kernel_version }}-${{ inputs.sub_level }}"
  45. # Set CONFIG as an environment variable for future steps
  46. echo "CONFIG=$CONFIG" >> $GITHUB_ENV
  47. echo "CONFIG set to: $CONFIG"
  48. - name: Install ccache
  49. run: sudo apt update && sudo apt install -y ccache
  50. - name: Set up ccache
  51. run: |
  52. mkdir -p ~/.cache/bazel
  53. ccache --version
  54. ccache --max-size=2G
  55. ccache --set-config=compression=true
  56. echo "CCACHE_DIR=$HOME/.ccache" >> $GITHUB_ENV
  57. - name: Restore ccache from cache
  58. uses: actions/cache@v4
  59. with:
  60. path: ~/.ccache
  61. key: ${{ inputs.android_version }}-${{ inputs.kernel_version }}-${{ inputs.sub_level }}-ccache-${{ github.sha }}
  62. restore-keys: |
  63. ${{ inputs.android_version }}-${{ inputs.kernel_version }}-${{ inputs.sub_level }}-ccache-
  64. - name: Cache toolchain
  65. id: cache-toolchain
  66. uses: actions/cache@v4
  67. with:
  68. path: |
  69. kernel-build-tools
  70. mkbootimg
  71. key: toolchain-${{ runner.os }}-v1
  72. - name: Download toolchain (if cache not found)
  73. if: steps.cache-toolchain.outputs.cache-hit != 'true'
  74. run: |
  75. AOSP_MIRROR=https://android.googlesource.com
  76. BRANCH=main-kernel-build-2024
  77. git clone $AOSP_MIRROR/kernel/prebuilts/build-tools -b $BRANCH --depth 1 kernel-build-tools
  78. git clone $AOSP_MIRROR/platform/system/tools/mkbootimg -b $BRANCH --depth 1 mkbootimg
  79. - name: Set environment variables
  80. run: |
  81. echo "AVBTOOL=$GITHUB_WORKSPACE/kernel-build-tools/linux-x86/bin/avbtool" >> $GITHUB_ENV
  82. echo "MKBOOTIMG=$GITHUB_WORKSPACE/mkbootimg/mkbootimg.py" >> $GITHUB_ENV
  83. echo "UNPACK_BOOTIMG=$GITHUB_WORKSPACE/mkbootimg/unpack_bootimg.py" >> $GITHUB_ENV
  84. - name: Set boot sign key
  85. env:
  86. BOOT_SIGN_KEY: ${{ secrets.BOOT_SIGN_KEY }}
  87. run: |
  88. if [ ! -z "$BOOT_SIGN_KEY" ]; then
  89. echo "$BOOT_SIGN_KEY" > ./kernel-build-tools/linux-x86/share/avb/testkey_rsa2048.pem
  90. echo "BOOT_SIGN_KEY_PATH=$GITHUB_WORKSPACE/kernel-build-tools/linux-x86/share/avb/testkey_rsa2048.pem" >> $GITHUB_ENV
  91. else
  92. echo "BOOT_SIGN_KEY is not set. Using AOSP sign key..."
  93. echo "BOOT_SIGN_KEY_PATH=$GITHUB_WORKSPACE/kernel-build-tools/linux-x86/share/avb/testkey_rsa2048.pem" >> $GITHUB_ENV
  94. fi
  95. - name: Install Repo
  96. run: |
  97. mkdir -p ./git-repo
  98. echo "Downloading repo tool..."
  99. curl https://storage.googleapis.com/git-repo-downloads/repo > ./git-repo/repo
  100. chmod a+rx ./git-repo/repo
  101. echo "REPO=$GITHUB_WORKSPACE/./git-repo/repo" >> $GITHUB_ENV
  102. - name: Clone AnyKernel3 and Other Dependencies
  103. run: |
  104. echo "Cloning AnyKernel3 and other dependencies..."
  105. ANYKERNEL_BRANCH="gki-2.0"
  106. SUSFS_BRANCH="gki-${{ inputs.android_version }}-${{ inputs.kernel_version }}"
  107. echo "Using branch for AnyKernel3: $ANYKERNEL_BRANCH"
  108. echo "Using branch for SUSFS: $SUSFS_BRANCH"
  109. git clone https://github.com/WildPlusKernel/AnyKernel3.git -b "$ANYKERNEL_BRANCH"
  110. git clone https://gitlab.com/simonpunk/susfs4ksu.git -b "$SUSFS_BRANCH"
  111. git clone https://github.com/WildPlusKernel/kernel_patches.git
  112. - name: Check Disk Space Before Sync
  113. run: |
  114. echo "Disk space before kernel source sync:"
  115. df -h
  116. - name: Initialize and Sync Kernel Source
  117. run: |
  118. echo "Creating folder for configuration: $CONFIG..."
  119. mkdir -p "$CONFIG"
  120. cd "$CONFIG"
  121. echo "Initializing and syncing kernel source..."
  122. FORMATTED_BRANCH="${{ inputs.android_version }}-${{ inputs.kernel_version }}-${{ inputs.os_patch_level }}"
  123. $REPO init --depth=1 --u https://android.googlesource.com/kernel/manifest -b common-${FORMATTED_BRANCH} --repo-rev=v2.16
  124. REMOTE_BRANCH=$(git ls-remote https://android.googlesource.com/kernel/common ${FORMATTED_BRANCH})
  125. DEFAULT_MANIFEST_PATH=.repo/manifests/default.xml
  126. if grep -q deprecated <<< $REMOTE_BRANCH; then
  127. echo "Found deprecated branch: $FORMATTED_BRANCH"
  128. sed -i "s/\"${FORMATTED_BRANCH}\"/\"deprecated\/${FORMATTED_BRANCH}\"/g" $DEFAULT_MANIFEST_PATH
  129. fi
  130. $REPO --version
  131. $REPO --trace sync -c -j$(nproc --all) --no-tags --fail-fast
  132. - name: Determine the branch for KernelSU
  133. run: |
  134. case "${{ inputs.kernelsu_branch }}" in
  135. "Stable")
  136. echo "BRANCH=-" >> $GITHUB_ENV
  137. ;;
  138. "Dev")
  139. if [[ "${{ inputs.kernelsu_variant }}" =~ ^(KSU|MKSU)$ ]]; then
  140. echo "BRANCH=-s main" >> $GITHUB_ENV
  141. elif [[ "${{ inputs.kernelsu_variant }}" == "NEXT" ]]; then
  142. echo "BRANCH=-s next" >> $GITHUB_ENV
  143. elif [[ "${{ inputs.kernelsu_variant }}" == "WILD" ]]; then
  144. echo "BRANCH=-s wild" >> $GITHUB_ENV
  145. fi
  146. ;;
  147. "Other")
  148. if [[ -n "${{ inputs.kernelsu_branch_other }}" ]]; then
  149. echo "BRANCH=-s ${{ inputs.kernelsu_branch_other }}" >> $GITHUB_ENV
  150. else
  151. echo "Error: Custom branch not provided for 'Other'" >&2
  152. exit 1
  153. fi
  154. ;;
  155. esac
  156. - name: Add KernelSU
  157. run: |
  158. echo "Changing to configuration directory: $CONFIG..."
  159. cd "$CONFIG"
  160. case "${{ inputs.kernelsu_variant }}" in
  161. "WILD")
  162. echo "Adding Wild KSU..."
  163. curl -LSs "https://raw.githubusercontent.com/WildKernels/Wild_KSU/refs/heads/wild/kernel/setup.sh" | bash ${{ env.BRANCH }}
  164. ;;
  165. "KSU")
  166. echo "Adding KernelSU Official..."
  167. curl -LSs "https://raw.githubusercontent.com/tiann/KernelSU/main/kernel/setup.sh" | bash ${{ env.BRANCH }}
  168. ;;
  169. "NEXT")
  170. echo "Adding KernelSU Next..."
  171. curl -LSs "https://raw.githubusercontent.com/KernelSU-Next/KernelSU-Next/next/kernel/setup.sh" | bash ${{ env.BRANCH }}
  172. ;;
  173. "MKSU")
  174. echo "Adding KernelSU MKSU..."
  175. curl -LSs "https://raw.githubusercontent.com/5ec1cff/KernelSU/main/kernel/setup.sh" | bash ${{ env.BRANCH }}
  176. ;;
  177. esac
  178. - name: Apply SUSFS Patches for KernelSU Variants
  179. run: |
  180. echo "Changing to configuration directory: $CONFIG..."
  181. cd "$CONFIG"
  182. echo "Applying SUSFS patches..."
  183. # Copy SUSFS patches
  184. cp ../susfs4ksu/kernel_patches/50_add_susfs_in_gki-${{ inputs.android_version }}-${{ inputs.kernel_version }}.patch ./common/
  185. cp ../susfs4ksu/kernel_patches/fs/* ./common/fs/
  186. cp ../susfs4ksu/kernel_patches/include/linux/* ./common/include/linux/
  187. case "${{ inputs.kernelsu_variant }}" in
  188. "WILD")
  189. echo "Applying SUSFS patches for Official KernelSU..."
  190. cd ./KernelSU
  191. cp ../../susfs4ksu/kernel_patches/KernelSU/10_enable_susfs_for_ksu.patch ./
  192. patch -p1 --forward --fuzz=3 < 10_enable_susfs_for_ksu.patch || true
  193. cp ../../kernel_patches/wild/fix.corehook.c.patch ./
  194. patch -p1 --forward --fuzz=3 < fix.corehook.c.patch
  195. cp ../../kernel_patches/wild/fix.selinux.c.patch ./
  196. patch -p1 --forward --fuzz=3 < fix.selinux.c.patch
  197. cp ../../kernel_patches/wild/fix.sucompat.c.patch ./
  198. patch -p1 --forward --fuzz=3 < fix.sucompat.c.patch
  199. ;;
  200. "KSU")
  201. echo "Applying SUSFS patches for Official KernelSU..."
  202. cd ./KernelSU
  203. cp ../../susfs4ksu/kernel_patches/KernelSU/10_enable_susfs_for_ksu.patch ./
  204. patch -p1 --forward --fuzz=3 < 10_enable_susfs_for_ksu.patch
  205. ;;
  206. "NEXT")
  207. echo "Applying SUSFS patches for KernelSU Next..."
  208. cd ./KernelSU-Next
  209. cp ../../kernel_patches/next/kernel-patch-susfs-v1.5.7-to-KernelSU-Next.patch ./
  210. patch -p1 --forward --fuzz=3 < kernel-patch-susfs-v1.5.7-to-KernelSU-Next.patch
  211. ;;
  212. "MKSU")
  213. echo "Applying SUSFS patches for MKSU..."
  214. cd ./KernelSU
  215. cp ../../kernel_patches/next/kernel-patch-susfs-v1.5.7-to-KernelSU-Next.patch ./
  216. patch -p1 --forward --fuzz=3 < kernel-patch-susfs-v1.5.7-to-KernelSU-Next.patch
  217. ;;
  218. esac
  219. cd ../common
  220. patch -p1 --fuzz=3 < 50_add_susfs_in_gki-${{ inputs.android_version }}-${{ inputs.kernel_version }}.patch || true
  221. - name: Apply Hooks Patches
  222. run: |
  223. echo "Changing to configuration directory: $CONFIG..."
  224. cd "$CONFIG/common"
  225. if [ "${{ inputs.kernelsu_variant }}" == "NEXT" ]; then
  226. echo "Applying hooks for KernelSU-Next..."
  227. cp ../../kernel_patches/next/syscall_hooks.patch ./
  228. patch -p1 -F 3 < syscall_hooks.patch
  229. elif [ "${{ inputs.kernelsu_variant }}" == "WILD" ]; then
  230. echo "Applying hooks for Wild KSU..."
  231. cp ../../kernel_patches/wild/syscall_hooks.patch ./
  232. patch -p1 -F 3 < syscall_hooks.patch
  233. fi
  234. - name: Apply Hide Stuff Patches
  235. run: |
  236. echo "Changing to configuration directory: $CONFIG..."
  237. cd "$CONFIG/common"
  238. cp ../../kernel_patches/69_hide_stuff.patch ./
  239. patch -p1 -F 3 < 69_hide_stuff.patch
  240. - name: Add All Managers
  241. run: |
  242. cd "$CONFIG"
  243. case "${{ inputs.kernelsu_variant }}" in
  244. "KSU" | "WILD")
  245. echo "Applying Manager patch for Official KernelSU..."
  246. cd KernelSU
  247. cp ../../kernel_patches/wild/manager.patch ./
  248. ;;
  249. "NEXT")
  250. echo "Applying Manager patch for KernelSU Next..."
  251. cd KernelSU-Next
  252. cp ../../kernel_patches/next/manager.patch ./
  253. ;;
  254. "MKSU")
  255. echo "Applying Manager patch for MKSU..."
  256. #cp ../kernel_patches/mksu/manager.patch .//
  257. ;;
  258. esac
  259. patch -p1 --fuzz=3 < manager.patch || echo "No Manager Patch"
  260. - name: Add Configuration Settings
  261. run: |
  262. echo "Changing to configuration directory: $CONFIG..."
  263. cd "$CONFIG"
  264. echo "Adding configuration settings to gki_defconfig..."
  265. # Add KSU configuration settings
  266. echo "CONFIG_KSU=y" >> ./common/arch/arm64/configs/gki_defconfig
  267. if [ "${{ inputs.kernelsu_variant }}" == "NEXT" || "${{ inputs.kernelsu_variant }}" == "WILD" ]; then
  268. echo "CONFIG_KSU_WITH_KPROBES=n" >> ./common/arch/arm64/configs/gki_defconfig
  269. fi
  270. # Add additional tmpfs config setting
  271. echo "CONFIG_TMPFS_XATTR=y" >> ./common/arch/arm64/configs/gki_defconfig
  272. echo "CONFIG_TMPFS_POSIX_ACL=y" >> ./common/arch/arm64/configs/gki_defconfig
  273. # Add additional config setting
  274. echo "CONFIG_IP_NF_TARGET_TTL=y" >> ./common/arch/arm64/configs/gki_defconfig
  275. echo "CONFIG_IP6_NF_TARGET_HL=y" >> ./common/arch/arm64/configs/gki_defconfig
  276. echo "CONFIG_IP6_NF_MATCH_HL=y" >> ./common/arch/arm64/configs/gki_defconfig
  277. # Add BBR Config
  278. echo "CONFIG_TCP_CONG_ADVANCED=y" >> ./common/arch/arm64/configs/gki_defconfig
  279. echo "CONFIG_TCP_CONG_BBR=y" >> ./common/arch/arm64/configs/gki_defconfig
  280. echo "CONFIG_NET_SCH_FQ=y" >> ./common/arch/arm64/configs/gki_defconfig
  281. echo "CONFIG_TCP_CONG_BIC=n" >> ./common/arch/arm64/configs/gki_defconfig
  282. echo "CONFIG_TCP_CONG_WESTWOOD=n" >> ./common/arch/arm64/configs/gki_defconfig
  283. echo "CONFIG_TCP_CONG_HTCP=n" >> ./common/arch/arm64/configs/gki_defconfig
  284. # Remove check_defconfig
  285. sed -i 's/check_defconfig//' ./common/build.config.gki
  286. - name: Add SUSFS Configuration Settings
  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 }}" == "NEXT" || "${{ inputs.kernelsu_variant }}" == "WILD" ]; 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. - name: Compress all img files with gzip
  437. run: |
  438. for image in *.img; do
  439. gzip -vnf9 "$image"
  440. done
  441. - name: Upload Build Artifacts
  442. uses: actions/upload-artifact@v4
  443. with:
  444. name: ${{ inputs.kernelsu_variant }}-kernel-${{ env.CONFIG }}
  445. path: |
  446. *.zip
  447. *.img.gz
  448. *Image*