diff --git a/.github/workflows/build-kernel.yml b/.github/workflows/build-kernel.yml index 653f0c491f..4967b6ad62 100644 --- a/.github/workflows/build-kernel.yml +++ b/.github/workflows/build-kernel.yml @@ -1,6 +1,5 @@ name: Build Kernel on: - workflow_dispatch: jobs: @@ -15,47 +14,57 @@ jobs: - uses: actions/checkout@v4 - name: Prepare Configuration run: | - CONFIG_ENV=$(cat config.env | grep -w "CONFIG_ENV" | head -n 1 | cut -d "=" -f 2) - echo "KERNEL_SOURCE=$(cat $CONFIG_ENV | grep -w "KERNEL_SOURCE" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV - echo "KERNEL_SOURCE_BRANCH=$(cat $CONFIG_ENV | grep -w "KERNEL_SOURCE_BRANCH" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV - echo "KERNEL_CONFIG=$(cat $CONFIG_ENV | grep -w "KERNEL_CONFIG" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV - echo "KERNEL_IMAGE_NAME=$(cat $CONFIG_ENV | grep -w "KERNEL_IMAGE_NAME" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV - echo "ARCH=$(cat $CONFIG_ENV | grep -w "ARCH" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV - echo "ADD_LOCALVERSION_TO_FILENAME=$(cat $CONFIG_ENV | grep -w "ADD_LOCALVERSION_TO_FILENAME" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV - echo "EXTRA_CMDS=$(cat $CONFIG_ENV | grep -w "EXTRA_CMDS" | head -n 1 | cut -d ":" -f 2)" >> $GITHUB_ENV - echo "USE_CUSTOM_CLANG=$(cat $CONFIG_ENV | grep -w "USE_CUSTOM_CLANG" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV - echo "CUSTOM_CLANG_SOURCE=$(cat $CONFIG_ENV | grep -w "CUSTOM_CLANG_SOURCE" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV - echo "CUSTOM_CLANG_BRANCH=$(cat $CONFIG_ENV | grep -w "CUSTOM_CLANG_BRANCH" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV - echo "CUSTOM_CMDS=$(cat $CONFIG_ENV | grep -w "CUSTOM_CMDS" | head -n 1 | cut -d ":" -f 2)" >> $GITHUB_ENV - echo "CLANG_BRANCH=$(cat $CONFIG_ENV | grep -w "CLANG_BRANCH" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV - echo "CLANG_VERSION=$(cat $CONFIG_ENV | grep -w "CLANG_VERSION" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV - echo "ENABLE_GCC_ARM64=$(cat $CONFIG_ENV | grep -w "ENABLE_GCC_ARM64" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV - echo "ENABLE_GCC_ARM32=$(cat $CONFIG_ENV | grep -w "ENABLE_GCC_ARM32" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV - echo "USE_CUSTOM_GCC_64=$(cat $CONFIG_ENV | grep -w "USE_CUSTOM_GCC_64" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV - echo "CUSTOM_GCC_64_SOURCE=$(cat $CONFIG_ENV | grep -w "CUSTOM_GCC_64_SOURCE" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV - echo "CUSTOM_GCC_64_BRANCH=$(cat $CONFIG_ENV | grep -w "CUSTOM_GCC_64_BRANCH" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV - echo "CUSTOM_GCC_64_BIN=$(cat $CONFIG_ENV | grep -w "CUSTOM_GCC_64_BIN" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV - echo "USE_CUSTOM_GCC_32=$(cat $CONFIG_ENV | grep -w "USE_CUSTOM_GCC_32" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV - echo "CUSTOM_GCC_32_SOURCE=$(cat $CONFIG_ENV | grep -w "CUSTOM_GCC_32_SOURCE" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV - echo "CUSTOM_GCC_32_BRANCH=$(cat $CONFIG_ENV | grep -w "CUSTOM_GCC_32_BRANCH" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV - echo "CUSTOM_GCC_32_BIN=$(cat $CONFIG_ENV | grep -w "CUSTOM_GCC_32_BIN" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV - echo "ENABLE_KERNELSU=$(cat $CONFIG_ENV | grep -w "ENABLE_KERNELSU" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV - echo "KERNELSU_TAG=$(cat $CONFIG_ENV | grep -w "KERNELSU_TAG" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV - echo "ADD_KPROBES_CONFIG=$(cat $CONFIG_ENV | grep -w "ADD_KPROBES_CONFIG" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV - echo "DISABLE-LTO=$(cat $CONFIG_ENV | grep -w "DISABLE-LTO" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV - echo "ADD_OVERLAYFS_CONFIG=$(cat $CONFIG_ENV | grep -w "ADD_OVERLAYFS_CONFIG" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV - echo "DISABLE_CC_WERROR=$(cat $CONFIG_ENV | grep -w "DISABLE_CC_WERROR" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV - echo "APPLY_KSU_PATCH=$(cat $CONFIG_ENV | grep -w "APPLY_KSU_PATCH" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV - echo "USE_CUSTOM_ANYKERNEL3=$(cat $CONFIG_ENV | grep -w "USE_CUSTOM_ANYKERNEL3" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV - echo "CUSTOM_ANYKERNEL3_SOURCE=$(cat $CONFIG_ENV | grep -w "CUSTOM_ANYKERNEL3_SOURCE" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV - echo "CUSTOM_ANYKERNEL3_BRANCH=$(cat $CONFIG_ENV | grep -w "CUSTOM_ANYKERNEL3_BRANCH" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV - echo "ENABLE_CCACHE=$(cat $CONFIG_ENV | grep -w "ENABLE_CCACHE" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV - echo "NEED_DTBO=$(cat $CONFIG_ENV | grep -w "NEED_DTBO" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV - echo "BUILD_BOOT_IMG=$(cat $CONFIG_ENV | grep -w "BUILD_BOOT_IMG" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV - echo "SOURCE_BOOT_IMAGE=$(cat $CONFIG_ENV | grep -w "SOURCE_BOOT_IMAGE" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV - echo "KSU_EXPECTED_SIZE=$(cat $CONFIG_ENV | grep -w "KSU_EXPECTED_SIZE" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV - echo "KSU_EXPECTED_HASH=$(cat $CONFIG_ENV | grep -w "KSU_EXPECTED_HASH" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV - echo "REMOVE_UNUSED_PACKAGES=$(cat $CONFIG_ENV | grep -w "REMOVE_UNUSED_PACKAGES" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV + CONFIG_ENV=$(grep -w "CONFIG_ENV" config.env | head -n 1 | cut -d "=" -f 2) + CONFIG_LIST=( + KERNEL_SOURCE + KERNEL_SOURCE_BRANCH + KERNEL_CONFIG + KERNEL_IMAGE_NAME + ARCH + ADD_LOCALVERSION_TO_FILENAME + EXTRA_CMDS + USE_CUSTOM_CLANG + CUSTOM_CLANG_SOURCE + CUSTOM_CLANG_BRANCH + CUSTOM_CMDS + CLANG_BRANCH + CLANG_VERSION + ENABLE_GCC_ARM64 + ENABLE_GCC_ARM32 + USE_CUSTOM_GCC_64 + CUSTOM_GCC_64_SOURCE + CUSTOM_GCC_64_BRANCH + CUSTOM_GCC_64_BIN + USE_CUSTOM_GCC_32 + CUSTOM_GCC_32_SOURCE + CUSTOM_GCC_32_BRANCH + CUSTOM_GCC_32_BIN + ENABLE_KERNELSU + KERNELSU_TAG + ADD_KPROBES_CONFIG + DISABLE-LTO + ADD_OVERLAYFS_CONFIG + DISABLE_CC_WERROR + APPLY_KSU_PATCH + USE_CUSTOM_ANYKERNEL3 + CUSTOM_ANYKERNEL3_SOURCE + CUSTOM_ANYKERNEL3_BRANCH + ENABLE_CCACHE + NEED_DTBO + BUILD_BOOT_IMG + SOURCE_BOOT_IMAGE + KSU_EXPECTED_SIZE + KSU_EXPECTED_HASH + REMOVE_UNUSED_PACKAGES + ) + + for CONFIG in "${CONFIG_LIST[@]}"; do + if [[ "$CONFIG" == "EXTRA_CMDS" || "$CONFIG" == "CUSTOM_CMDS" ]]; then + echo "$CONFIG=$(grep -w "$CONFIG" "$CONFIG_ENV" | head -n 1 | cut -d ":" -f 2)" >> $GITHUB_ENV + else + echo "$CONFIG=$(grep -w "$CONFIG" "$CONFIG_ENV" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV + fi + done - name: Remove unused packages if: env.REMOVE_UNUSED_PACKAGES == 'true' @@ -101,7 +110,7 @@ jobs: tar -C clang-aosp/ -zxvf clang.tar.gz else git clone ${{ env.CUSTOM_CLANG_SOURCE }} -b ${{ env.CUSTOM_CLANG_BRANCH }} clang-aosp --depth=1 - fi + fi else wget -O clang.zip ${{ env.CUSTOM_CLANG_SOURCE }} mkdir clang-aosp @@ -133,7 +142,7 @@ jobs: if [ ${{ env.USE_CUSTOM_GCC_64 }} = true ]; then if [[ ${{ env.CUSTOM_GCC_64_SOURCE }} =~ git ]]; then if [[ ${{ env.CUSTOM_GCC_64_SOURCE }} == *'.tar.gz' ]]; then - wget -O gcc-64.tar.gz ${{ env.CUSTOM_CLANG_SOURCE }} + wget -O gcc-64.tar.gz ${{ env.CUSTOM_GCC_64_SOURCE }} mkdir gcc-64 tar -C gcc-64/ -zxvf gcc-64.tar.gz else @@ -150,7 +159,7 @@ jobs: if [ ${{ env.USE_CUSTOM_GCC_32 }} = true ]; then if [[ ${{ env.CUSTOM_GCC_32_SOURCE }} =~ git ]]; then if [[ ${{ env.CUSTOM_GCC_32_SOURCE }} == *'.tar.gz' ]]; then - wget -O gcc-32.tar.gz ${{ env.CUSTOM_CLANG_SOURCE }} + wget -O gcc-32.tar.gz ${{ env.CUSTOM_GCC_32_SOURCE }} mkdir gcc-32 tar -C gcc-32/ -zxvf gcc-32.tar.gz else @@ -189,12 +198,11 @@ jobs: echo "FORMAT_MKBOOTING=$(echo `tools/unpack_bootimg.py --boot_img=boot-source.img --format mkbootimg`)" >> $GITHUB_ENV echo "HAVE_SOURCE_BOOT_IMAGE=true" >> $GITHUB_ENV fi - + - name: Setup KernelSU if: env.ENABLE_KERNELSU == 'true' run: | cd $GITHUB_WORKSPACE/kernel_workspace/android-kernel - rm -rf KernelSU drivers/kernelsu curl -LSs "https://raw.githubusercontent.com/tiann/KernelSU/main/kernel/setup.sh" | bash -s ${{ env.KERNELSU_TAG }} KSU_VERSION=$(cd KernelSU && expr $(/usr/bin/git rev-list --count HEAD) + 10200) echo "UPLOADNAME=-KernelSU_$KSU_VERSION" >> $GITHUB_ENV @@ -271,7 +279,7 @@ jobs: exit 1 fi fi - + - name: Make Anykernel3 if: env.CHECK_FILE_IS_OK == 'true' && env.USE_CUSTOM_ANYKERNEL3 != 'true' run: | @@ -322,7 +330,7 @@ jobs: echo "Boot image is empty" exit 1 fi - + - name: Upload ${{ env.KERNEL_IMAGE_NAME }} if: env.CHECK_FILE_IS_OK == 'true' uses: actions/upload-artifact@v4