Skip to content

Commit

Permalink
Add use actions compile kernel templates
Browse files Browse the repository at this point in the history
  • Loading branch information
ophub committed Jan 27, 2022
1 parent fd55012 commit 8361a1a
Show file tree
Hide file tree
Showing 6 changed files with 213 additions and 64 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/compile-kernel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ on:
description: "Source: kernel.org / unifreq"
required: false
default: "unifreq"
kernel_ver:
kernel_version:
description: "Kernel version: 5.4.170"
required: false
default: "5.4.170_5.10.90"
default: "5.10.90_5.4.170"

env:
TZ: Asia/Shanghai
Expand Down Expand Up @@ -46,15 +46,15 @@ jobs:
[ -z "${kernel_repo}"] && kernel_repo="kernel.org"
echo "KERNEL_REPO=${kernel_repo}" >> $GITHUB_ENV
kernel_ver="${{ github.event.inputs.kernel_ver }}"
[ -z "${kernel_ver}" ] && kernel_ver="5.4.170_5.10.90"
echo "KERNEL_VER=${kernel_ver}" >> $GITHUB_ENV
kernel_version="${{ github.event.inputs.kernel_version }}"
[ -z "${kernel_version}" ] && kernel_version="5.4.170_5.10.90"
echo "KERNEL_VERSION=${kernel_version}" >> $GITHUB_ENV
- name: Compile the Kernel [ -k ${{ env.KERNEL_VER }} -r ${{ env.KERNEL_REPO }} ]
- name: Compile the kernel for Amlogic s9xxx
id: compile
run: |
sudo chmod +x recompile
sudo ./recompile -d -k ${{ env.KERNEL_VER }} -r ${{ env.KERNEL_REPO }}
sudo ./recompile -d -k ${{ env.KERNEL_VERSION }} -r ${{ env.KERNEL_REPO }}
output_dirname="${PWD}/compile-kernel/output"
output_tags="$(ls ${output_dirname}/*.tar.gz -l | awk '{print $9}' | grep -oE '[1-9].[0-9]{1,3}.[0-9]+' | xargs | tr "[ ]" "_")"
echo "PACKAGED_OUTPUTTAGS=${output_tags}" >> $GITHUB_ENV
Expand Down
13 changes: 12 additions & 1 deletion README.cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,10 @@ sudo apt-get install -y $(curl -fsSL git.io/ubuntu-2004-server)
你可以使用其他方式构建 Armbian 固件。或者使用 [Armbian](https://armbian.tnahosting.net/dl/) 官方提供的 [lepotato](https://armbian.tnahosting.net/dl/lepotato/archive/) 等分支的固件,仅在流程控制文件 [.yml](.github/workflows/rebuild-armbian.yml) 中引入本仓库的脚本进行 Armbian 重构,适配 Amlogic S9xxx 系列盒子的使用。在 [Action](https://github.com/ophub/amlogic-s9xxx-armbian/actions) 页面里选择 ***`Rebuild armbian`*** ,输入 Armbian 的网络下载地址如 `https://dl.armbian.com/*/Armbian_*.img.xz` ,或者在流程控制文件 [.yml](.github/workflows/rebuild-armbian.yml) 中通过 `armbian_path` 参数设定重构文件的加载路径。代码如下:

```yaml
- name: Rebuild Armbian for Amlogic s9xxx
- name: Rebuild the Armbian for Amlogic s9xxx
uses: ophub/amlogic-s9xxx-armbian@main
with:
build_target: armbian
armbian_path: build/output/images/*.img
armbian_soc: s905d_s905x3_s922x_s905x
armbian_kernel: 5.15.13_5.4.170
Expand Down Expand Up @@ -222,6 +223,16 @@ sudo apt-get install -y $(curl -fsSL git.io/ubuntu-2004-server)

自定义内核的编译方法详见 [compile-kernel](compile-kernel/README.cn.md)

```yaml
- name: Compile the kernel for Amlogic s9xxx
uses: ophub/amlogic-s9xxx-armbian@main
with:
build_target: kernel
kernel_version: 5.15.13_5.4.170
kernel_auto: true
kernel_sign: -meson64-dev
```

## Armbian 贡献者名单

首先感谢 [150balbes](https://github.com/150balbes) 为在 Amlogic 盒子中使用 Armbian 所做出的杰出贡献和奠定的良好基础。这里编译的 [armbian](https://github.com/armbian/build) 系统直接使用了官方当前的最新源码进行实时编译。为不同的盒子制作专用的 Armbian 系统时采用了 [unifreq](https://github.com/unifreq/openwrt_packit) 为 `amlogic s9xxx openwrt` 制作的内核、脚本及 `u-boot` 等资源。程序的开发思路来自 [ebkso](https://www.kflyo.com/howto-compile-armbian-for-n1-box) 等作者的教程。感谢各位的奉献和分享,让我们可以在 Amlogic s9xxx 盒子里使用 Armbian 系统。
Expand Down
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,10 @@ sudo apt-get install -y $(curl -fsSL git.io/ubuntu-2004-server)
You can use other methods to build the Armbian system. Or use [Armbian](https://armbian.tnahosting.net/dl/) officially provided [lepotato](https://armbian.tnahosting.net/dl/lepotato/archive/) and other branch firmware. and only import the Action from this repository in the process control file [.yml](.github/workflows/rebuild-armbian.yml) to rebuild Armbian to adapt to the use of Amlogic S9xxx series boxes. In the [Action](https://github.com/ophub/amlogic-s9xxx-armbian/actions) page, select ***`Rebuild armbian`***, and enter the Armbian network download url such as `https://dl.armbian.com/*/Armbian_*.img.xz`, or in the process control file [.yml](.github/workflows/rebuild-armbian.yml), set the load path of the rebuild file through the `armbian_path` parameter. code show as below:

```yaml
- name: Rebuild Armbian for Amlogic s9xxx
- name: Rebuild the Armbian for Amlogic s9xxx
uses: ophub/amlogic-s9xxx-armbian@main
with:
build_target: armbian
armbian_path: build/output/images/*.img
armbian_soc: s905d_s905x3_s922x_s905x
armbian_kernel: 5.15.13_5.4.170
Expand Down Expand Up @@ -222,6 +223,16 @@ You can use other methods to build the Armbian system. Or use [Armbian](https://

For the compilation method of the custom kernel, see [compile-kernel](compile-kernel)

```yaml
- name: Compile the kernel for Amlogic s9xxx
uses: ophub/amlogic-s9xxx-armbian@main
with:
build_target: kernel
kernel_version: 5.15.13_5.4.170
kernel_auto: true
kernel_sign: -meson64-dev
```

## Armbian contributor list

First of all, I would like to thank [150balbes](https://github.com/150balbes) for his outstanding contributions and a good foundation for using Armbian in the Amlogic box. The [armbian](https://github.com/armbian/build) system compiled here directly uses the latest official source code for real-time compilation, When making dedicated Armbian systems for different boxes, the kernel, scripts, u-boot and other resources made by [unifreq](https://github.com/unifreq/openwrt_packit) for `Amlogic s9xxx openwrt` are used. The development idea of the program comes from the tutorials of authors such as [ebkso](https://www.kflyo.com/howto-compile-armbian-for-n1-box). Thank you for your dedication and sharing, so that we can use the Armbian system in the Amlogic s9xxx box.
Expand Down
166 changes: 113 additions & 53 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
name: "Rebuild armbian for Amlogic s9xxx tv box"
author: "ophub"
name: "Rebuild armbian and kernel for Amlogic s9xxx tv box"
author: "https://github.com/ophub"
description: "Support Amlogic s9xxx tv box are s922x, s905x3, s905x2, s912, s905d, s905x, s905w, s905, etc."
inputs:
mode:
description: "Choose script."
# Choose build target
build_target:
description: "Choose build target: armbian / kernel"
required: false
default: "ophub"
default: "armbian"
# For build armbian -----
armbian_soc:
description: "Set Amlogic SoC."
required: false
Expand All @@ -30,66 +32,124 @@ inputs:
description: "Set armbian original file path."
required: false
default: "build/output/images/*.img"
# For compile kernel -----
kernel_repo:
description: "select kernel repository"
required: false
default: "unifreq"
kernel_version:
description: "select kernel version"
required: false
default: "5.10.90_5.4.170"
kernel_auto:
description: "Auto use the latest kernel"
required: false
default: "true"
kernel_sign:
description: "Set the kernel custom signature"
required: false
default: "-meson64-dev"

runs:
using: "composite"
steps:
- shell: bash
run: |
cd ${GITHUB_ACTION_PATH}
echo -e "Armbian rebuild actions path: ${PWD}"
build_target="${{ inputs.build_target }}"
[ -z "${build_target}" ] && build_target="armbian"
armbian_file="${{ inputs.armbian_path }}"
armbian_filepath="build/output/images"
echo -e "Get armbian file input parameters: [ ${armbian_file} ]"
[ -z "${armbian_file}" ] && echo -e "The [ armbian_path ] variable must be specified." && exit 1
[ -d "${armbian_filepath}" ] || sudo mkdir -p ${armbian_filepath}
if [[ "${armbian_file}" == http* ]]; then
echo -e "Use wget to download file: [ ${armbian_file} ]"
sudo wget ${armbian_file} -q -P ${armbian_filepath} 2>/dev/null
elif [[ "${armbian_file:0:6}" != "build/" && "${armbian_file:0:8}" != "./build/" ]]; then
echo -e "Copy files: [ ${armbian_file} ]"
sudo cp -f ${GITHUB_WORKSPACE}/${armbian_file} ${armbian_filepath} 2>/dev/null
else
echo -e "Use armbian files: [ ${armbian_file} ]"
fi
sync
echo -e "About the ${armbian_filepath} directory: \n $(ls ${armbian_filepath} -l 2>/dev/null)"
if [ "${build_target}" == "armbian" ]; then
cd ${GITHUB_ACTION_PATH}/${armbian_filepath}
echo -e "Check the armbian file format..."
down_file="$(ls . -l 2>/dev/null | grep "^-" | awk '{print $9}' | head -n 1)"
[ -z "${down_file}" ] && echo -e "The [ ${armbian_file} ] is invalid." && exit 1
[ "${down_file:0-7}" == ".img.gz" ] && sudo gzip -df ${down_file} 2>/dev/null && sync
[ "${down_file:0-7}" == ".img.xz" ] && sudo xz -d ${down_file} 2>/dev/null && sync
[ "${down_file:0-4}" == ".zip" ] && sudo unzip -o ${down_file} 2>/dev/null && sync
echo -e "Armbian file: [ $(ls *.img -l 2>/dev/null) ]"
cd ${GITHUB_ACTION_PATH}
echo -e "Rebuild the armbian actions path: ${PWD}"
cd ${GITHUB_ACTION_PATH}
echo -e "Start to rebuild armbian..."
make_command=" -d"
[ -n ${{ inputs.armbian_soc }} ] && make_command="${make_command} -b ${{ inputs.armbian_soc }}"
[ -n ${{ inputs.armbian_kernel }} ] && make_command="${make_command} -k ${{ inputs.armbian_kernel }}"
[ -n ${{ inputs.version_branch }} ] && make_command="${make_command} -v ${{ inputs.version_branch }}"
[ -n ${{ inputs.auto_kernel }} ] && make_command="${make_command} -a ${{ inputs.auto_kernel }}"
[ -n ${{ inputs.armbian_size }} ] && make_command="${make_command} -s ${{ inputs.armbian_size }}"
sudo chmod +x rebuild
sudo ./rebuild ${make_command}
armbian_file="${{ inputs.armbian_path }}"
armbian_filepath="build/output/images"
echo -e "Get armbian file input parameters: [ ${armbian_file} ]"
[ -z "${armbian_file}" ] && echo -e "The [ armbian_path ] variable must be specified." && exit 1
[ -d "${armbian_filepath}" ] || sudo mkdir -p ${armbian_filepath}
if [[ "${armbian_file}" == http* ]]; then
echo -e "Use wget to download file: [ ${armbian_file} ]"
sudo wget ${armbian_file} -q -P ${armbian_filepath} 2>/dev/null
elif [[ "${armbian_file:0:6}" != "build/" && "${armbian_file:0:8}" != "./build/" ]]; then
echo -e "Copy files: [ ${armbian_file} ]"
sudo cp -f ${GITHUB_WORKSPACE}/${armbian_file} ${armbian_filepath} 2>/dev/null
else
echo -e "Use armbian files: [ ${armbian_file} ]"
fi
sync
echo -e "About the ${armbian_filepath} directory: \n $(ls ${armbian_filepath} -l 2>/dev/null)"
cd ${GITHUB_ACTION_PATH}/${armbian_filepath}
echo -e "Compress the .img file in the [ ${armbian_filepath} ] directory. \n"
sudo gzip *.img && sync
cd ${GITHUB_ACTION_PATH}/${armbian_filepath}
echo -e "Check the armbian file format..."
down_file="$(ls . -l 2>/dev/null | grep "^-" | awk '{print $9}' | head -n 1)"
[ -z "${down_file}" ] && echo -e "The [ ${armbian_file} ] is invalid." && exit 1
[ "${down_file:0-7}" == ".img.gz" ] && sudo gzip -df ${down_file} 2>/dev/null && sync
[ "${down_file:0-7}" == ".img.xz" ] && sudo xz -d ${down_file} 2>/dev/null && sync
[ "${down_file:0-4}" == ".zip" ] && sudo unzip -o ${down_file} 2>/dev/null && sync
echo -e "Armbian file: [ $(ls *.img -l 2>/dev/null) ]"
cd ${GITHUB_ACTION_PATH}
echo -e "Output environment variables."
echo "PACKAGED_OUTPUTPATH=${PWD}/${armbian_filepath}" >> $GITHUB_ENV
echo "PACKAGED_OUTPUTDATE=$(date +"%Y.%m.%d.%H%M")" >> $GITHUB_ENV
echo "PACKAGED_STATUS=success" >> $GITHUB_ENV
echo -e "PACKAGED_OUTPUTPATH: ${PWD}/${armbian_filepath}"
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}/${armbian_filepath} 2>/dev/null) \n"
cd ${GITHUB_ACTION_PATH}
echo -e "Start to rebuild armbian..."
make_command=" -d"
[ -n ${{ inputs.armbian_soc }} ] && make_command="${make_command} -b ${{ inputs.armbian_soc }}"
[ -n ${{ inputs.armbian_kernel }} ] && make_command="${make_command} -k ${{ inputs.armbian_kernel }}"
[ -n ${{ inputs.version_branch }} ] && make_command="${make_command} -v ${{ inputs.version_branch }}"
[ -n ${{ inputs.auto_kernel }} ] && make_command="${make_command} -a ${{ inputs.auto_kernel }}"
[ -n ${{ inputs.armbian_size }} ] && make_command="${make_command} -s ${{ inputs.armbian_size }}"
sudo chmod +x rebuild
sudo ./rebuild ${make_command}
cd ${GITHUB_ACTION_PATH}/${armbian_filepath}
echo -e "The armbian files in the [ ${armbian_filepath} ] directory. \n"
sudo gzip *.img && sync
cd ${GITHUB_ACTION_PATH}
echo -e "Output environment variables."
echo "PACKAGED_OUTPUTPATH=${PWD}/${armbian_filepath}" >> $GITHUB_ENV
echo "PACKAGED_OUTPUTDATE=$(date +"%Y.%m.%d.%H%M")" >> $GITHUB_ENV
echo "PACKAGED_STATUS=success" >> $GITHUB_ENV
echo -e "PACKAGED_OUTPUTPATH: ${PWD}/${armbian_filepath}"
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}/${armbian_filepath} 2>/dev/null) \n"
elif [ "${build_target}" == "kernel" ]; then
cd ${GITHUB_ACTION_PATH}
echo -e "Compile the kernel actions path: ${PWD}"
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 }}"
sudo chmod +x recompile
sudo ./recompile ${make_command}
kernel_filepath="compile-kernel/output"
echo -e "The kernel files in the [ ${kernel_filepath} ] 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 "[ ]" "_")"
echo -e "Output environment variables."
echo "PACKAGED_OUTPUTTAGS=${output_tags}" >> $GITHUB_ENV
echo "PACKAGED_OUTPUTPATH=${PWD}/${kernel_filepath}" >> $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_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"
else
echo -e "Please select a build target: armbian / kernel"
exit 1
fi
branding:
icon: "terminal"
Expand Down
35 changes: 34 additions & 1 deletion compile-kernel/README.cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

根据需要,编译自定义内核。此内核可用于 [Armbian](https://github.com/ophub/amlogic-s9xxx-armbian)[OpenWrt](https://github.com/ophub/amlogic-s9xxx-openwrt) 系统,在以 [unifreq](https://github.com/unifreq/openwrt_packit) 标准制作的同类系统中可通用。

## 编译命令说明
## 本地编译命令说明

| 参数 | 含义 | 说明 |
| ---- | ---- | ---- |
Expand Down Expand Up @@ -44,6 +44,39 @@ sudo apt-get install -y $(curl -fsSL git.io/ubuntu-2004-server)

2.[Action](https://github.com/ophub/amlogic-s9xxx-armbian/actions) 页面里选择 ***`Compile the armbian kernel`*** ,点击 ***`Run workflow`*** 按钮即可编译。

- ### 仅单独引入 GitHub Action 编译内核

可以在你的 github.com 仓库中通过 Actions 调用本仓库的内核编译脚本,制作个性化内核。详见使用模板 [compile-kernel.yml](https://github.com/ophub/amlogic-s9xxx-openwrt/blob/main/.github/workflows/compile-kernel.yml) 。代码如下:

```yaml
- name: Compile the kernel for Amlogic s9xxx
uses: ophub/amlogic-s9xxx-armbian@main
with:
build_target: kernel
kernel_version: 5.15.13_5.4.170
kernel_auto: true
kernel_sign: -meson64-dev
```
- GitHub Action 输入参数说明
| 参数 | 默认值 | 说明 |
|------------------------|------------------------|------------------------------------------------|
| 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_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` 。设置自定义签名时请勿包含空格。 |

- GitHub Action 输出变量说明

| 参数 | 默认值 | 说明 |
|-----------------------------------|------------------------------|---------------------------|
| ${{ env.PACKAGED_OUTPUTTAGS }} | 5.15.13_5.4.170 | 编译好的内核的名称 |
| ${{ env.PACKAGED_OUTPUTPATH }} | ${PWD}/compile-kernel/output | 编译完成的内核所在文件夹的路径 |
| ${{ env.PACKAGED_OUTPUTDATE }} | 2021.04.13.1058 | 编译日期 |
| ${{ env.PACKAGED_STATUS }} | success / failure | 编译状态。成功 / 失败 |

## 其他说明

1. 内核编译文件检查的优先级:如果 `compile-kernel/kernel` 目录下有指定内核的文件夹如 `linux-5.4.170` 时,将使用本地源码进行编译;当没有指定内核的文件夹,但有指定内核的压缩文件如 linux-5.4.170.tar.xz 时,将自动解压并进行编译;当本地没有指定内核时,将自动从服务器下载并编译。
Expand Down
Loading

0 comments on commit 8361a1a

Please sign in to comment.