diff --git a/action.yml b/action.yml index a035c72883..e99af6c7b7 100644 --- a/action.yml +++ b/action.yml @@ -49,6 +49,10 @@ inputs: description: "Set the kernel custom signature" required: false default: "-meson64-dev" + kernel_config: + description: "Set the path of kernel .config" + required: false + default: "compile-kernel/tools/config" runs: using: "composite" @@ -126,6 +130,8 @@ runs: [ -n ${{ inputs.kernel_version }} ] && make_command="${make_command} -k ${{ inputs.kernel_version }}" [ -n ${{ inputs.kernel_auto }} ] && make_command="${make_command} -a ${{ inputs.kernel_auto }}" [ -n ${{ inputs.kernel_sign }} ] && make_command="${make_command} -n ${{ inputs.kernel_sign }}" + [ -n ${{ inputs.kernel_config }} ] && make_command="${make_command} -c ${{ inputs.kernel_config }}" + sudo chmod +x recompile sudo ./recompile ${make_command} diff --git a/compile-kernel/README.cn.md b/compile-kernel/README.cn.md index fae352e490..9f5f793a97 100644 --- a/compile-kernel/README.cn.md +++ b/compile-kernel/README.cn.md @@ -11,14 +11,15 @@ | -d | Defaults | 使用默认配置 | | -k | Kernel | 指定 [kernel](https://cdn.kernel.org/pub/linux/kernel/v5.x/) 名称,如 `-k 5.4.170` . 多个内核使用 `_` 进行连接,如 `-k 5.15.13_5.4.170` | | -a | AutoKernel | 设置是否自动采用同系列最新版本内核。当为 `true` 时,将自动查找在 `-k` 中指定的内核如 `5.4.170` 的 `5.4` 同系列是否有更新的版本,如有 `5.4.170` 之后的最新版本时,将自动更换为最新版。设置为 `false` 时将编译指定版本内核。默认值:`true` | +| -c | ConfigPath | 设置内核编译时 [.config](tools/config) 配置文件模板的存放路径。在此目录下存放的各系列的内核配置模板都必须以 `config-5.x` 的名称为开头,例如编译 `5.4` 系列内核的模板可命名为以 `config-5.4` 开头的各种名字,如 `config-5.4` 、 `config-5.4.174` 或者 `config-5.4.174-xiaoming` 等,有多个以 `config-5.4` 为开头的文件时,将使用版本号最大的文件。默认值:`compile-kernel/tools/config` | | -n | CustomName | 设置内核自定义签名。默认值为 `-meson64-dev` ,生成的内核名称为 `5.4.170-meson64-dev` 。设置自定义签名时请勿包含空格。 | -| -r | Repo | 指定编译内核的源代码仓库。默认为 `unifreq` 。可选择 `kernel.org` 的源码和 `github.com` 的内核源代码仓库。例如 `-r kernel.org` 或 `-r unifreq` 或 `-r chewitt/linux@amlogic-5.4.y` 。当使用 `github.com` 的内核源代码仓库时,可设置参数格式为 `owner/repo@branch` 三项组合,参数中的所有者名称 `owner` 为必选参数,内核源代码仓库名称 `/repo` 和 仓库的分支名称 `@branch` 为可选参数。当仅指定所有者名称 `owner` 参数时,将自动匹配所有者的名称为 `linux-5.x.y` 格式且分支为 `main` 的内核源代码仓库。如果仓库名称或分支名称不同,请使用组合方式指定,如 `owner@branch` 或 `owner/repo` 或 `owner/repo@branch` | +| -r | Repo | 指定编译内核的源代码仓库。默认为 `unifreq` 。可选择 `kernel.org` 的源码和 `github.com` 的内核源代码仓库。例如 `-r kernel.org` 或 `-r unifreq` 等。当使用 `github.com` 的内核源代码仓库时,可设置参数格式为 `owner/repo@branch` 三项组合,参数中的所有者名称 `owner` 为必选参数,内核源代码仓库名称 `/repo` 和 仓库的分支名称 `@branch` 为可选参数。当仅指定所有者名称 `owner` 参数时,将自动匹配所有者的名称为 `linux-5.x.y` 格式且分支为 `main` 的内核源代码仓库。如果仓库名称或分支名称不同,请使用组合方式指定,如 `owner@branch` 或 `owner/repo` 或 `owner/repo@branch` | - `sudo ./recompile -d -k 5.4.170` : 使用默认配置,并通过 `-k` 进行指定需要编译的内核版本,多个版本同时编译时使用 `_` 进行连接。 - `sudo ./recompile -d -k 5.4.170 -a true` : 使用默认配置,并通过 `-a` 参数设置编译内核时,是否自动升级到同系列最新内核。 -- `sudo ./recompile -d -k 5.4.170 -n -leifeng` : 使用默认配置,并通过 `-n` 参数设置内核自定义签名。 +- `sudo ./recompile -d -k 5.4.170 -n -xiaoming` : 使用默认配置,并通过 `-n` 参数设置内核自定义签名。 - `sudo ./recompile -d -k 5.4.170 -r kernel.org` : 使用默认配置,并通过 `-r` 参数设置内核源代码仓库。 -- `sudo ./recompile -d -k 5.15.13_5.4.170 -a true -n -leifeng -r kernel.org` : 使用默认配置,并通过多个参数进行设置。 +- `sudo ./recompile -d -k 5.15.13_5.4.170 -a true -n -xiaoming -r kernel.org` : 使用默认配置,并通过多个参数进行设置。 💡提示:推荐使用 `unifreq` 的 [.config](https://github.com/unifreq/arm64-kernel-configs) 模板和源码编译 [5.4](https://github.com/unifreq/linux-5.4.y) / [5.10](https://github.com/unifreq/linux-5.10.y) / [5.15](https://github.com/unifreq/linux-5.15.y) 等内核的 `最新版本` 。`其他系列或历史版本` 可以使用 [kernel.org](https://cdn.kernel.org/pub/linux/kernel/v5.x/) 编译。你也可以使用其他内核源代码仓库。 @@ -63,10 +64,11 @@ sudo apt-get install -y $(curl -fsSL git.io/ubuntu-2004-server) | 参数 | 默认值 | 说明 | |------------------------|------------------------|------------------------------------------------| | build_target | kernel | 固定参数 `kernel`,设置编译目标为内核。 | -| kernel_repo | unifreq | 指定编译内核的源代码仓库。默认为 `unifreq` 。可选择 `kernel.org` 的源码和 `github.com` 的内核源代码仓库。例如 `kernel.org` 或 `unifreq` 或 `chewitt/linux@amlogic-5.4.y` 。当使用 `github.com` 的内核源代码仓库时,可设置参数格式为 `owner/repo@branch` 三项组合,参数中的所有者名称 `owner` 为必选参数,内核源代码仓库名称 `/repo` 和 仓库的分支名称 `@branch` 为可选参数。当仅指定所有者名称 `owner` 参数时,将自动匹配所有者的名称为 `linux-5.x.y` 格式且分支为 `main` 的内核源代码仓库。如果仓库名称或分支名称不同,请使用组合方式指定,如 `owner@branch` 或 `owner/repo` 或 `owner/repo@branch` | +| kernel_repo | unifreq | 指定编译内核的源代码仓库。默认为 `unifreq` 。可选择 `kernel.org` 的源码和 `github.com` 的内核源代码仓库。例如 `kernel.org` 或 `unifreq` 。当使用 `github.com` 的内核源代码仓库时,可设置参数格式为 `owner/repo@branch` 三项组合,参数中的所有者名称 `owner` 为必选参数,内核源代码仓库名称 `/repo` 和 仓库的分支名称 `@branch` 为可选参数。当仅指定所有者名称 `owner` 参数时,将自动匹配所有者的名称为 `linux-5.x.y` 格式且分支为 `main` 的内核源代码仓库。如果仓库名称或分支名称不同,请使用组合方式指定,如 `owner@branch` 或 `owner/repo` 或 `owner/repo@branch` | | kernel_version | 5.15.13_5.4.170 | 指定 [kernel](https://cdn.kernel.org/pub/linux/kernel/v5.x/) 名称,如 `5.4.170` . 多个内核使用 `_` 进行连接,如 `5.15.13_5.4.170` | | kernel_auto | true | 设置是否自动采用同系列最新版本内核。当为 `true` 时,将自动查找在指定的内核如 `5.4.170` 的 `5.4` 同系列是否有更新的版本,如有 `5.4.170` 之后的最新版本时,将自动更换为最新版。设置为 `false` 时将编译指定版本内核。默认值:`true` | | kernel_sign | -meson64-dev | 设置内核自定义签名。默认值为 `-meson64-dev` ,生成的内核名称为 `5.4.170-meson64-dev` 。设置自定义签名时请勿包含空格。 | +| kernel_config | compile-kernel/tools/config | 设置内核编译时 [.config](tools/config) 配置文件模板的存放路径。在此目录下存放的各系列的内核配置模板都必须以 `config-5.x` 的名称为开头,例如编译 `5.4` 系列内核的模板可命名为以 `config-5.4` 开头的各种名字,如 `config-5.4` 、 `config-5.4.174` 或者 `config-5.4.174-xiaoming` 等,有多个以 `config-5.4` 为开头的文件时,将使用版本号最大的文件。默认值:`compile-kernel/tools/config` | - GitHub Action 输出变量说明 diff --git a/compile-kernel/README.md b/compile-kernel/README.md index c6cacb84ce..408b4be904 100644 --- a/compile-kernel/README.md +++ b/compile-kernel/README.md @@ -11,14 +11,15 @@ Compile a custom kernel as needed. This kernel can be used in [Armbian](https:// | -d | Defaults | Compile all kernels with default configuration. | | -k | Kernel | Specify [kernel](https://cdn.kernel.org/pub/linux/kernel/v5.x/) name, such as `-k 5.4.170`. Multiple kernels use `_` to connect, such as `- k 5.15.13_5.4.170` | | -a | AutoKernel | Set whether to automatically adopt the latest version of the kernel of the same series. When it is `true`, it will automatically find whether there is a newer version of the kernel specified in `-k` such as `5.4.170` of the `5.4` series. If there is the latest version after `5.4.170`, it will be automatically replaced with the latest version . When set to `false`, the specified version of the kernel will be compiled. Default value: `true` | +| -c | ConfigPath | Set the storage path of the [.config](tools/config) configuration file template when the kernel is compiled. The kernel configuration templates of each series stored in this directory must start with the name of `config-5.x`. For example, templates for compiling `5.4` series kernels can be named with various names starting with `config-5.4`, such as `config-5.4`, `config-5.4.174` or `config-5.4.174-xiaoming`, etc., When there are multiple files starting with `config-5.4`, the file with the highest version number will be used. Default: `compile-kernel/tools/config` | | -n | CustomName | Set the kernel custom signature. The default value is `-meson64-dev` and the generated kernel is `5.4.170-meson64-dev`. Do not include spaces when setting a custom signature. | -| -r | Repo | Specifies the source code repository for the compiled kernel. Defaults to `unifreq` . You can choose the source code of `kernel.org` and the kernel source of `github.com` code repository. For example `-r kernel.org` or `-r unifreq` or `-r chewitt/linux@amlogic-5.4.y` . When using the kernel source code repository of `github.com`, the parameter format can be set to the three-item combination of `owner/repo@branch` , The owner name `owner` in the parameters is a required parameter, the kernel source code repository name `/repo` and the repository branch name `@branch` are optional parameters. When only the owner name `owner` parameter is specified, it will automatically match kernel source code repositories whose owner's name is in `linux-5.x.y` format and branch is `main`. If the repository name or branch name is different, use a combination, such as `owner@branch` or `owner/repo` or `owner/repo@branch` | +| -r | Repo | Specifies the source code repository for the compiled kernel. Defaults to `unifreq` . You can choose the source code of `kernel.org` and the kernel source of `github.com` code repository. For example `-r kernel.org` or `-r unifreq`, etc., When using the kernel source code repository of `github.com`, the parameter format can be set to the three-item combination of `owner/repo@branch` , The owner name `owner` in the parameters is a required parameter, the kernel source code repository name `/repo` and the repository branch name `@branch` are optional parameters. When only the owner name `owner` parameter is specified, it will automatically match kernel source code repositories whose owner's name is in `linux-5.x.y` format and branch is `main`. If the repository name or branch name is different, use a combination, such as `owner@branch` or `owner/repo` or `owner/repo@branch` | - `sudo ./recompile -d -k 5.4.170`: Use the default configuration, and use the `-k` parameter to specify the kernel version to be compiled, and use `_` to link when multiple versions are compiled at the same time. - `sudo ./recompile -d -k 5.4.170 -a true`: Use the default configuration, and use the `-a` parameter to set whether to automatically upgrade to the latest kernel of the same series when compiling the kernel. -- `sudo ./recompile -d -k 5.4.170 -n -leifeng`: Use the default configuration, and use the `-n` parameter to set the kernel custom signature. +- `sudo ./recompile -d -k 5.4.170 -n -xiaoming`: Use the default configuration, and use the `-n` parameter to set the kernel custom signature. - `sudo ./recompile -d -k 5.4.170 -r kernel.org`: Use the default configuration, and set the kernel source code repository through the `-r` parameter. -- `sudo ./recompile -d -k 5.15.13_5.4.170 -a true -n -leifeng -r kernel.org`: Use the default configuration, and set through multiple parameters. +- `sudo ./recompile -d -k 5.15.13_5.4.170 -a true -n -xiaoming -r kernel.org`: Use the default configuration, and set through multiple parameters. 💡Tip: Recommended Use the [.config](https://github.com/unifreq/arm64-kernel-configs) template and source code of `unifreq` to compile the `latest version` of [5.4](https://github.com/unifreq/linux-5.4.y) / [5.10](https://github.com/unifreq/linux-5.10.y) / [5.15](https://github.com/unifreq/linux-5.15.y), etc. `Other series or historical versions` can be compiled with [kernel.org](https://cdn.kernel.org/pub/linux/kernel/v5.x/). You can also use other kernel source code repositories. @@ -63,11 +64,11 @@ You can call the kernel compilation script of this repository through Actions in | Parameter | Meaning | Description | | ---- | ---- | ---- | | build_target | kernel | Fixed parameter `kernel`, set the compilation target to the kernel. | -| kernel_repo | unifreq | Specifies the source code repository for the compiled kernel. Defaults to `unifreq` . You can choose the source code of `kernel.org` and the kernel source of `github.com` code repository. For example `kernel.org` or `unifreq` or `chewitt/linux@amlogic-5.4.y` . When using the kernel source code repository of `github.com`, the parameter format can be set to the three-item combination of `owner/repo@branch` , The owner name `owner` in the parameters is a required parameter, the kernel source code repository name `/repo` and the repository branch name `@branch` are optional parameters. When only the owner name `owner` parameter is specified, it will automatically match kernel source code repositories whose owner's name is in `linux-5.x.y` format and branch is `main`. If the repository name or branch name is different, use a combination, such as `owner@branch` or `owner/repo` or `owner/repo@branch` | +| kernel_repo | unifreq | Specifies the source code repository for the compiled kernel. Defaults to `unifreq` . You can choose the source code of `kernel.org` and the kernel source of `github.com` code repository. For example `kernel.org` or `unifreq`, etc., When using the kernel source code repository of `github.com`, the parameter format can be set to the three-item combination of `owner/repo@branch` , The owner name `owner` in the parameters is a required parameter, the kernel source code repository name `/repo` and the repository branch name `@branch` are optional parameters. When only the owner name `owner` parameter is specified, it will automatically match kernel source code repositories whose owner's name is in `linux-5.x.y` format and branch is `main`. If the repository name or branch name is different, use a combination, such as `owner@branch` or `owner/repo` or `owner/repo@branch` | | kernel_version | 5.15.13_5.4.170 | Specify [kernel](https://cdn.kernel.org/pub/linux/kernel/v5.x/) name, such as `5.4.170`. Multiple kernels use `_` to connect, such as `5.15.13_5.4.170` | | kernel_auto | true | Set whether to automatically adopt the latest version of the kernel of the same series. When it is `true`, it will automatically find whether there is a newer version of the kernel such as `5.4.170` of the `5.4` series. If there is the latest version after `5.4.170`, it will be automatically replaced with the latest version . When set to `false`, the specified version of the kernel will be compiled. Default value: `true` | | kernel_sign | -meson64-dev | Set the kernel custom signature. The default value is `-meson64-dev` and the generated kernel is `5.4.170-meson64-dev`. Do not include spaces when setting a custom signature. | - +| kernel_config | compile-kernel/tools/config | Set the storage path of the [.config](tools/config) configuration file template when the kernel is compiled. The kernel configuration templates of each series stored in this directory must start with the name of `config-5.x`. For example, templates for compiling `5.4` series kernels can be named with various names starting with `config-5.4`, such as `config-5.4`, `config-5.4.174` or `config-5.4.174-xiaoming`, etc., When there are multiple files starting with `config-5.4`, the file with the highest version number will be used. Default: `compile-kernel/tools/config` | - GitHub Action Output variable description diff --git a/recompile b/recompile index 1cd2e53bd5..abc7b73b1f 100755 --- a/recompile +++ b/recompile @@ -36,9 +36,8 @@ make_path=${PWD} compile_path="${make_path}/compile-kernel" kernel_path="${compile_path}/kernel" out_kernel="${compile_path}/output" -config_dir="${compile_path}/tools/config" -uInitrd_dir="${compile_path}/tools/uInitrd" -script_dir="${compile_path}/tools/script" +config_path="${compile_path}/tools/config" +script_path="${compile_path}/tools/script" moredtb_path="${make_path}/build-armbian/amlogic-dtb" arch_info=$(arch) auto_kernel="true" @@ -55,14 +54,14 @@ repo_owner="unifreq" repo_branch="main" # Cross compile toolchain, run on ubuntu-20.04 -toolchain_dir="/usr/local/toolchain_x86_64_aarch64" +toolchain_path="/usr/local/toolchain_x86_64_aarch64" dev_repo="https://github.com/ophub/script/releases/download/dev" # armbian armbian_rootfs_file="armbian_22.02.0_Aml_s922x_bullseye_5.10.93.tar.xz" -armbian_dir="${compile_path}/tools/armbian" -armbian_file="${armbian_dir}/armbian.img" -chroot_dir="${out_kernel}/chroot" -chroot_file="${chroot_dir}/armbian.img" +armbian_path="${compile_path}/tools/armbian" +armbian_file="${armbian_path}/armbian.img" +chroot_path="${out_kernel}/chroot" +chroot_file="${chroot_path}/armbian.img" # gcc #gcc_repo="https://developer.arm.com/-/media/Files/downloads/gnu-a/10.3-2021.07/binrel" gcc_file="gcc-arm-10.3-2021.07-x86_64-aarch64-none-linux-gnu.tar.xz" @@ -97,34 +96,34 @@ toolchain_check() { cd ${make_path} echo -e "${STEPS} Check the cross-compilation environment ..." - [ -d "${toolchain_dir}" ] || mkdir -p ${toolchain_dir} + [ -d "${toolchain_path}" ] || mkdir -p ${toolchain_path} # Download gcc - if [ ! -d "${toolchain_dir}/${gcc_file//.tar.xz/}/bin" ]; then + if [ ! -d "${toolchain_path}/${gcc_file//.tar.xz/}/bin" ]; then echo -e "${INFO} Download gcc [ ${gcc_file} ] ..." - wget -c "${dev_repo}/${gcc_file}" -O "${toolchain_dir}/${gcc_file}" >/dev/null 2>&1 && sync - tar -xJf ${toolchain_dir}/${gcc_file} -C ${toolchain_dir} && sync - rm -f ${toolchain_dir}/${gcc_file} && sync - [ -d "${toolchain_dir}/${gcc_file//.tar.xz/}/bin" ] || error_msg "The gcc is not set!" + wget -c "${dev_repo}/${gcc_file}" -O "${toolchain_path}/${gcc_file}" >/dev/null 2>&1 && sync + tar -xJf ${toolchain_path}/${gcc_file} -C ${toolchain_path} && sync + rm -f ${toolchain_path}/${gcc_file} && sync + [ -d "${toolchain_path}/${gcc_file//.tar.xz/}/bin" ] || error_msg "The gcc is not set!" fi # Download clang - if [ ! -d "${toolchain_dir}/${clang_file//.tar.xz/}/bin" ]; then + if [ ! -d "${toolchain_path}/${clang_file//.tar.xz/}/bin" ]; then echo -e "${INFO} Download clang [ ${clang_file} ] ..." - wget -c "${dev_repo}/${clang_file}" -O "${toolchain_dir}/${clang_file}" >/dev/null 2>&1 && sync - tar -xJf ${toolchain_dir}/${clang_file} -C ${toolchain_dir} && sync - rm -f ${toolchain_dir}/${clang_file} && sync - [ -d "${toolchain_dir}/${clang_file//.tar.xz/}/bin" ] || error_msg "The clang is not set!" + wget -c "${dev_repo}/${clang_file}" -O "${toolchain_path}/${clang_file}" >/dev/null 2>&1 && sync + tar -xJf ${toolchain_path}/${clang_file} -C ${toolchain_path} && sync + rm -f ${toolchain_path}/${clang_file} && sync + [ -d "${toolchain_path}/${clang_file//.tar.xz/}/bin" ] || error_msg "The clang is not set!" fi # Download armbian if [ ! -f "${armbian_file}" ]; then echo -e "${INFO} Download armbian [ ${armbian_rootfs_file} ] ..." - rm -rf ${armbian_dir} 2>/dev/null && mkdir -p ${armbian_dir} - wget -c "${dev_repo}/${armbian_rootfs_file}" -O "${armbian_dir}/${armbian_rootfs_file}" >/dev/null 2>&1 && sync - tar -xJf ${armbian_dir}/${armbian_rootfs_file} -C ${armbian_dir} && sync - mv -f ${armbian_dir}/*.img ${armbian_file} && sync - rm -f ${armbian_dir}/${armbian_rootfs_file} && sync + rm -rf ${armbian_path} 2>/dev/null && mkdir -p ${armbian_path} + wget -c "${dev_repo}/${armbian_rootfs_file}" -O "${armbian_path}/${armbian_rootfs_file}" >/dev/null 2>&1 && sync + tar -xJf ${armbian_path}/${armbian_rootfs_file} -C ${armbian_path} && sync + mv -f ${armbian_path}/*.img ${armbian_file} && sync + rm -f ${armbian_path}/${armbian_rootfs_file} && sync [ -f "${armbian_file}" ] || error_msg "There is no armbian file: [ ${armbian_file} ]" fi } @@ -179,33 +178,33 @@ download_kernel() { # kernel_folder > kernel_.tar.xz_file > download_from_kernel.org echo -e "${STEPS} Start query and download the kernel." [ -d "${kernel_path}" ] || mkdir -p ${kernel_path} - if [ ! -d "${kernel_path}/${local_kernel_dirname}" ]; then + if [ ! -d "${kernel_path}/${local_kernel_path}" ]; then if [ "${code_owner}" == "kernel.org" ]; then - if [ -f "${kernel_path}/${local_kernel_dirname}.tar.xz" ]; then - echo -e "${INFO} Unzip local files [ ${local_kernel_dirname}.tar.xz ]" + if [ -f "${kernel_path}/${local_kernel_path}.tar.xz" ]; then + echo -e "${INFO} Unzip local files [ ${local_kernel_path}.tar.xz ]" cd ${kernel_path} - tar -xJf ${local_kernel_dirname}.tar.xz - [ "$?" -eq "0" ] || error_msg "[ ${local_kernel_dirname}.tar.xz ] file decompression failed." + tar -xJf ${local_kernel_path}.tar.xz + [ "$?" -eq "0" ] || error_msg "[ ${local_kernel_path}.tar.xz ] file decompression failed." else - echo -e "${INFO} [ ${kernel_version} ] Kernel loading from [ ${server_kernel_repo}${local_kernel_dirname}.tar.xz ]" - wget -q -P ${kernel_path} ${server_kernel_repo}${local_kernel_dirname}.tar.xz && sync - if [[ "$?" -eq "0" && -s "${kernel_path}/${local_kernel_dirname}.tar.xz" ]]; then + echo -e "${INFO} [ ${kernel_version} ] Kernel loading from [ ${server_kernel_repo}${local_kernel_path}.tar.xz ]" + wget -q -P ${kernel_path} ${server_kernel_repo}${local_kernel_path}.tar.xz && sync + if [[ "$?" -eq "0" && -s "${kernel_path}/${local_kernel_path}.tar.xz" ]]; then echo -e "${SUCCESS} The kernel file is downloaded successfully." cd ${kernel_path} - tar -xJf ${local_kernel_dirname}.tar.xz && sync - [ -d "${local_kernel_dirname}" ] || error_msg "[ ${local_kernel_dirname}.tar.xz ] file decompression failed." + tar -xJf ${local_kernel_path}.tar.xz && sync + [ -d "${local_kernel_path}" ] || error_msg "[ ${local_kernel_path}.tar.xz ] file decompression failed." else error_msg "Kernel file download failed!" fi fi else echo -e "${INFO} Start cloning from [ https://github.com/${server_kernel_repo} -b ${code_branch} ]" - git clone --depth 1 https://github.com/${server_kernel_repo} -b ${code_branch} ${kernel_path}/${local_kernel_dirname} + git clone --depth 1 https://github.com/${server_kernel_repo} -b ${code_branch} ${kernel_path}/${local_kernel_path} [ "$?" -eq "0" ] || error_msg "[ https://github.com/${server_kernel_repo} ] Clone failed." fi elif [ "${code_owner}" != "kernel.org" ]; then # Get a local kernel version - local_makefile="${kernel_path}/${local_kernel_dirname}/Makefile" + local_makefile="${kernel_path}/${local_kernel_path}/Makefile" local_makefile_version="$(cat ${local_makefile} | grep -oE "VERSION =.*" | head -n 1 | grep -oE '[0-9]{1,3}')" local_makefile_patchlevel="$(cat ${local_makefile} | grep -oE "PATCHLEVEL =.*" | head -n 1 | grep -oE '[0-9]{1,3}')" local_makefile_sublevel="$(cat ${local_makefile} | grep -oE "SUBLEVEL =.*" | head -n 1 | grep -oE '[0-9]{1,3}')" @@ -213,7 +212,7 @@ download_kernel() { # Local version and server version comparison if [[ "${auto_kernel}" == "true" && "${kernel_sub}" -gt "${local_makefile_sublevel}" ]]; then # Pull the latest source code of the server - cd ${kernel_path}/${local_kernel_dirname} + cd ${kernel_path}/${local_kernel_path} git checkout ${code_branch} && git reset --hard origin/${code_branch} && git pull && sync unset kernel_version kernel_version="${local_makefile_version}.${local_makefile_patchlevel}.${kernel_sub}" @@ -249,18 +248,18 @@ compile_env_check() { } make_kernel() { - cd ${kernel_path}/${local_kernel_dirname} + cd ${kernel_path}/${local_kernel_path} echo -e "${STEPS} Set cross compilation parameters." # Set cross compilation parameters path_ubuntu2004="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin" - path_clang="${toolchain_dir}/${clang_file//.tar.xz/}/bin:${path_ubuntu2004}" + path_clang="${toolchain_path}/${clang_file//.tar.xz/}/bin:${path_ubuntu2004}" export ARCH="arm64" export LOCALVERSION="${custom_name}" export PATH=${path_clang} - export CROSS_COMPILE=${toolchain_dir}/${gcc_file//.tar.xz/}/bin/aarch64-none-linux-gnu- - export CLANG_TRIPLE=${toolchain_dir}/${clang_file//.tar.xz/}/bin - export CC=${toolchain_dir}/${clang_file//.tar.xz/}/bin/clang - export LD=${toolchain_dir}/${clang_file//.tar.xz/}/bin/ld.lld + export CROSS_COMPILE=${toolchain_path}/${gcc_file//.tar.xz/}/bin/aarch64-none-linux-gnu- + export CLANG_TRIPLE=${toolchain_path}/${clang_file//.tar.xz/}/bin + export CC=${toolchain_path}/${clang_file//.tar.xz/}/bin/clang + export LD=${toolchain_path}/${clang_file//.tar.xz/}/bin/ld.lld # Set $PATH variable for ~/.bashrc sed -i '/^PATH=/d' ~/.bashrc 2>/dev/null && sync echo "PATH=${path_clang}" >>~/.bashrc && sync @@ -290,12 +289,12 @@ make_kernel() { # Check .config file if [ ! -f ".config" ]; then # Copy config file - echo -e "${INFO} Copy config file to ${local_kernel_dirname}" - config_demo=$(ls ${config_dir}/config-${kernel_verpatch}* 2>/dev/null | sort -rV | head -n 1) + echo -e "${INFO} Copy config file to ${local_kernel_path}" + config_demo=$(ls ${config_path}/config-${kernel_verpatch}* 2>/dev/null | sort -rV | head -n 1) config_demo_file=${config_demo##*/} [ -z "${config_demo_file}" ] && error_msg "Missing [ config-${kernel_verpatch}* ] template!" - echo -e "${INFO} CONFIG_DEMO: [ ${config_dir}/${config_demo_file} ]" - cp -f ${config_dir}/${config_demo_file} .config && sync + echo -e "${INFO} CONFIG_DEMO: [ ${config_path}/${config_demo_file} ]" + cp -f ${config_path}/${config_demo_file} .config && sync else echo -e "${INFO} Use the .config file in the current directory." fi @@ -311,7 +310,7 @@ make_kernel() { fi # Make kernel - echo -e "${STEPS} Start compilation kernel [ ${local_kernel_dirname} ]..." + echo -e "${STEPS} Start compilation kernel [ ${local_kernel_path} ]..." PROCESS="$(cat /proc/cpuinfo | grep "processor" | wc -l)" [ -z ${PROCESS} ] && PROCESS="1" && echo "PROCESS: 1" make ${MAKE_SET_STRING} Image modules dtbs -j${PROCESS} @@ -334,7 +333,7 @@ generate_uinitrd() { cp -f ${armbian_file} ${chroot_file} && sync # Mount the armbian system - tag_rootfs=${chroot_dir}/root + tag_rootfs=${chroot_path}/root loop_armbian=$(losetup -P -f --show "${chroot_file}") [ ${loop_armbian} ] || error_msg "losetup ${chroot_file} failed." @@ -349,9 +348,9 @@ generate_uinitrd() { # Copy /boot related files into armbian system rm -f ${tag_rootfs}/boot/{config-*,initrd.img-*,System.map-*,uInitrd-*,vmlinuz-*,uInitrd,zImage} 2>/dev/null && sync # - cp -f ${kernel_path}/${local_kernel_dirname}/System.map ${tag_rootfs}/boot/System.map-${kernel_outname} - cp -f ${kernel_path}/${local_kernel_dirname}/.config ${tag_rootfs}/boot/config-${kernel_outname} - cp -f ${kernel_path}/${local_kernel_dirname}/arch/arm64/boot/Image ${tag_rootfs}/boot/vmlinuz-${kernel_outname} + cp -f ${kernel_path}/${local_kernel_path}/System.map ${tag_rootfs}/boot/System.map-${kernel_outname} + cp -f ${kernel_path}/${local_kernel_path}/.config ${tag_rootfs}/boot/config-${kernel_outname} + cp -f ${kernel_path}/${local_kernel_path}/arch/arm64/boot/Image ${tag_rootfs}/boot/vmlinuz-${kernel_outname} sync #echo -e "${INFO} Kernel copy results in the [ ${tag_rootfs}/boot ] directory: \n$(ls -l ${tag_rootfs}/boot) \n" @@ -359,7 +358,7 @@ generate_uinitrd() { cp -rf /lib/modules/${kernel_outname} ${tag_rootfs}/lib/modules && sync #echo -e "${INFO} Kernel copy results in the [ ${tag_rootfs}/lib/modules ] directory: \n$(ls -l ${tag_rootfs}/lib/modules) \n" - cp -f ${script_dir}/generate_uinitrd.sh ${tag_rootfs}/root 2>/dev/null && sync + cp -f ${script_path}/generate_uinitrd.sh ${tag_rootfs}/root 2>/dev/null && sync chmod +x ${tag_rootfs}/root/generate_uinitrd.sh 2>/dev/null #echo -e "${INFO} Kernel copy results in the [ ${tag_rootfs}/root ] directory: \n$(ls -l ${tag_rootfs}/root) \n" @@ -392,7 +391,7 @@ EOF packit_kernel() { # Pack the kernel 6 files - echo -e "${STEPS} Packing the 6 [ ${kernel_outname} ] packages generated by the compilation of the [ ${local_kernel_dirname} ] kernel..." + echo -e "${STEPS} Packing the 6 [ ${kernel_outname} ] packages generated by the compilation of the [ ${local_kernel_path} ] kernel..." cd ${out_kernel}/boot chmod +x * @@ -401,20 +400,20 @@ packit_kernel() { echo -e "${SUCCESS} The [ boot-${kernel_outname}.tar.gz ] file is packaged." cd ${out_kernel}/dtb/allwinner - cp -f ${kernel_path}/${local_kernel_dirname}/arch/arm64/boot/dts/allwinner/*.dtb . && chmod +x * && sync + cp -f ${kernel_path}/${local_kernel_path}/arch/arm64/boot/dts/allwinner/*.dtb . && chmod +x * && sync tar -czf dtb-allwinner-${kernel_outname}.tar.gz * && sync cp -f *.tar.gz ${out_kernel}/${kernel_version} && sync echo -e "${SUCCESS} The [ dtb-allwinner-${kernel_outname}.tar.gz ] file is packaged." cd ${out_kernel}/dtb/amlogic [ -d ${moredtb_path} ] && cp -f ${moredtb_path}/*.dtb . && chmod +x * && sync - cp -f ${kernel_path}/${local_kernel_dirname}/arch/arm64/boot/dts/amlogic/*.dtb . && chmod +x * && sync + cp -f ${kernel_path}/${local_kernel_path}/arch/arm64/boot/dts/amlogic/*.dtb . && chmod +x * && sync tar -czf dtb-amlogic-${kernel_outname}.tar.gz * && sync cp -f *.tar.gz ${out_kernel}/${kernel_version} && sync echo -e "${SUCCESS} The [ dtb-amlogic-${kernel_outname}.tar.gz ] file is packaged." cd ${out_kernel}/dtb/rockchip - cp -f ${kernel_path}/${local_kernel_dirname}/arch/arm64/boot/dts/rockchip/*.dtb . && chmod +x * && sync + cp -f ${kernel_path}/${local_kernel_path}/arch/arm64/boot/dts/rockchip/*.dtb . && chmod +x * && sync tar -czf dtb-rockchip-${kernel_outname}.tar.gz * && sync cp -f *.tar.gz ${out_kernel}/${kernel_version} && sync echo -e "${SUCCESS} The [ dtb-rockchip-${kernel_outname}.tar.gz ] file is packaged." @@ -456,6 +455,7 @@ while [ "${1}" ]; do : ${auto_kernel:="${auto_kernel}"} : ${custom_name:="${custom_name}"} : ${repo_owner:="${repo_owner}"} + : ${config_path:="${config_path}"} ;; -k | --kernel) if [ -n "${2}" ]; then @@ -492,6 +492,14 @@ while [ "${1}" ]; do error_msg "Invalid -r parameter [ ${2} ]!" fi ;; + -c | --config) + if [ -n "${2}" ]; then + config_path="${2}" + shift + else + error_msg "Invalid -c parameter [ ${2} ]!" + fi + ;; *) error_msg "Invalid option [ ${1} ]!" ;; @@ -531,13 +539,13 @@ for x in ${build_kernel[*]}; do if [ "${code_owner}" == "kernel.org" ]; then server_kernel_repo="${kernel_org_repo}" - local_kernel_dirname="linux-${kernel_version}" + local_kernel_path="linux-${kernel_version}" elif [ -z "${code_repo}" ]; then server_kernel_repo="${code_owner}/linux-${kernel_verpatch}.y" - local_kernel_dirname="linux-${kernel_verpatch}.y" + local_kernel_path="linux-${kernel_verpatch}.y" else server_kernel_repo="${code_owner}/${code_repo}" - local_kernel_dirname="${code_repo}-${code_branch}" + local_kernel_path="${code_repo}-${code_branch}" fi download_kernel