Skip to content

Commit

Permalink
Update kernel compilation instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
ophub committed Jan 28, 2022
1 parent d99e130 commit d41d334
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 21 deletions.
26 changes: 19 additions & 7 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,32 +127,44 @@ runs:
cd ${GITHUB_ACTION_PATH}
echo -e "Start compile kernel..."
config_filepath="compile-kernel/tools/config"
kernel_outpath="compile-kernel/output"
if [[ -n "${{ inputs.kernel_config }}" && "${{ inputs.kernel_config }}" != "${config_filepath}" ]]; then
if [[ -d "${GITHUB_WORKSPACE}/${{ inputs.kernel_config }}" ]]; then
echo -e "Use a custom kernel compilation template."
rm -f ${config_filepath}/* 2>/dev/null && sync
sudo cp -vf ${GITHUB_WORKSPACE}/${{ inputs.kernel_config }}/* ${config_filepath}/ 2>/dev/null && sync
else
echo -e "The custom kernel compilation template path is invalid, continue to use the default template"
fi
else
echo -e "Use the default kernel compilation template."
fi
make_command=" -d"
[ -n ${{ inputs.kernel_repo }} ] && make_command="${make_command} -r ${{ inputs.kernel_repo }}"
[ -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}
kernel_filepath="compile-kernel/output"
echo -e "The kernel files in the [ ${kernel_filepath} ] directory. \n"
echo -e "The kernel files in the [ ${kernel_outpath} ] directory. \n"
cd ${GITHUB_ACTION_PATH}
output_tags="$(ls ${PWD}/${kernel_filepath}/*.tar.gz -l | awk '{print $9}' | grep -oE '[1-9].[0-9]{1,3}.[0-9]+' | xargs | tr "[ ]" "_")"
output_tags="$(ls ${PWD}/${kernel_outpath}/*.tar.gz -l | awk '{print $9}' | grep -oE '[1-9].[0-9]{1,3}.[0-9]+' | xargs | tr "[ ]" "_")"
echo -e "Output environment variables."
echo "PACKAGED_OUTPUTTAGS=${output_tags}" >> $GITHUB_ENV
echo "PACKAGED_OUTPUTPATH=${PWD}/${kernel_filepath}" >> $GITHUB_ENV
echo "PACKAGED_OUTPUTPATH=${PWD}/${kernel_outpath}" >> $GITHUB_ENV
echo "PACKAGED_OUTPUTDATE=$(date +"%Y.%m.%d.%H%M")" >> $GITHUB_ENV
echo "PACKAGED_STATUS=success" >> $GITHUB_ENV
echo -e "PACKAGED_OUTPUTTAGS: ${output_tags}"
echo -e "PACKAGED_OUTPUTPATH: ${PWD}/${kernel_filepath}"
echo -e "PACKAGED_OUTPUTPATH: ${PWD}/${kernel_outpath}"
echo -e "PACKAGED_OUTPUTDATE: $(date +"%Y.%m.%d.%H%M")"
echo -e "PACKAGED_STATUS: success"
echo -e "PACKAGED_OUTPUTPATH files list:"
echo -e "$(ls ${PWD}/${kernel_filepath} 2>/dev/null) \n"
echo -e "$(ls ${PWD}/${kernel_outpath} 2>/dev/null) \n"
else
echo -e "Please select a build target: armbian / kernel"
Expand Down
3 changes: 1 addition & 2 deletions compile-kernel/README.cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
| -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` 等。当使用 `github.com` 的内核源代码仓库时,可设置参数格式为 `owner/repo@branch` 三项组合,参数中的所有者名称 `owner` 为必选参数,内核源代码仓库名称 `/repo` 和 仓库的分支名称 `@branch` 为可选参数。当仅指定所有者名称 `owner` 参数时,将自动匹配所有者的名称为 `linux-5.x.y` 格式且分支为 `main` 的内核源代码仓库。如果仓库名称或分支名称不同,请使用组合方式指定,如 `owner@branch``owner/repo``owner/repo@branch` |

Expand Down Expand Up @@ -68,7 +67,7 @@ sudo apt-get install -y $(curl -fsSL git.io/ubuntu-2004-server)
| 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` |
| kernel_config | 无 | 默认值使用 [compile-kernel/tools/config](tools/config) 目录下的配置模板。你可以设置编译内核的配置文件在你仓库中的存放目录,如 `kernel/config_path` 。在此目录下存放的各系列的内核配置模板都必须以 `config-5.x` 的名称为开头,例如编译 `5.4` 系列内核的模板可命名为以 `config-5.4` 开头的各种名字,如 `config-5.4` 、 `config-5.4.174` 或者 `config-5.4.174-xiaoming` 等,有多个以 `config-5.4` 为开头的文件时,将使用版本号最大的文件。 |

- GitHub Action 输出变量说明

Expand Down
3 changes: 1 addition & 2 deletions compile-kernel/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ 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`, 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` |

Expand Down Expand Up @@ -68,7 +67,7 @@ You can call the kernel compilation script of this repository through Actions in
| 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` |
| kernel_config | null | The default uses the configuration templates in the [compile-kernel/tools/config](tools/config) directory. You can set the directory where the compiled kernel configuration files are stored in your repository, such as `kernel/config_path` . 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

Expand Down
10 changes: 0 additions & 10 deletions recompile
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,6 @@ 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
Expand Down Expand Up @@ -492,14 +491,6 @@ while [ "${1}" ]; do
error_msg "Invalid -r parameter [ ${2} ]!"
fi
;;
-c | --config)
if [ -n "${2}" ]; then
config_path="${make_path}/${2}"
shift
else
error_msg "Invalid -c parameter [ ${2} ]!"
fi
;;
*)
error_msg "Invalid option [ ${1} ]!"
;;
Expand All @@ -526,7 +517,6 @@ echo -e "Welcome to compile kernel! \n"
echo -e "Server space usage before starting to compile: \n$(df -hT ${PWD}) \n"
echo -e "Kernel from: [ ${code_owner} ]"
echo -e "Kernel List: [ $(echo ${build_kernel[*]} | tr "\n" " ") ]"
echo -e "Kernel .config files path: [ ${config_path} ]"
echo -e "Ready, start compile kernel... \n"

k=1
Expand Down

0 comments on commit d41d334

Please sign in to comment.