ARMv8 Plus OpenWrt #83
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#=============================================== | |
# Description: Build OpenWrt | |
# File name: build-openwrt.yml | |
# Lisence: MIT | |
# Author: P3TERX | |
# https://github.com/P3TERX | |
#=============================================== | |
name: ARMv8 Plus OpenWrt | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: 0 20 * * * | |
env: | |
SOURCE_URL: https://github.com/coolsnowwolf/lede | |
SOURCE_BRANCH: master | |
CONFIG_FILE: configs/armv8-plus.config | |
DIY_SCRIPT: diy-script.sh | |
TOOLCHAIN_TAG: Toolchain | |
CLASH_KERNEL: arm64 | |
UPLOAD_BIN_DIR: false | |
FIRMWARE_RELEASE: true | |
FIRMWARE_TAG: ROOTFS_PLUS | |
OPENWRT_RELEASE: true | |
OPENWRT_TAG: ARMv8_PLUS | |
TZ: Asia/Shanghai | |
jobs: | |
Toolchain: | |
runs-on: ubuntu-22.04 | |
outputs: | |
OPENWRT_PATH: ${{ steps.clone.outputs.OPENWRT_PATH }} | |
VERSION_INFO: ${{ steps.clone.outputs.VERSION_INFO }} | |
CURRENT_BRANCH: ${{ steps.env.outputs.CURRENT_BRANCH }} | |
SOURCE_REPO: ${{ steps.env.outputs.SOURCE_REPO }} | |
DEVICE_TARGET: ${{ steps.env.outputs.DEVICE_TARGET }} | |
DEVICE_SUBTARGET: ${{ steps.env.outputs.DEVICE_SUBTARGET }} | |
TOOLCHAIN_IMAGE: ${{ steps.env.outputs.TOOLCHAIN_IMAGE }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@main | |
- name: Initialization Environment | |
env: | |
DEBIAN_FRONTEND: noninteractive | |
run: | | |
sudo rm -rf /etc/apt/sources.list.d/* /usr/share/dotnet /etc/mysql /etc/php /usr/local/lib/android | |
sudo -E apt-get -qq update | |
sudo -E apt-get -y install $(curl -fsSL is.gd/depends_ubuntu_2204) | |
sudo -E apt-get -qq autoremove --purge | |
sudo -E apt-get -qq clean | |
sudo timedatectl set-timezone "$TZ" | |
- name: Clone Source Code | |
id: clone | |
run: | | |
df -hT $GITHUB_WORKSPACE | |
git clone $SOURCE_URL -b $SOURCE_BRANCH workspace/openwrt | |
cd workspace/openwrt | |
echo "OPENWRT_PATH=$PWD" >> $GITHUB_ENV | |
echo "OPENWRT_PATH=$(echo $PWD)" >> $GITHUB_OUTPUT | |
export VERSION_INFO=$(git show -s --date=short --format="Author: %an<br/>date: %cd<br/>commit: %s<br/>commit hash: %H") | |
echo "VERSION_INFO=$VERSION_INFO" >> $GITHUB_ENV | |
echo "VERSION_INFO=$(echo $VERSION_INFO)" >> $GITHUB_OUTPUT | |
- name: Generate Toolchain Config | |
run: | | |
[ -e $CONFIG_FILE ] && mv $CONFIG_FILE $OPENWRT_PATH/.config | |
echo "CONFIG_ALL=y" >> $OPENWRT_PATH/.config | |
echo "CONFIG_ALL_NONSHARED=y" >> $OPENWRT_PATH/.config | |
cd $OPENWRT_PATH | |
make defconfig > /dev/null 2>&1 | |
- name: Generate Variables | |
id: env | |
run: | | |
export CURRENT_BRANCH="$(git symbolic-ref --short HEAD)" | |
echo "CURRENT_BRANCH=$CURRENT_BRANCH" >> $GITHUB_ENV | |
echo "CURRENT_BRANCH=$(echo $CURRENT_BRANCH)" >> $GITHUB_OUTPUT | |
cd $OPENWRT_PATH | |
export SOURCE_REPO="$(echo $SOURCE_URL | awk -F '/' '{print $(NF)}')" | |
echo "SOURCE_REPO=$SOURCE_REPO" >> $GITHUB_ENV | |
echo "SOURCE_REPO=$(echo $SOURCE_REPO)" >> $GITHUB_OUTPUT | |
export DEVICE_TARGET=$(cat .config | grep CONFIG_TARGET_BOARD | awk -F '"' '{print $2}') | |
echo "DEVICE_TARGET=$DEVICE_TARGET" >> $GITHUB_ENV | |
echo "DEVICE_TARGET=$(echo $DEVICE_TARGET)" >> $GITHUB_OUTPUT | |
export DEVICE_SUBTARGET=$(cat .config | grep CONFIG_TARGET_SUBTARGET | awk -F '"' '{print $2}') | |
echo "DEVICE_SUBTARGET=$DEVICE_SUBTARGET" >> $GITHUB_ENV | |
echo "DEVICE_SUBTARGET=$(echo $DEVICE_SUBTARGET)" >> $GITHUB_OUTPUT | |
export TOOLCHAIN_IMAGE="toolchain-$SOURCE_REPO-$SOURCE_BRANCH-$DEVICE_TARGET-$DEVICE_SUBTARGET" | |
echo "TOOLCHAIN_IMAGE=$TOOLCHAIN_IMAGE" >> $GITHUB_ENV | |
echo "TOOLCHAIN_IMAGE=$(echo $TOOLCHAIN_IMAGE)" >> $GITHUB_OUTPUT | |
- name: Compare Toolchain Hash | |
id: hash | |
run: | | |
cd $OPENWRT_PATH | |
export CURRENT_HASH=$(git log --pretty=tformat:"%H" -n1 tools toolchain) | |
echo "CURRENT_HASH=$CURRENT_HASH" >> $GITHUB_ENV | |
echo "CURRENT_HASH is $CURRENT_HASH" | |
export CACHE_HASH=$(curl -fSsL https://github.com/$GITHUB_REPOSITORY/releases/download/$TOOLCHAIN_TAG/$TOOLCHAIN_IMAGE.hash) | |
echo "CACHE_HASH is $CACHE_HASH" | |
if [ -z "$CACHE_HASH" ] || [ "$CURRENT_HASH" != "$CACHE_HASH" ]; then | |
echo "REBUILD_TOOLCHAIN=true" >> $GITHUB_OUTPUT | |
fi | |
- name: Install Feeds | |
if: steps.hash.outputs.REBUILD_TOOLCHAIN == 'true' | |
run: | | |
cd $OPENWRT_PATH | |
./scripts/feeds update -a | |
./scripts/feeds install -a | |
- name: Compile Tools | |
if: steps.hash.outputs.REBUILD_TOOLCHAIN == 'true' | |
run: | | |
cd $OPENWRT_PATH | |
make defconfig | |
echo -e "$(nproc) thread compile" | |
make tools/compile -j$(nproc) || make tools/compile -j1 V=s | |
- name: Compile Toolchain | |
if: steps.hash.outputs.REBUILD_TOOLCHAIN == 'true' | |
run: | | |
cd $OPENWRT_PATH | |
echo -e "$(nproc) thread compile" | |
make toolchain/compile -j$(nproc) || make toolchain/compile -j1 V=s | |
rm -rf .config* dl bin | |
- name: Generate Toolchain Image | |
if: steps.hash.outputs.REBUILD_TOOLCHAIN == 'true' | |
run: | | |
cd workspace | |
mksquashfs openwrt $TOOLCHAIN_IMAGE -force-gid 1001 -force-uid 1001 -comp zstd | |
mkdir -p $GITHUB_WORKSPACE/output | |
split -d -b 1900M $TOOLCHAIN_IMAGE $GITHUB_WORKSPACE/output/$TOOLCHAIN_IMAGE.img. | |
rm $TOOLCHAIN_IMAGE | |
echo $CURRENT_HASH > $GITHUB_WORKSPACE/output/$TOOLCHAIN_IMAGE.hash | |
ls -lh $GITHUB_WORKSPACE/output | |
- name: Delete Old Toolchain Assets | |
if: steps.hash.outputs.REBUILD_TOOLCHAIN == 'true' | |
uses: mknejp/delete-release-assets@v1 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
tag: ${{ env.TOOLCHAIN_TAG }} | |
assets: '${{ env.TOOLCHAIN_IMAGE }}.*' | |
fail-if-no-assets: false | |
fail-if-no-release: false | |
- name: Upload Toolchain Image | |
if: steps.hash.outputs.REBUILD_TOOLCHAIN == 'true' | |
uses: ncipollo/release-action@v1 | |
with: | |
name: Toolchain-Image | |
allowUpdates: true | |
tag: ${{ env.TOOLCHAIN_TAG }} | |
token: ${{ secrets.GITHUB_TOKEN }} | |
artifacts: output/* | |
body: OpenWrt 工具链镜像文件 | |
Build: | |
needs: [Toolchain] | |
runs-on: ubuntu-22.04 | |
env: | |
OPENWRT_PATH: ${{ needs.Toolchain.outputs.OPENWRT_PATH }} | |
VERSION_INFO: ${{ needs.Toolchain.outputs.VERSION_INFO }} | |
CURRENT_BRANCH: ${{ needs.Toolchain.outputs.CURRENT_BRANCH }} | |
SOURCE_REPO: ${{ needs.Toolchain.outputs.SOURCE_REPO }} | |
DEVICE_TARGET: ${{ needs.Toolchain.outputs.DEVICE_TARGET }} | |
DEVICE_SUBTARGET: ${{ needs.Toolchain.outputs.DEVICE_SUBTARGET }} | |
TOOLCHAIN_IMAGE: ${{ needs.Toolchain.outputs.TOOLCHAIN_IMAGE }} | |
steps: | |
- name: Check Server Performance | |
run: | | |
echo "警告⚠" | |
echo "分配的服务器性能有限,若选择的插件过多,务必注意CPU性能!" | |
echo -e "已知CPU型号(降序):8370C,8272CL,8171M,E5-2673 \n" | |
echo "--------------------------CPU信息--------------------------" | |
echo "CPU物理数量:$(cat /proc/cpuinfo | grep "physical id" | sort | uniq | wc -l)" | |
echo -e "CPU核心信息:$(cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c) \n" | |
echo "--------------------------内存信息--------------------------" | |
echo "已安装内存详细信息:" | |
echo -e "$(sudo lshw -short -C memory | grep GiB) \n" | |
echo "--------------------------硬盘信息--------------------------" | |
echo "硬盘数量:$(ls /dev/sd* | grep -v [1-9] | wc -l)" && df -hT | |
- name: Initialization Environment | |
env: | |
DEBIAN_FRONTEND: noninteractive | |
run: | | |
docker rmi $(docker images -q) | |
sudo rm -rf /etc/apt/sources.list.d/* /usr/share/dotnet /etc/mysql /etc/php /usr/local/lib/android | |
sudo -E apt-get -y purge azure-cli* docker* ghc* zulu* llvm* firefox* google* dotnet* powershell* openjdk* mysql* php* mongodb* moby* snap* aspnetcore* | |
sudo -E apt-get -qq update | |
sudo -E apt-get -y install libfuse-dev $(curl -fsSL is.gd/depends_ubuntu_2204) | |
sudo -E apt-get -qq autoremove --purge | |
sudo -E apt-get -qq clean | |
sudo timedatectl set-timezone "$TZ" | |
- name: Combine Disks | |
run: | | |
sudo swapoff -a && sudo rm -f /mnt/swapfile | |
export ROOT_FREE_KB=$(df --block-size=1024 --output=avail / | tail -1) | |
export ROOT_LOOP_KB=$(expr $ROOT_FREE_KB - 1048576) | |
export ROOT_LOOP_BYTES=$(expr $ROOT_LOOP_KB \* 1024) | |
sudo fallocate -l $ROOT_LOOP_BYTES /root.img | |
export ROOT_LOOP_DEVNAME=$(sudo losetup -Pf --show /root.img) | |
sudo pvcreate -f $ROOT_LOOP_DEVNAME | |
export MNT_FREE_KB=$(df --block-size=1024 --output=avail /mnt | tail -1) | |
export MNT_LOOP_KB=$(expr $MNT_FREE_KB - 102400) | |
export MNT_LOOP_BYTES=$(expr $MNT_LOOP_KB \* 1024) | |
sudo fallocate -l $MNT_LOOP_BYTES /mnt/mnt.img | |
export MNT_LOOP_DEVNAME=$(sudo losetup -Pf --show /mnt/mnt.img) | |
sudo pvcreate -f $MNT_LOOP_DEVNAME | |
sudo vgcreate vgstorage $ROOT_LOOP_DEVNAME $MNT_LOOP_DEVNAME | |
sudo lvcreate -n lvstorage -l 100%FREE vgstorage | |
export LV_DEVNAME=$(sudo lvscan | awk -F "'" '{print $2}') | |
sudo mkfs.btrfs -L combinedisk $LV_DEVNAME | |
sudo mount -o compress=zstd $LV_DEVNAME $GITHUB_WORKSPACE | |
sudo chown -R runner:runner $GITHUB_WORKSPACE | |
mkdir $GITHUB_WORKSPACE/tmp && chmod 777 $GITHUB_WORKSPACE/tmp | |
sudo cp -rp /tmp/* $GITHUB_WORKSPACE/tmp | |
sudo mount -B $GITHUB_WORKSPACE/tmp /tmp && df -hT | |
- name: Checkout | |
run: | | |
cd $GITHUB_WORKSPACE | |
git init | |
git remote add origin https://github.com/$GITHUB_REPOSITORY | |
git fetch | |
git checkout -t origin/$CURRENT_BRANCH | |
- name: Prepare Toolchain Image | |
run: | | |
mkdir -p workspace | |
cd workspace | |
for i in {0..9} | |
do | |
curl -fsL https://github.com/$GITHUB_REPOSITORY/releases/download/$TOOLCHAIN_TAG/$TOOLCHAIN_IMAGE.img.0$i >> $TOOLCHAIN_IMAGE.img || break | |
done | |
mkdir openwrt-ro openwrt workdir overlay | |
sudo mount -o loop $TOOLCHAIN_IMAGE.img openwrt-ro | |
sudo mount -t overlay overlay -o lowerdir=openwrt-ro,upperdir=overlay,workdir=workdir openwrt | |
cd $OPENWRT_PATH | |
git pull | |
- name: Install Feeds | |
run: | | |
cd $OPENWRT_PATH | |
./scripts/feeds update -a | |
./scripts/feeds install -a | |
- name: Load Custom Configuration | |
run: | | |
[ -e files ] && mv files $OPENWRT_PATH/files | |
[ -e $CONFIG_FILE ] && mv $CONFIG_FILE $OPENWRT_PATH/.config | |
chmod +x $GITHUB_WORKSPACE/scripts/*.sh | |
chmod +x $DIY_SCRIPT | |
cd $OPENWRT_PATH | |
$GITHUB_WORKSPACE/$DIY_SCRIPT | |
$GITHUB_WORKSPACE/scripts/preset-clash-core.sh $CLASH_KERNEL | |
$GITHUB_WORKSPACE/scripts/preset-terminal-tools.sh | |
- name: Download DL Package | |
run: | | |
cd $OPENWRT_PATH | |
make defconfig | |
make download -j8 | |
find dl -size -1024c -exec ls -l {} \; | |
find dl -size -1024c -exec rm -f {} \; | |
- name: Compile Packages | |
run: | | |
cd $OPENWRT_PATH | |
echo -e "$(nproc) thread compile" | |
make diffconfig | |
make target/compile -j$(nproc) IGNORE_ERRORS="m n" BUILD_LOG=1 || \ | |
yes n | make target/compile -j1 V=s IGNORE_ERRORS=1 | |
make package/compile -j$(nproc) IGNORE_ERRORS=1 || make package/compile -j1 V=s IGNORE_ERRORS=1 | |
make package/index | |
- name: Generate Firmware | |
id: generate | |
run: | | |
cd $OPENWRT_PATH | |
mkdir -p files/etc/uci-defaults | |
cp $GITHUB_WORKSPACE/scripts/init-settings.sh files/etc/uci-defaults/99-init-settings | |
make package/install -j$(nproc) || make package/install -j1 V=s | |
make target/install -j$(nproc) || make target/install -j1 V=s | |
echo "status=success" >> $GITHUB_OUTPUT | |
make checksum | |
echo "DATE=$(date +"%Y-%m-%d %H:%M:%S")" >> $GITHUB_ENV | |
echo "FILE_DATE=$(date +"%Y.%m.%d")" >> $GITHUB_ENV | |
- name: Check Space Usage | |
if: always() | |
run: | | |
lsblk -f | |
echo -e "\n" | |
df -hT | |
echo -e "\n" | |
sudo btrfs filesystem usage $GITHUB_WORKSPACE | |
- name: Upload Bin Directory | |
if: steps.generate.outputs.status == 'success' && env.UPLOAD_BIN_DIR == 'true' | |
uses: actions/upload-artifact@main | |
with: | |
name: ${{ env.SOURCE_REPO }}-bin-${{ env.DEVICE_TARGET }}-${{ env.DEVICE_SUBTARGET }}-${{ env.FILE_DATE }} | |
path: ${{ env.OPENWRT_PATH }}/bin | |
- name: Organize Files | |
if: steps.generate.outputs.status == 'success' | |
run: | | |
cd $OPENWRT_PATH/bin/targets/*/* | |
cat sha256sums | |
cp $OPENWRT_PATH/.config build.config | |
mv -f $OPENWRT_PATH/bin/packages/*/*/*.ipk packages | |
tar -zcf Packages.tar.gz packages | |
rm -rf packages feeds.buildinfo version.buildinfo | |
echo "FIRMWARE_PATH=$PWD" >> $GITHUB_ENV | |
- name: Upload Firmware To Artifact | |
if: steps.generate.outputs.status == 'success' && env.FIRMWARE_RELEASE != 'true' | |
uses: actions/upload-artifact@main | |
with: | |
name: ${{ env.SOURCE_REPO }}-firmware-${{ env.DEVICE_TARGET }}-${{ env.DEVICE_SUBTARGET }}-${{ env.FILE_DATE }} | |
path: ${{ env.FIRMWARE_PATH }} | |
- name: Upload Firmware To Release | |
if: steps.generate.outputs.status == 'success' && env.FIRMWARE_RELEASE == 'true' | |
uses: ncipollo/release-action@v1 | |
with: | |
name: R${{ env.DATE }} for ${{ env.FIRMWARE_TAG }} | |
allowUpdates: true | |
tag: ${{ env.FIRMWARE_TAG }} | |
token: ${{ secrets.GITHUB_TOKEN }} | |
artifacts: ${{ env.FIRMWARE_PATH }}/* | |
body: | | |
**This is Temporary Firmware for Armvirt 64** | |
* 这是 ARMv8_PLUS 多功能版打包临时固件,不可直刷 | |
直刷固件参见 Tag 名为 ARMv8_PLUS 的 Releases | |
当前使用版本:【编译前的最后一次[➦主源码](https://github.com/coolsnowwolf/lede)更新记录】 | |
${{ env.VERSION_INFO }} | |
Package: | |
needs: [Toolchain, Build] | |
runs-on: ubuntu-22.04 | |
env: | |
VERSION_INFO: ${{ needs.Toolchain.outputs.VERSION_INFO }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@main | |
- name: Initialization Environment | |
env: | |
DEBIAN_FRONTEND: noninteractive | |
run: | | |
sudo rm -rf /etc/apt/sources.list.d/* /usr/share/dotnet /etc/mysql /etc/php /usr/local/lib/android | |
sudo -E apt-get -qq update | |
sudo -E apt-get -y install $(curl -fsSL is.gd/depends_ubuntu_2204) | |
sudo -E apt-get -qq autoremove --purge | |
sudo -E apt-get -qq clean | |
sudo timedatectl set-timezone "$TZ" | |
- name: Download Armvirt Firmware | |
id: download | |
run: | | |
[ -d openwrt-armvirt ] || mkdir -p openwrt-armvirt | |
curl -s "https://api.github.com/repos/$GITHUB_REPOSITORY/releases" | grep -o "$FIRMWARE_TAG.*rootfs.tar.gz" > DOWNLOAD_ARMVIRT | |
wget -q -P openwrt-armvirt https://github.com/$GITHUB_REPOSITORY/releases/download/$(cat DOWNLOAD_ARMVIRT) | |
echo "status=success" >> $GITHUB_OUTPUT | |
echo "DATE=$(date +"%Y-%m-%d %H:%M:%S")" >> $GITHUB_ENV | |
echo "DATE1=$(date +"%y.%m.%d")" >> $GITHUB_ENV | |
- name: Package OpenWrt Firmware | |
if: steps.download.outputs.status == 'success' | |
uses: unifreq/openwrt_packit@master | |
env: | |
OPENWRT_ARMVIRT: openwrt-armvirt/*rootfs.tar.gz | |
PACKAGE_SOC: all | |
WHOAMI: Haiibo | |
KERNEL_VERSION_NAME: 5.15.13_6.1.5 | |
KERNEL_AUTO_LATEST: true | |
DISTRIB_REVISION: R${{ env.DATE1 }} by Haiibo | |
- name: Upload OpenWrt To Artifact | |
if: env.PACKAGED_STATUS == 'success' && env.OPENWRT_RELEASE != 'true' | |
uses: kittaakos/upload-artifact-as-is@master | |
with: | |
path: ${{ env.PACKAGED_OUTPUTPATH }} | |
- name: Upload OpenWrt To Release | |
if: env.PACKAGED_STATUS == 'success' && env.OPENWRT_RELEASE == 'true' | |
uses: ncipollo/release-action@v1 | |
with: | |
name: R${{ env.DATE }} for ${{ env.OPENWRT_TAG }} | |
allowUpdates: true | |
removeArtifacts: true | |
tag: ${{ env.OPENWRT_TAG }} | |
token: ${{ secrets.GITHUB_TOKEN }} | |
artifacts: ${{ env.PACKAGED_OUTPUTPATH }}/* | |
body: | | |
**This is OpenWrt Firmware for Armvirt 64** | |
* 这是 ARMv8 多功能版,集成插件多适合折腾 | |
默认 IP:192.168.1.1 默认密码:password | |
安装到 EMMC:系统 → 晶晨宝盒 → 安装 OpenWrt → 选择型号 → 安装 | |
升级 OpenWrt:系统 → 晶晨宝盒 → 手动上传更新 或者 在线下载更新 | |
常见问题及注意事项请参考恩山F大➦[最新帖](https://www.right.com.cn/forum/thread-4076037-1-1.html) | |
当前使用版本:【编译前的最后一次➦[主源码](https://github.com/coolsnowwolf/lede)更新记录】 | |
${{ env.VERSION_INFO }} |