gki-kernel.yml 25 KB

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