├── .github └── workflows │ └── build.yml ├── README.md ├── build_action.sh ├── build_on_uos.sh ├── config └── patch.d └── redmi_book_air_13_acpi.sh /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: Build kernel deb packages 2 | on: push 3 | 4 | jobs: 5 | build: 6 | name: Build kernel 7 | runs-on: ubuntu-latest 8 | container: debian:buster 9 | steps: 10 | - name: Checkout 11 | uses: actions/checkout@v3 12 | 13 | - name: Build 14 | run: bash build_action.sh 15 | 16 | - name: Artifact 17 | uses: actions/upload-artifact@v3 18 | with: 19 | name: artifact 20 | path: ${{ github.workspace }}/artifact/ 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # kernel_deb_builder 2 | 利用 GitHub Actions 自动编译 Linux 内核为 deb 包。 3 | 4 | # 如何使用 5 | 如果您想要利用我的这个自动化脚本根据自己的需求编译内核,请参考如下步骤: 6 | 7 | #### 1. Fork 仓库 8 | 访问 [https://github.com/debuggerx01/kernel_deb_builder](https://github.com/debuggerx01/kernel_deb_builder) ,点击右上角的 `Fork` 按钮,并 clone 到本地 9 | 10 | #### 2. 更新 config 文件 11 | 在本地将您获取的 config 文件替换根目录下的 `config`,可以从您系统的 `/boot/config*` 文件复制,或者手动编辑 12 | 13 | #### 3. 编写自定义修改脚本 14 | 当前 `/patch.d/` 目录下的修改脚本是只针对我自己的需求编写的,建议您先将其删掉,然后编写自己的脚本放在这个目录下,在脚本执行过程中会自动应用该目录下的所有脚本 15 | 16 | #### 4. 推送修改 17 | 推送后,action 自动触发,可以在您的仓库页面的 `Actions` 选项卡查看进度详情。 18 | 19 | Enjoy~ :grin: 20 | 21 | 了解更多请看: 22 | 23 | [利用 GitHub Actions 自动构建 Linux 内核为 deb 包](https://www.debuggerx.com/2021/08/17/Using-github-actions-to-build-kernel-deb-packages/) 24 | 25 | [修改 Linux 内核使系统启动时间缩短约 30 秒](https://www.debuggerx.com/2021/07/07/Modify-the-linux-kernel-to-reduce-the-boot-speed-by-about-30-seconds/) 26 | -------------------------------------------------------------------------------- /build_action.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | VERSION=$(grep 'Kernel Configuration' < config | awk '{print $3}') 4 | 5 | # add deb-src to sources.list 6 | sed -i "/deb-src/s/# //g" /etc/apt/sources.list 7 | 8 | # install dep 9 | apt update 10 | apt install -y wget xz-utils make gcc flex bison dpkg-dev bc rsync kmod cpio libssl-dev 11 | apt build-dep -y linux 12 | 13 | # change dir to workplace 14 | cd "${GITHUB_WORKSPACE}" || exit 15 | 16 | # download kernel source 17 | wget http://www.kernel.org/pub/linux/kernel/v5.x/linux-"$VERSION".tar.xz 18 | tar -xf linux-"$VERSION".tar.xz 19 | cd linux-"$VERSION" || exit 20 | 21 | # copy config file 22 | cp ../config .config 23 | 24 | # disable DEBUG_INFO to speedup build 25 | scripts/config --disable DEBUG_INFO 26 | 27 | # apply patches 28 | # shellcheck source=src/util.sh 29 | source ../patch.d/*.sh 30 | 31 | # build deb packages 32 | CPU_CORES=$(($(grep -c processor < /proc/cpuinfo)*2)) 33 | make deb-pkg -j"$CPU_CORES" 34 | 35 | # move deb packages to artifact dir 36 | cd .. 37 | rm -rfv *dbg*.deb 38 | mkdir "artifact" 39 | mv ./*.deb artifact/ 40 | -------------------------------------------------------------------------------- /build_on_uos.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | VERSION=$(grep 'Kernel Configuration' < /boot/config-"$(uname -r)" | awk '{print $3}') 4 | 5 | # add deb-src to sources.list 6 | echo "deb-src https://home-packages.chinauos.com/home plum main contrib non-free" >> /etc/apt/sources.list 7 | 8 | # install dep 9 | sudo apt update 10 | sudo apt install -y wget 11 | sudo apt build-dep -y linux 12 | 13 | # download kernel source 14 | wget http://www.kernel.org/pub/linux/kernel/v5.x/linux-"$VERSION".tar.xz 15 | tar -xf linux-"$VERSION".tar.xz 16 | cd linux-"$VERSION" || exit 17 | 18 | # copy config file 19 | cp /boot/config-"$(uname -r)" .config 20 | 21 | # change version string 22 | sed -i "s/-desktop/-debuggerx/g" .config 23 | 24 | # reduce ACPI_MAX_LOOP_TIMEOUT value 25 | sed -i "/ACPI_MAX_LOOP_TIMEOUT/s/30/3/g" include/acpi/acconfig.h 26 | 27 | # disable DEBUG_INFO to speedup build 28 | scripts/config --disable DEBUG_INFO 29 | 30 | CPU_CORES=$(grep -c processor < /proc/cpuinfo) 31 | make deb-pkg -j"$CPU_CORES" -------------------------------------------------------------------------------- /patch.d/redmi_book_air_13_acpi.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # reduce ACPI_MAX_LOOP_TIMEOUT value 4 | sed -i "/ACPI_MAX_LOOP_TIMEOUT/s/30/3/g" include/acpi/acconfig.h 5 | 6 | # make kernel version to 5.xx.0 7 | sed -i '/SUBLEVEL =/s/[0-9].*/0/g' Makefile 8 | --------------------------------------------------------------------------------