Skip to content

Commit

Permalink
Support Actions to introduce rebuild
Browse files Browse the repository at this point in the history
  • Loading branch information
ophub committed Dec 4, 2021
1 parent de4df52 commit 0ebe3f2
Show file tree
Hide file tree
Showing 7 changed files with 211 additions and 48 deletions.
52 changes: 43 additions & 9 deletions README.cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,22 @@ armbian-tf

💡提示:当前 ***`s905x`******`s905w`*** 系列的盒子只支持使用 `5.4.*` 内核,不能使用 5.10.* 或更高版本,请在编译时指定替换内核。其他型号的盒子可任选内核版本使用。

- ### 本地化打包

1. 安装必要的软件包(如 Ubuntu 20.04 LTS 用户)

```yaml
sudo apt-get update -y
sudo apt-get full-upgrade -y
sudo apt-get install -y $(curl -fsSL git.io/ubuntu-2004-server)
```

2. 克隆仓库到本地 `git clone --depth 1 https://github.com/ophub/amlogic-s9xxx-armbian.git`

3. 在根目录下创建文件夹 `build/output/images` ,并上传 Armbian 镜像文件 ( 如:`Armbian_21.11.0-trunk_Lepotato_buster_current_5.10.80.img` ) 到 `~/amlogic-s9xxx-armbian/build/output/images` 目录里。原版 Armbian 镜像文件名称中的发行版本号(如:`21.11.0`)和内核版本号(如:`5.10.80`)请保留,它将在重构后用作 Armbian 固件的名称。

4. 进入 `~/amlogic-s9xxx-armbian` 根目录,然后运行 `sudo ./rebuild -d -b s905x3 -k 5.4.160` 命令即可生成指定 soc 的 Armbian 镜像文件。生成的文件保存在 `build/output/images` 目录里。

- ### 使用 GitHub Action 进行编译

1. 关于 Workflows 文件的配置在 [.yml](.github/workflows) 文件里。可以设置需要编译的盒子的 `SOC` 等参数,具体详见 `Rebuild Armbian for amlogic s9xxx` 节点。
Expand All @@ -151,23 +167,41 @@ armbian-tf

3. 再次编译:如果 [Releases](https://github.com/ophub/amlogic-s9xxx-armbian/releases) 中有已经编译好的 `Armbian_.*-trunk_.*.img.gz` 文件,你只是想再次制作其他不同 soc 的盒子,可以跳过 Armbian 源文件的编译,直接进行二次制作。在 [Action](https://github.com/ophub/amlogic-s9xxx-armbian/actions) 页面中选择 ***`Use Releases file to build armbian`*** ,点击 ***`Run workflow`*** 按钮即可二次编译。

- ### 本地化打包
- ### 仅单独引入 GitHub Action 进行 Armbian 重构

1. 安装必要的软件包(如 Ubuntu 20.04 LTS 用户)
你可以使用其他方式构建 Armbian 固件。或者使用 [Armbian](https://armbian.tnahosting.net/dl/) 官方提供的 [lepotato](https://armbian.tnahosting.net/dl/lepotato/archive/) 等分支的固件,仅在流程控制文件 .github/workflows/.yml 中引入本仓库的脚本进行 Armbian 重构,适配 Amlogic S9xxx 系列盒子的使用,代码如下:

```yaml
sudo apt-get update -y
sudo apt-get full-upgrade -y
sudo apt-get install -y $(curl -fsSL git.io/ubuntu-2004-server)
- name: Rebuild Armbian for Amlogic s9xxx
uses: ophub/amlogic-s9xxx-armbian@main
with:
armbian_path: build/output/images/*.img
armbian_soc: s905d_s905x3_s922x_s905x
armbian_kernel: 5.10.80_5.4.160
```
2. 克隆仓库到本地 `git clone --depth 1 https://github.com/ophub/amlogic-s9xxx-armbian.git`
3. 在根目录下创建文件夹 `build/output/images` ,并上传采用 `lepotato` 分支生成的 Armbian 镜像文件 ( 如:`Armbian_21.11.0-trunk_Lepotato_buster_current_5.10.80.img` ) 到 `~/amlogic-s9xxx-armbian/build/output/images` 目录里。
4. 进入 `~/amlogic-s9xxx-armbian` 根目录,然后运行 `sudo ./rebuild s905x3` 命令即可生成指定 soc 的 Armbian 镜像文件。生成的文件保存在 `build/output/images` 目录里。
- GitHub Action 输入参数说明
| 参数 | 默认值 | 说明 |
|------------------------|------------------------|------------------------------------------------|
| armbian_path | no | 设置原版 Armbian 文件的路径,支持使用当前工作流中的文件路径如 `build/output/images/*.img` ,也支持使用网络下载地址如: `https://dl.armbian.com/*/Armbian_*_buster_*.img.xz` |
| armbian_soc | s905d_s905x3 | 设置打包盒子的 `SOC` ,可指定单个盒子如 `s905x3` ,可选择多个盒子用_连接如 `s905x3_s905d` 。各盒子的SoC代码为:`s905x3`, `s905x2`, `s905x`, `s905w`, `s905d`, `s922x`, `s922x-n2`, `s912`。说明:`s922x-n2` 是 `s922x-odroid-n2` |
| version_branch | stable | 指定内核 [版本分支](https://github.com/ophub/kernel/tree/main/pub) 名称,如 `stable` 。指定的名称须与分支目录名称相同。默认使用 `stable` 分支版本。 |
| armbian_kernel | 5.10.80_5.4.160 | 设置内核版本,[kernel](https://github.com/ophub/kernel/tree/main/pub/stable) 库里收藏了众多 Flippy 的原版内核,可以查看并选择指定。 |
| auto_kernel | true | 设置是否自动采用同系列最新版本内核。当为 `true` 时,将自动在内核库中查找在 `amlogic_kernel` 中指定的内核如 5.4.160 的 5.4 同系列是否有更新的版本,如有 5.4.160 之后的最新版本时,将自动更换为最新版。设置为 `false` 时将编译指定版本内核。默认值:`true` |
| armbian_size | 2748 | 设置固件 ROOTFS 分区的大小。 |

- GitHub Action 输出变量说明

| 参数 | 默认值 | 说明 |
|------------------------------------------|-------------------------|---------------------------|
| ${{ env.PACKAGED_OUTPUTPATH }} | ${PWD}/out | 打包后的固件所在文件夹的路径 |
| ${{ env.PACKAGED_OUTPUTDATE }} | 2021.04.21.1058 | 打包日期 |
| ${{ env.PACKAGED_STATUS }} | success / failure | 打包状态。成功 / 失败 |

## 编译自定义内核

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

## Armbian 贡献者名单

Expand Down
54 changes: 45 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,25 +143,61 @@ Command: Enter [ vi /etc/fstab ]

💡Tips: The ***`s905x`*** and ***`s905w`*** boxs currently only support `5.4.*` kernels, Cannot use kernel version 5.10 and above. Please add kernel substitution variables when compiling these two models of devices. Other devices can be freely selected.

- ### Use GitHub Action to build instructions
- ### Local build instructions

1. Install the necessary packages (E.g Ubuntu 20.04 LTS user)

```yaml
sudo apt-get update -y
sudo apt-get full-upgrade -y
sudo apt-get install -y $(curl -fsSL git.io/ubuntu-2004-server)
```

2. Clone the repository to the local. `git clone --depth 1 https://github.com/ophub/amlogic-s9xxx-armbian.git`

3. Create the `build/output/images` folder, and upload the Armbian image ( Eg: `Armbian_21.11.0-trunk_Lepotato_buster_current_5.10.80.img` ) to this `~/amlogic-s9xxx-armbian/build/output/images` directory. Please keep the release version number (e.g. `21.11.0`) and kernel version number (e.g. `5.10.80`) in the name of the original Armbian image file, It will be used as the name of the armbian firmware after rebuilding.

4. Enter the `~/amlogic-s9xxx-armbian` root directory. And run Eg: `sudo ./rebuild -d -b s905x3 -k 5.4.160` to build armbian for `amlogic s9xxx`. The generated Armbian image is in the `build/output/images` directory under the root directory.

- ### Use GitHub Action to build

1. Workflows configuration in [.yml](.github/workflows) files. Set the armbian `SOC` you want to build in `Rebuild Armbian for amlogic s9xxx`.

2. New compilation: Select ***`Build the armbian firmware`*** on the [Action](https://github.com/ophub/amlogic-s9xxx-armbian/actions) page. Click the ***`Run workflow`*** button.

3. Compile again: If there is an `Armbian_.*-trunk_.*.img.gz` file in [Releases](https://github.com/ophub/amlogic-s9xxx-armbian/releases), you do not need to compile it completely, you can directly use this file to `build armbian` of different soc. Select ***`Use Releases file to build armbian`*** on the [Action](https://github.com/ophub/amlogic-s9xxx-armbian/actions) page. Click the ***`Run workflow`*** button.

- ### Local build instructions
- ### Only import GitHub Action for Armbian rebuild

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 .github/workflows/.yml to rebuild Armbian to adapt to the use of Amlogic S9xxx series boxes, code show as below:

1. Install the necessary packages (E.g Ubuntu 20.04 LTS user)
```yaml
sudo apt-get update -y
sudo apt-get full-upgrade -y
sudo apt-get install -y $(curl -fsSL git.io/ubuntu-2004-server)
- name: Rebuild Armbian for Amlogic s9xxx
uses: ophub/amlogic-s9xxx-armbian@main
with:
armbian_path: build/output/images/*.img
armbian_soc: s905d_s905x3_s922x_s905x
armbian_kernel: 5.10.80_5.4.160
```
2. Clone the repository to the local. `git clone --depth 1 https://github.com/ophub/amlogic-s9xxx-armbian.git`
3. Create the `build/output/images` folder, and upload the Armbian image of the `lepotato` board ( Eg: `Armbian_21.11.0-trunk_Lepotato_buster_current_5.10.80.img` ) to this `~/amlogic-s9xxx-armbian/build/output/images` directory.
4. Enter the `~/amlogic-s9xxx-armbian` root directory. And run Eg: `sudo ./rebuild s905x3` to build armbian for `amlogic s9xxx`. The generated Armbian image is in the `build/output/images` directory under the root directory.
- GitHub Action Input parameter description
| parameter | Defaults | Description |
|------------------------|------------------------|---------------------------------------------------------------|
| armbian_path | no | Set the path of the original Armbian file, support the file path in the current workflow such as `build/output/images/*.img`, and also support the use of the network download address such as: `https://dl.armbian.com/*/Armbian_*_buster_*.img.xz` |
| armbian_soc | s905d_s905x3 | Set the `SoC` of the packaging box, you can specify a single box such as `s905x3`, you can choose multiple boxes to use `_` connection such as `s905x3_s905d` . SOC code of each box is: `s905x3`, `s905x2`, `s905x`, `s905w`, `s905d`, `s922x`, `s922x-n2`, `s912`. Note: `s922x-n2` is `s922x-odroid-n2` |
| version_branch | stable | Specify the name of the kernel [version branch](https://github.com/ophub/kernel/tree/main/pub), Such as `stable`. The specified name must be the same as the branch directory name. The `stable` branch version is used by default. |
| armbian_kernel | 5.10.80_5.4.160 | Set the kernel version,The [kernel](https://github.com/ophub/kernel/tree/main/pub/stable) library contains many original kernels of `Flippy`, you can view and choose to specify. |
| auto_kernel | true | Set whether to automatically adopt the latest version of the kernel of the same series. When it is `true`, it will automatically find in the kernel library whether there is an updated version of the kernel specified in `amlogic_kernel`. such as 5.4.160 version. If there is the latest version of 5.4 same series, it will automatically Replace with the latest version. When set to `false`, the specified version of the kernel will be compiled. Default value: `true` |
| armbian_size | 2748 | Set the size of the firmware ROOTFS partition. |

- GitHub Action Output variable description

| parameter | For example | Description |
|------------------------------------------|-------------------------|-------------------------------|
| ${{ env.PACKAGED_OUTPUTPATH }} | ${PWD}/out | OpenWrt firmware storage path |
| ${{ env.PACKAGED_OUTPUTDATE }} | 2021.04.21.1058 | Packing date |
| ${{ env.PACKAGED_STATUS }} | success / failure | Package status |

## Compile a custom kernel

Expand Down
92 changes: 92 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
name: "Rebuild armbian for Amlogic S9xxx STB"
author: "ophub"
description: "Support Amlogic S9xxx STB are s922x, s905x3, s905x2, s912, s905d, s905x, s905w, etc."
inputs:
mode:
description: "Choose script."
required: false
default: "ophub"
armbian_soc:
description: "Set Amlogic SoC."
required: false
default: "s905d_s905x3"
armbian_kernel:
description: "Set kernel."
required: false
default: "5.10.80_5.4.160"
version_branch:
description: "Set kernel."
required: false
default: "stable"
auto_kernel:
description: "Auto use the latest kernel."
required: false
default: "true"
armbian_size:
description: "Set armbian rootfs size."
required: false
default: "2748"
armbian_path:
description: "Set armbian original file path."
required: false
default: "build/output/images/*.img"

runs:
using: "composite"
steps:
- shell: bash
run: |
cd ${GITHUB_ACTION_PATH}
echo -e "Armbian rebuild actions path: ${PWD}"
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 ${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 "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}
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"
branding:
icon: "terminal"
color: "gray-dark"
Loading

0 comments on commit 0ebe3f2

Please sign in to comment.