|
| 1 | +# Build Your Own Kernel |
| 2 | + |
| 3 | +English | [中文文档](./README.zh_CN.md) |
| 4 | + |
| 5 | +In this part, we will use `Github Action` to perform kernel cloud compilation. The directory structure of this project is as follows: |
| 6 | + |
| 7 | +```sh |
| 8 | +. |
| 9 | +├── configs |
| 10 | +│ ├── markw.config.json |
| 11 | +│ ├── thyme.config.json |
| 12 | +│ └── wayne.config.json |
| 13 | +└── LXC |
| 14 | + ├── LXC_defconfig |
| 15 | + └── Patches |
| 16 | + ├── cgroup.patch |
| 17 | + └── xt_qtaguid.patch |
| 18 | +``` |
| 19 | + |
| 20 | +The contents and functions of each part are as follows: |
| 21 | + |
| 22 | +- **configs**: used to store the detailed configuration of all kernels to be compiled (kernel source code address, compilation tool chain, compilation parameters and additional compilation options) |
| 23 | +- **LXC**: stores some configuration files and patches required for kernel support `Docker` |
| 24 | + - **LXC_defconfig**: Options that need to be enabled for kernel support `Docker` |
| 25 | + - **Patches**: Some patches that need to be applied |
| 26 | + |
| 27 | +## Development progress |
| 28 | + |
| 29 | +- [x] `AnyKernel3` original and customized versions supported |
| 30 | +- [x] `KernelSU` compilation support |
| 31 | +- [x] `Docker` compilation support |
| 32 | +- [x] Use repository owner information to compile |
| 33 | +- [ ] Use `MagiskBoot` to generate `boot.img` |
| 34 | +- [ ] Compile kernel script locally |
| 35 | +- [ ] Web page configuration Json compilation configuration file (to be released soon) |
| 36 | +- [ ] Cloud compiled kernel web page |
| 37 | + |
| 38 | +## Github Action |
| 39 | + |
| 40 | +### Introduction to the compilation process |
| 41 | + |
| 42 | +The `Github Action` file for compiling the kernel is [kernel.yml](../.github/workflows/kernel.yml). This Action contains the following two jobs: |
| 43 | + |
| 44 | +- `Read-configuration`: used to read the configuration files in the `configs` folder |
| 45 | +- `Build-Kernel`: Compile the text kernel according to the read configuration file, and perform functions such as uploading |
| 46 | + |
| 47 | +### Compilation process timeline |
| 48 | + |
| 49 | +```mermaid |
| 50 | +%%{init: { 'logLevel': 'debug', 'theme': 'neutral' } }%% |
| 51 | +timeline |
| 52 | + How to build a Kernel |
| 53 | + section Read configuration |
| 54 | + Checkout repository |
| 55 | + Generate configuration matrix |
| 56 | + Set builddate |
| 57 | + section Kernel Build |
| 58 | + Prepare : 📐 Set swap to 10G : 😄 Checkout repository |
| 59 | + : ⭐ Install prerequisites for Ubuntu : 🚄 Setup ccache : 🚅 Restore cache |
| 60 | + : 🌟 Clone kernel source : 💫 Get toolchains |
| 61 | + Basic configuration : 😎 Set build args : 😋 Setup KernelSU : 😋 Setup LXC Docker |
| 62 | + : 👍 Build kernel |
| 63 | + section Post build |
| 64 | + Upload Artifact : 💛 Upload Image : 💙 Upload Image.gz : 💙 Upload Image.gz-dtb |
| 65 | + : 💜 Upload dtb : ❤️ Upload dtbo.img : ☢️ Upload output directory |
| 66 | + Pack Anykernel3 : ⏰ Get Anykernel3 : ⏰ Pack your kernel : 💾 Upload AnyKernel3 package |
| 67 | + Release |
| 68 | +``` |
| 69 | + |
| 70 | +## Configuration file parsing |
| 71 | + |
| 72 | +Please see [Compile Configuration](./configs/) for specific configuration methods. |
| 73 | + |
| 74 | +## Instructions |
| 75 | + |
| 76 | +The basic usage of this project is as follows: |
| 77 | + |
| 78 | +1. `fork` this project on GitHub |
| 79 | + |
| 80 | +2. Modify the `config/*.config.json` file through the Github web page or pull it locally, and submit the changes |
| 81 | + |
| 82 | +3. View the `Action` page of the Github page and find `Build kernels` and `Run workflow` |
| 83 | + |
| 84 | +4. After the compilation is completed, you can enter the corresponding page to download the compiled product. |
| 85 | + |
| 86 | +5. Use your favorite packaging software for kernel packaging ([AnyKernel3](https://github.com/osm0sis/AnyKernel3), [Android-Image-Kitchen](https://github.com/osm0sis/Android-Image-Kitchen), [MagiskBoot](https://github.com/topjohnwu/Magisk/releases), etc. **Currently this project only integrates AnyKernel3**) |
| 87 | + |
| 88 | + |
| 89 | + |
| 90 | +## Local build |
| 91 | + |
| 92 | +### 1. Run `Action` locally |
| 93 | + |
| 94 | +If you don't want to repeatedly execute `Action` on `Github`, you can use [nektos/act](https://github.com/nektos/act) to test this build process and output it in the local environment. |
| 95 | + |
| 96 | +After installing [nektos/act](https://github.com/nektos/act) and execute the following instructions: |
| 97 | + |
| 98 | +```sh |
| 99 | +# Collect build files into the /tmp/artifacts folder: |
| 100 | +act --artifact-server-path /tmp/artifacts |
| 101 | +``` |
| 102 | + |
| 103 | +If you need to place it in a local location you like, please change `/tmp/artifacts` to your preferred directory. |
| 104 | + |
| 105 | +If an error is reported during the process, please add the parameter `-v` and re-execute to obtain the error report and submit an `issue`. The specific command is as follows: |
| 106 | + |
| 107 | +```sh |
| 108 | +# Collect build files into the /tmp/artifacts folder: |
| 109 | +act --artifact-server-path /tmp/artifacts -v |
| 110 | +``` |
| 111 | + |
| 112 | +## FAQ |
| 113 | + |
| 114 | +### 1. GitHub release failed with status: `403` |
| 115 | + |
| 116 | +When you use `softprops/action-gh-release@v1` to publish `Release`, you may encounter the following error: |
| 117 | + |
| 118 | +```plaintext |
| 119 | +👩🏭 Creating new GitHub release for tag v20230619.7... |
| 120 | +⚠️ GitHub release failed with status: 403 |
| 121 | +undefined |
| 122 | +retrying... (2 retries remaining) |
| 123 | +👩🏭 Creating new GitHub release for tag v20230619.7... |
| 124 | +⚠️ GitHub release failed with status: 403 |
| 125 | +undefined |
| 126 | +retrying... (1 retries remaining) |
| 127 | +👩🏭 Creating new GitHub release for tag v20230619.7... |
| 128 | +⚠️ GitHub release failed with status: 403 |
| 129 | +undefined |
| 130 | +retrying... (0 retries remaining) |
| 131 | +❌ Too many retries. Aborting... |
| 132 | +Error: Too many retries. |
| 133 | +``` |
| 134 | + |
| 135 | +This is caused by your `Workflow` not having **read and write permission**: |
| 136 | + |
| 137 | + |
| 138 | + |
| 139 | +Open the corresponding read and write permissions as shown above, and then re-run `Action` to publish your own `Release` |
| 140 | + |
| 141 | +# Acknowledgments |
| 142 | + |
| 143 | +- [weishu](https://github.com/tiann) : Developer of KernelSU |
| 144 | +- [AKR Android Developer Community](https://www.akr-developers.com/) : Provides build tutorials |
| 145 | +- [DogDayAndroid/KSU_Thyme_BuildBot](https://github.com/DogDayAndroid/KSU_Thyme_BuildBot) : Predecessor of this project |
| 146 | +- [xiaoleGun/KernelSU_Action](https://github.com/xiaoleGun/KernelSU_Action) : Drawing on some Github Actions |
| 147 | +- [UtsavBalar1231/Drone-scripts](https://github.com/UtsavBalar1231/Drone-scripts) : Drawing on some Github Actions |
0 commit comments