Skip to content
This repository has been archived by the owner on Apr 21, 2024. It is now read-only.

Commit

Permalink
Workflows and configs: Imporvement and fix a lot of bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
magojohnji committed Sep 3, 2023
1 parent d41f39d commit 98ffcc3
Show file tree
Hide file tree
Showing 4 changed files with 133 additions and 42 deletions.
69 changes: 53 additions & 16 deletions .github/workflows/build-kernel.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build
name: Build example
on:
workflow_dispatch:
inputs:
Expand All @@ -12,7 +12,7 @@ jobs:
build:
permissions:
contents: write
name: Work by ${{ github.actor }}
name: Build by ${{ github.actor }}
runs-on: ubuntu-latest
if: github.event.repository.owner.id == github.event.sender.id
env:
Expand Down Expand Up @@ -50,9 +50,9 @@ jobs:
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 "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_64_BIN=$(cat $CONFIG_ENV | grep -w "CUSTOM_GCC_64_BIN" | 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_INSTALLER=$(cat $CONFIG_ENV | grep -w "KERNELSU_INSTALLER" | 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
Expand All @@ -64,6 +64,7 @@ jobs:
echo "MAGISK_APK=$(cat $CONFIG_ENV | grep -w "MAGISK_APK" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV
echo "MAGISK_PATCH_PARTITION=$(cat $CONFIG_ENV | grep -w "MAGISK_PATCH_PARTITION" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV
echo "MAGISK_SOURCE_BOOT_IMAGE=$(cat $CONFIG_ENV | grep -w "MAGISK_SOURCE_BOOT_IMAGE" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV
echo "MIX_KERNELSU_MAGISK_BOOT_IMAGE=$(cat $CONFIG_ENV | grep -w "MIX_KERNELSU_MAGISK_BOOT_IMAGE" | 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 "DISABLE_CC_WERROR=$(cat $CONFIG_ENV | grep -w "DISABLE_CC_WERROR" | 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
Expand All @@ -73,11 +74,6 @@ jobs:
echo "BUILDER_HOST=$(cat $CONFIG_ENV | grep -w "BUILDER_HOST" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV
echo "TC_CUSTOM_CMDS=$(cat $CONFIG_ENV | grep -w "TC_CUSTOM_CMDS" | 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
- name: Set Swap to 10GB
uses: pierotofy/set-swap-space@master
with:
swap-size-gb: 10
- name: Setting up the kernel compilation environment
run: |
Expand All @@ -88,6 +84,11 @@ jobs:
sudo apt upgrade
mkdir -p $GITHUB_WORKSPACE/kernel_workspace
- name: Set Swap to 10GB
uses: pierotofy/set-swap-space@master
with:
swap-size-gb: 10

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
Expand Down Expand Up @@ -164,7 +165,9 @@ jobs:
mkdir gcc-64
unzip gcc-64.zip -d gcc-64/
fi
echo "GCC_64=CROSS_COMPILE=$GITHUB_WORKSPACE/kernel_workspace/gcc-64/bin/${{ env.CUSTOM_GCC_64_BIN }}" >> $GITHUB_ENV
fi
if [ ${{ env.USE_CUSTOM_GCC_64 }} = true ]; then
if [[ ${{ env.CUSTOM_GCC_32_SOURCE }} =~ git ]]; then
if [[ ${{ env.CUSTOM_GCC_32_SOURCE }} == *'.tar.gz' ]]; then
Expand All @@ -179,16 +182,20 @@ jobs:
mkdir gcc-32
unzip gcc-32.zip -d gcc-32/
fi
echo "GCC_32=CROSS_COMPILE=$GITHUB_WORKSPACE/kernel_workspace/gcc-32/bin/${{ env.CUSTOM_GCC_32_BIN }}" >> $GITHUB_ENV
fi
- name: Setup magiskboot
- name: Download magiskboot
if: env.BUILD_KERNELSU_BOOT_IMG == 'true'
run: |
cd $GITHUB_WORKSPACE/kernel_workspace
mkdir tools
git clone https://github.com/magojohnji/magiskboot.git --depth=1 magiskboot
cp ./magiskboot/x86_64/magiskboot ../tools/
rm -rf ./magiskboot
git clone --recurse-submodules https://github.com/magojohnji/magiskboot-linux.git magiskboot
cd magiskboot
cp ./x86_64/magiskboot ../tools/
cd ..
rm -rf magiskboot
- name: Download the kernel source code
run: |
cd $GITHUB_WORKSPACE/kernel_workspace
Expand Down Expand Up @@ -346,7 +353,7 @@ jobs:
if [ -f boot-kernelsu.img ]; then
echo "MAKE_KERNELSU_BOOT_IMAGE_IS_OK=true" >> $GITHUB_ENV
else
echo "Magisk Boot image is empty or broken."
echo "KernelSU Boot image is empty or broken."
exit 1
fi
Expand All @@ -356,7 +363,6 @@ jobs:
cd $GITHUB_WORKSPACE/kernel_workspace
mkdir magisk-patch
cd magisk-patch
sudo apt install -y rename
mkdir magisk
cd magisk
wget "${{ env.MAGISK_SOURCE_BOOT_IMAGE }}" -O ${{ env.MAGISK_PATCH_PARTITION }}.img
Expand All @@ -373,6 +379,28 @@ jobs:
echo "MAKE_MAGISK_BOOT_IMAGE_IS_OK=true" >> $GITHUB_ENV
- name: Mixing KernelSU and Magisk boot image
if: env.MAKE_KERNELSU_BOOT_IMAGE_IS_OK == 'true' && env.ENABLE_MAGISK == 'true'
run: |
cd $GITHUB_WORKSPACE/kernel_workspace
mkdir magisk-patch-kernelsu
cd magisk-patch-kernelsu
mkdir magisk
cd magisk
cp $GITHUB_WORKSPACE/kernel_workspace/bootimg_tmp/boot-kernelsu.img ./${{ env.MAGISK_PATCH_PARTITION }}.img
wget "${{ env.MAGISK_APK }}" -O Magisk.zip
unzip Magisk.zip >> /dev/null
cd ./lib/x86_64
rename 's/(lib|\.so)//g' *
cd ../../
mv ./lib/x86_64/* ./assets
chmod -R a+x ./assets/*
cd assets
bash ./boot_patch.sh ../${{ env.MAGISK_PATCH_PARTITION }}.img
mv ./new-boot.img $GITHUB_WORKSPACE/kernel_workspace/magisk-patch-kernelsu/boot-kernelsu-magisk.img
echo "MAKE_KERNELSU_MAGISK_BOOT_IMAGE_IS_OK=true" >> $GITHUB_ENV
- name: Upload ${{ env.KERNEL_IMAGE_NAME }}
if: env.CHECK_FILE_IS_OK == 'true'
uses: actions/upload-artifact@v3
Expand All @@ -385,7 +413,7 @@ jobs:
if: env.CHECK_FILE_IS_OK == 'true' && env.AK3_IS_OK == 'true'
uses: actions/upload-artifact@v3
with:
name: AnyKernel3-${{ env.UPLOADNAME }}-${{ env.DEVICE }}-${{ env.BUILD_TIME }}
name: AnyKernel3${{ env.UPLOADNAME }}-${{ env.DEVICE }}-${{ env.BUILD_TIME }}
path: kernel_workspace/AnyKernel3/AnyKernel3.zip
if-no-files-found: error

Expand Down Expand Up @@ -421,6 +449,14 @@ jobs:
path: kernel_workspace/magisk-patch/magisk/Magisk.zip
if-no-files-found: error

- name: Upload KernelSU and Magisk mixed boot image
if: env.MAKE_KERNELSU_MAGISK_BOOT_IMAGE_IS_OK == 'true'
uses: actions/upload-artifact@v3
with:
name: boot-KernelSU-Magisk-${{ env.BUILD_TIME }}
path: kernel_workspace/magisk-patch-kernelsu/boot-kernelsu-magisk.img
if-no-files-found: error

- name: Release
uses: softprops/action-gh-release@master
if: github.event.inputs.release == 'true'
Expand All @@ -434,6 +470,7 @@ jobs:
kernel_workspace/android-kernel/out/arch/${{ env.ARCH }}/boot/dtbo.img
kernel_workspace/bootimg_tmp/boot-kernelsu.img
kernel_workspace/magisk-patch/boot-magisk.img
kernel_workspace/magisk-patch-kernelsu/boot-kernelsu-magisk.img
kernel_workspace/magisk-patch/magisk/Magisk.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
51 changes: 38 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,35 @@
[Chinese (Simplified)](README_ZH-HANS.md) | **English**

# *Add KernelSU and Magisk Action*
# Add KernelSU and Magisk Action

## :warning: :warning: :warning: **Read README frist !!!!!**

The ***Plus*** version, can compile kernel, AnyKernel3, boot-kernelsu.img, boot-magisk.img, magisk.zip
The ***Plus*** version, can compile kernel, AnyKernel3 and boot image

The Actions to compile the Non-GKI kernel, with the optional addition of Magisk and KernelSU, is somewhat universal.

:warning: **The essence of this project is to simplify the configuration of the compilation environment and other steps (all similar repositories are), the kernel compilation of the parameters still need to find your own, otherwise the compilation will fail!**

**This repository is real, so if you want to see examples of builds, check out [the build repository](https://github.com/magojohnji/MAKSU/actions) named MAKSU.**

## ***Supported Kernels***

- *`5.10`*
- *`5.4`*
- *`4.19`*
- *`4.14`*
- *`4.9`*
- ***The other versions** ***may*** **be supported, but you need to try it for yourself!***

## ***Usage***
## **Usage**

> :warning: :warning: :warning: After compilation, AnyKernel3 will be uploaded in `Action` and so on, device checking has been turned off, please make sure your phone is unlocked before flashing it!
- Star this repository, then Fork this repository to make sure the workflow is running properly.

> Star is a source of motivation for authors, so please don't skimp on your Star!
- Rename the config file to config.env (the name can be customized, but **must** end with `.env`!)
- Rename the configuration file to `config.properties` (the name can be customized, as long as it is a plain text file)

- Write your favorite configuration in the configuration file, whose comments can be found in the lower part of this README.md.

Expand All @@ -50,7 +53,7 @@ The Actions to compile the Non-GKI kernel, with the optional addition of Magisk
echo "KERNEL_CONFIG=$(cat $CONFIG_ENV | grep -w "KERNEL_CONFIG" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV
```

- Change **`config.env.simple`** to the name of your configuration file. If you created a config file called **`config_abcdefg.env`** then you should fill in **`config_abcdefg.env`** here.
- Change **`config.env.simple`** to the name of your configuration file. If you created a config file called **`config_abcdefg.envaaa`** then you should fill in **`config_abcdefg.envaaa`** here.

- After that go to Actions and click on the green button `I understand my workflows, go ahead and enable them.` Click on Options (default is **`Build`**) and you'll see **`Run workflows`** at the top of the big dialog on the right, clicking on that will start the build. If **`Release`** is checked, it will release the build.

Expand Down Expand Up @@ -293,6 +296,12 @@ Custom Gcc 64 source code, support git repositories or direct links to zip or ta

If you use Custom Gcc 64, you can customize the branch of a third-party Gcc, e.g. `main`.

#### Custom Gcc 64 Bin

(String)

Customize the name of the Gcc 64 executable, AOSP Gcc is `aarch64-linux-android-`.

#### Use Custom Gcc 32

(true or false)
Expand All @@ -315,6 +324,12 @@ Custom Gcc 32 source code, support git repositories or direct links to zip or ta

If you use custom Gcc 32, you can customize the branch of a third-party Gcc, e.g. ``main``.

#### Custom Gcc 32 Bin

(String)

Customize the name of the Gcc 32 executable, for AOSP Gcc it is `arm-linux-androideabi-`.


### **Enable KernelSU**

Expand Down Expand Up @@ -404,6 +419,12 @@ Image file of the partition patched by Magisk, requires a direct link.

Example: https://raw.githubusercontent.com/abc/def/main/boot/boot.img

#### Mix KernelSU Magisk Boot Image

(true or false)

Mix KernelSU and Magisk into one image.

### **Build Settings**

---
Expand Down Expand Up @@ -515,27 +536,29 @@ ARCH=arm64

ENABLE_CLANG=true
USE_AOSP_CLANG=false
AOSP_CLANG_SYSTEM=linux-x86
AOSP_CLANG_BRANCH=master
AOSP_CLANG_VERSION=r450784e
AOSP_CLANG_SYSTEM=
AOSP_CLANG_BRANCH=
AOSP_CLANG_VERSION=
USE_CUSTOM_CLANG=true
CUSTOM_CLANG_SOURCE=https://gitlab.com/Panchajanya1999/azure-clang.git
CUSTOM_CLANG_BRANCH=main

ENABLE_GCC=true
ENABLE_AOSP_GCC_ARM64=false
ENABLE_AOSP_GCC_ARM32=false
AOSP_GCC_SYSTEM=linux-x86
AOSP_GCC_ARM64_VERSION=aarch64-linux-android-4.9
AOSP_GCC_ARM32_VERSION=arm-linux-androideabi-4.9
AOSP_GCC_ANDROID_VERSION=12.1.0
AOSP_GCC_RELEASE=r27
AOSP_GCC_SYSTEM=
AOSP_GCC_ARM64_VERSION=
AOSP_GCC_ARM32_VERSION=
AOSP_GCC_ANDROID_VERSION=
AOSP_GCC_RELEASE=
USE_CUSTOM_GCC_64=true
CUSTOM_GCC_64_SOURCE=https://github.com/magojohnji/gcc-arm64.git
CUSTOM_GCC_64_BRANCH=gcc-master
CUSTOM_GCC_64_BIN=aarch64-linux-android-
USE_CUSTOM_GCC_32=true
CUSTOM_GCC_32_SOURCE=https://github.com/magojohnji/gcc-arm32.git
CUSTOM_GCC_32_BRANCH=master
CUSTOM_GCC_32_BIN=arm-linux-androideabi-

ENABLE_KERNELSU=true
KERNELSU_INSTALLER=https://raw.githubusercontent.com/tiann/KernelSU/main/kernel/setup.sh
Expand All @@ -550,6 +573,8 @@ MAGISK_APK=https://cdn.jsdelivr.net/gh/magojohnji/magisk-file-host@master/delta/
MAGISK_PATCH_PARTITION=boot
MAGISK_SOURCE_BOOT_IMAGE=https://raw.githubusercontent.com/magojohnji/bin/main/boot_PE13_violet.img

MIX_KERNELSU_MAGISK_BOOT_IMAGE=true

DISABLE-LTO=false
DISABLE_CC_WERROR=false
ADD_KPROBES_CONFIG=true
Expand Down
Loading

0 comments on commit 98ffcc3

Please sign in to comment.