|
1 | | -name: Build A12 Kernel |
| 1 | +name: Build Android 12 GKI Kernels with KernelSU-Next & SUSFS |
2 | 2 |
|
3 | 3 | on: |
4 | | - workflow_call: # This workflow will be triggered by the release.yml |
| 4 | + workflow_dispatch: # Manually triggered workflow |
5 | 5 |
|
6 | 6 | jobs: |
7 | | - build-kernel: |
8 | | - runs-on: ubuntu-latest # Change the runner if necessary |
9 | | - strategy: |
10 | | - matrix: |
11 | | - kernel_configs: |
12 | | - - sub_level: 198 |
13 | | - os_patch_level: 2024-01 |
14 | | - - sub_level: 205 |
15 | | - os_patch_level: 2024-03 |
16 | | - - sub_level: 209 |
17 | | - os_patch_level: 2024-05 |
18 | | - - sub_level: 218 |
19 | | - os_patch_level: 2024-08 |
20 | | - - sub_level: 226 |
21 | | - os_patch_level: 2024-11 |
| 7 | + build-kernel-a12: |
| 8 | + runs-on: ubuntu-latest |
22 | 9 |
|
23 | 10 | steps: |
24 | | - - name: Set up kernel build configuration |
25 | | - run: | |
26 | | - # Set static values for Android version and kernel version |
27 | | - ANDROID_VERSION="android12" |
28 | | - KERNEL_VERSION="5.10" |
29 | | - |
30 | | - # Formatted branch name for each build (e.g., android12-5.10-2024-01) |
31 | | - FORMATTED_BRANCH="${ANDROID_VERSION}-${KERNEL_VERSION}-${{ matrix.kernel_configs.os_patch_level }}" |
32 | | - echo "Formatted branch name: $FORMATTED_BRANCH" |
33 | | -
|
34 | | - # Create a directory in the format android_version-kernel_version-sub_level-os_patch_level |
35 | | - BUILD_DIR="${ANDROID_VERSION}-${KERNEL_VERSION}-${{ matrix.kernel_configs.sub_level }}-${{ matrix.kernel_configs.os_patch_level }}" |
36 | | - mkdir -p "$BUILD_DIR" |
37 | | - echo "Directory created: $BUILD_DIR" |
| 11 | + # Step 0: Maximize build space |
| 12 | + - name: Maximize build space |
| 13 | + uses: easimon/maximize-build-space@master |
| 14 | + with: |
| 15 | + root-reserve-mb: 8192 |
| 16 | + temp-reserve-mb: 2048 |
| 17 | + remove-dotnet: 'true' |
| 18 | + remove-android: 'true' |
| 19 | + remove-haskell: 'true' |
| 20 | + remove-codeql: 'true' |
| 21 | + |
| 22 | + # Step 1: Download prebuilt toolchain from AOSP |
| 23 | + - name: Download prebuilt toolchain |
| 24 | + run: | |
| 25 | + AOSP_MIRROR=https://android.googlesource.com |
| 26 | + BRANCH=main-kernel-build-2024 # Updated branch name |
| 27 | + git clone $AOSP_MIRROR/platform/prebuilts/build-tools -b $BRANCH --depth 1 build-tools |
| 28 | + git clone $AOSP_MIRROR/kernel/prebuilts/build-tools -b $BRANCH --depth 1 kernel-build-tools |
| 29 | + git clone $AOSP_MIRROR/platform/system/tools/mkbootimg -b $BRANCH --depth 1 mkbootimg |
| 30 | +
|
| 31 | + # Step 2: Set environment variables for boot image build |
| 32 | + - name: Build boot images |
| 33 | + run: | |
| 34 | + export AVBTOOL=$GITHUB_WORKSPACE/kernel-build-tools/linux-x86/bin/avbtool |
| 35 | + export GZIP=$GITHUB_WORKSPACE/build-tools/path/linux-x86/gzip |
| 36 | + export LZ4=$GITHUB_WORKSPACE/build-tools/path/linux-x86/lz4 |
| 37 | + export MKBOOTIMG=$GITHUB_WORKSPACE/mkbootimg/mkbootimg.py |
| 38 | + export UNPACK_BOOTIMG=$GITHUB_WORKSPACE/mkbootimg/unpack_bootimg.py |
38 | 39 | |
39 | | - # Change into the newly created directory |
40 | | - cd "$BUILD_DIR" |
41 | | - echo "Now in directory: $(pwd)" |
42 | | - |
43 | | - - name: Clone AnyKernel3 repository |
44 | | - run: | |
45 | | - echo "Cloning AnyKernel3 repository..." |
46 | | - git clone https://github.com/TheWildJames/AnyKernel3.git -b "${ANDROID_VERSION}-${KERNEL_VERSION}" |
47 | | -
|
48 | | - - name: Clone susfs4ksu repository |
49 | | - run: | |
50 | | - echo "Cloning susfs4ksu repository..." |
51 | | - git clone https://gitlab.com/simonpunk/susfs4ksu.git -b "gki-${ANDROID_VERSION}-${KERNEL_VERSION}" |
52 | | -
|
53 | | - - name: Clone kernel_patches repository |
54 | | - run: | |
55 | | - echo "Cloning kernel_patches repository..." |
56 | | - git clone https://github.com/TheWildJames/kernel_patches.git |
57 | | -
|
58 | | - - name: Initialize and sync kernel source |
59 | | - run: | |
60 | | - echo "Initializing and syncing kernel source..." |
61 | | - # Initialize repo |
62 | | - repo init --depth=1 --u https://android.googlesource.com/kernel/manifest -b common-${FORMATTED_BRANCH} |
63 | | - |
64 | | - # Get remote branch details |
65 | | - REMOTE_BRANCH=$(git ls-remote https://android.googlesource.com/kernel/common ${FORMATTED_BRANCH}) |
66 | | - DEFAULT_MANIFEST_PATH=.repo/manifests/default.xml |
67 | | - |
68 | | - # Check if the branch is deprecated and adjust the manifest |
69 | | - if grep -q deprecated <<< $REMOTE_BRANCH; then |
70 | | - echo "Found deprecated branch: $FORMATTED_BRANCH" |
71 | | - sed -i "s/\"${FORMATTED_BRANCH}\"/\"deprecated\/${FORMATTED_BRANCH}\"/g" $DEFAULT_MANIFEST_PATH |
72 | | - fi |
73 | | -
|
74 | | - # Verify repo version and sync the kernel source |
75 | | - repo --version |
76 | | - repo --trace sync -c -j$(nproc --all) --no-tags --fail-fast |
77 | | -
|
78 | | - - name: Set up KernelSU-Next |
79 | | - run: | |
80 | | - echo "Setting up KernelSU-Next..." |
81 | | - curl -LSs "https://raw.githubusercontent.com/rifsxd/KernelSU-Next/next/kernel/setup.sh" | bash - |
82 | | -
|
83 | | - - name: Apply SUSFS patches |
84 | | - run: | |
85 | | - echo "Applying SUSFS patches..." |
86 | | - # Copy the necessary patches to the appropriate directories |
87 | | - cp ../susfs4ksu/kernel_patches/KernelSU/10_enable_susfs_for_ksu.patch ./KernelSU-Next/ |
88 | | - cp ../susfs4ksu/kernel_patches/50_add_susfs_in_gki-${ANDROID_VERSION}-${KERNEL_VERSION}.patch ./common/ |
89 | | - cp ../susfs4ksu/kernel_patches/fs/* ./common/fs/ |
90 | | - cp ../susfs4ksu/kernel_patches/include/linux/* ./common/include/linux/ |
91 | | -
|
92 | | - # Apply the patches |
93 | | - cd ./KernelSU-Next |
94 | | - patch -p1 --forward < 10_enable_susfs_for_ksu.patch || true |
95 | | - cd ../common |
96 | | - patch -p1 < 50_add_susfs_in_gki-${ANDROID_VERSION}-${KERNEL_VERSION}.patch || true |
97 | | -
|
98 | | - - name: Apply Custom Patches |
99 | | - run: | |
100 | | - echo "Applying custom patches..." |
101 | | - |
102 | | - # Copy the custom patches and apply them |
103 | | - cp ../../kernel_patches/69_hide_stuff.patch ./ |
104 | | - patch -p1 -F 3 < 69_hide_stuff.patch |
105 | | - cd .. |
106 | | - |
107 | | - cp ../kernel_patches/apk_sign.c_fix.patch ./ |
108 | | - patch -p1 -F 3 < apk_sign.c_fix.patch |
109 | | - |
110 | | - cp ../kernel_patches/core_hook.c_fix.patch ./ |
111 | | - patch -p1 --fuzz=3 < ./core_hook.c_fix.patch |
112 | | -
|
113 | | - cp ../kernel_patches/selinux.c_fix.patch ./ |
114 | | - patch -p1 -F 3 < selinux.c_fix.patch |
115 | | -
|
116 | | - - name: Add SUSFS configuration settings |
117 | | - run: | |
118 | | - echo "Adding configuration settings to gki_defconfig..." |
119 | | - echo "CONFIG_KSU=y" >> ./common/arch/arm64/configs/gki_defconfig |
120 | | - echo "CONFIG_KSU_SUSFS=y" >> ./common/arch/arm64/configs/gki_defconfig |
121 | | - echo "CONFIG_KSU_SUSFS_HAS_MAGIC_MOUNT=y" >> ./common/arch/arm64/configs/gki_defconfig |
122 | | - echo "CONFIG_KSU_SUSFS_SUS_PATH=y" >> ./common/arch/arm64/configs/gki_defconfig |
123 | | - echo "CONFIG_KSU_SUSFS_SUS_MOUNT=y" >> ./common/arch/arm64/configs/gki_defconfig |
124 | | - echo "CONFIG_KSU_SUSFS_AUTO_ADD_SUS_KSU_DEFAULT_MOUNT=y" >> ./common/arch/arm64/configs/gki_defconfig |
125 | | - echo "CONFIG_KSU_SUSFS_AUTO_ADD_SUS_BIND_MOUNT=y" >> ./common/arch/arm64/configs/gki_defconfig |
126 | | - echo "CONFIG_KSU_SUSFS_SUS_KSTAT=y" >> ./common/arch/arm64/configs/gki_defconfig |
127 | | - echo "CONFIG_KSU_SUSFS_SUS_OVERLAYFS=y" >> ./common/arch/arm64/configs/gki_defconfig |
128 | | - echo "CONFIG_KSU_SUSFS_TRY_UMOUNT=y" >> ./common/arch/arm64/configs/gki_defconfig |
129 | | - echo "CONFIG_KSU_SUSFS_AUTO_ADD_TRY_UMOUNT_FOR_BIND_MOUNT=y" >> ./common/arch/arm64/configs/gki_defconfig |
130 | | - echo "CONFIG_KSU_SUSFS_SPOOF_UNAME=y" >> ./common/arch/arm64/configs/gki_defconfig |
131 | | - echo "CONFIG_KSU_SUSFS_ENABLE_LOG=y" >> ./common/arch/arm64/configs/gki_defconfig |
132 | | - echo "CONFIG_KSU_SUSFS_HIDE_KSU_SUSFS_SYMBOLS=y" >> ./common/arch/arm64/configs/gki_defconfig |
133 | | - echo "CONFIG_KSU_SUSFS_SPOOF_CMDLINE_OR_BOOTCONFIG=y" >> ./common/arch/arm64/configs/gki_defconfig |
134 | | - echo "CONFIG_KSU_SUSFS_OPEN_REDIRECT=y" >> ./common/arch/arm64/configs/gki_defconfig |
135 | | - echo "CONFIG_KSU_SUSFS_SUS_SU=y" >> ./common/arch/arm64/configs/gki_defconfig |
136 | | -
|
137 | | - - name: Final build steps (Apply final fixes and build kernel) |
138 | | - run: | |
139 | | - # Apply final edits to config files and build kernel image |
140 | | - ed -i '2s/check_defconfig//' ./common/build.config.gki |
141 | | - sed -i "s/dirty/'Wild+'/g" ./common/scripts/setlocalversion |
142 | | - LTO=full BUILD_CONFIG=common/build.config.gki.aarch64 build/build.sh |
143 | | -
|
144 | | - - name: Copy kernel image to AnyKernel3 |
| 40 | + # Step 3: Install repo tool via apt |
| 41 | + - name: Install repo tool via apt |
145 | 42 | run: | |
146 | | - echo "Copying Image.lz4 to $CONFIG/AnyKernel3..." |
147 | | - # Check if the boot.img file exists |
148 | | - if [ "$ANDROID_VERSION" = "android12" ]; then |
149 | | - mkdir bootimgs |
150 | | - cp ./out/${ANDROID_VERSION}-${KERNEL_VERSION}/dist/Image ./bootimgs |
151 | | - cp ./out/${ANDROID_VERSION}-${KERNEL_VERSION}/dist/Image.lz4 ./bootimgs |
152 | | - cp ./out/${ANDROID_VERSION}-${KERNEL_VERSION}/dist/Image ../ |
153 | | - cp ./out/${ANDROID_VERSION}-${KERNEL_VERSION}/dist/Image.lz4 ../ |
154 | | - gzip -n -k -f -9 ../Image >../Image.gz |
155 | | - cd ./bootimgs |
156 | | - |
157 | | - GKI_URL=https://dl.google.com/android/gki/gki-certified-boot-android12-5.10-"${DATE}"_r1.zip |
158 | | - FALLBACK_URL=https://dl.google.com/android/gki/gki-certified-boot-android12-5.10-2023-01_r1.zip |
159 | | - status=$(curl -sL -w "%{http_code}" "$GKI_URL" -o /dev/null) |
160 | | - |
161 | | - if [ "$status" = "200" ]; then |
162 | | - curl -Lo gki-kernel.zip "$GKI_URL" |
163 | | - else |
164 | | - echo "[+] $GKI_URL not found, using $FALLBACK_URL" |
165 | | - curl -Lo gki-kernel.zip "$FALLBACK_URL" |
166 | | - fi |
167 | | - |
168 | | - unzip gki-kernel.zip && rm gki-kernel.zip |
169 | | - echo 'Unpack prebuilt boot.img' |
170 | | - unpack_bootimg.py --boot_img="./boot-5.10.img" |
171 | | - |
172 | | - echo 'Building Image.gz' |
173 | | - gzip -n -k -f -9 Image >Image.gz |
174 | | - |
175 | | - echo 'Building boot.img' |
176 | | - mkbootimg.py --header_version 4 --kernel Image --output boot.img --ramdisk out/ramdisk --os_version 12.0.0 --os_patch_level "${DATE}" |
| 43 | + sudo apt-get update |
| 44 | + sudo apt-get install -y repo |
0 commit comments