build.yml 25 KB

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