mirror of
https://github.com/RROrg/rr.git
synced 2025-06-21 05:51:05 +08:00
285 lines
10 KiB
YAML
285 lines
10 KiB
YAML
#
|
|
# Copyright (C) 2022 Ing <https://github.com/wjz304>
|
|
#
|
|
# This is free software, licensed under the MIT License.
|
|
# See /LICENSE for more information.
|
|
#
|
|
|
|
name: Build arpl
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
tags:
|
|
- v*
|
|
|
|
release:
|
|
types: [published]
|
|
|
|
workflow_dispatch:
|
|
inputs:
|
|
version:
|
|
description: 'format %y.%-m.$i or auto'
|
|
required: false
|
|
type: string
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@main
|
|
|
|
# Install dependencies
|
|
- name: Install dependencies
|
|
run: |
|
|
git config --global user.email "github-actions[bot]@users.noreply.github.com"
|
|
git config --global user.name "github-actions[bot]"
|
|
|
|
sudo apt-get update
|
|
sudo apt-get install -y jq gettext libelf-dev qemu-utils
|
|
sudo cp -f files/board/arpl/overlayfs/usr/bin/yq /usr/bin/yq
|
|
|
|
# Check dl cache
|
|
- name: Cache downloads
|
|
id: dl-cache
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: ~/dl
|
|
key: ${{ runner.os }}-dl
|
|
|
|
# Check buildroot cache
|
|
- name: Cache buildroot
|
|
id: br-cache
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: .buildroot
|
|
key: ${{ runner.os }}-${{ hashFiles('files/configs/arpl_defconfig') }}
|
|
|
|
# Clone buildroot repository (if not cached)
|
|
- name: Clone buildroot
|
|
if: steps.br-cache.outputs.cache-hit != 'true'
|
|
run: |
|
|
git clone --single-branch -b 2022.02 https://github.com/buildroot/buildroot.git .buildroot
|
|
# Copy files
|
|
echo "Copying files"
|
|
cp -Ru files/* .buildroot
|
|
cd .buildroot
|
|
echo "Generating default config"
|
|
make BR2_EXTERNAL=../external arpl_defconfig
|
|
|
|
# Download sources if not cached
|
|
- name: Download buildroot packages source
|
|
if: steps.dl-cache.outputs.cache-hit != 'true'
|
|
run: |
|
|
cd .buildroot
|
|
make BR2_EXTERNAL=../external source
|
|
|
|
# Prepare buildroot for first make
|
|
- name: Prepare buildroot
|
|
if: steps.br-cache.outputs.cache-hit != 'true'
|
|
run: |
|
|
echo "First make"
|
|
cd .buildroot
|
|
make BR2_EXTERNAL=../external
|
|
|
|
# calculates the version number and push
|
|
- name: Calculate version
|
|
run: |
|
|
# Calculate version
|
|
VERSION=""
|
|
if [[ "${{ github.event_name }}" =~ ^(push|release)$ && "${{ github.ref_type }}" == 'tag' ]]; then
|
|
VERSION="${{ github.ref_name }}"
|
|
elif [ -n "${{ inputs.version }}" ]; then
|
|
if [ "`echo ${{ inputs.version }} | cut -d '.' -f 1,2`" = "`date +'%y.%-m'`" ]; then
|
|
VERSION="${{ inputs.version }}"
|
|
else
|
|
LATEST_TAG="`curl -skL "https://api.github.com/repos/${{ github.repository }}/releases/latest" | jq -r ".[0].tag_name" 2>/dev/null`"
|
|
if [ -n "${LATEST_TAG}" -a "`echo ${LATEST_TAG} | cut -d '.' -f 1,2`" = "`date +'%y.%-m'`" ]; then # format %y.%-m.$i
|
|
VERSION="`echo ${LATEST_TAG} | awk -F '.' '{$3=$3+1}1' OFS='.'`"
|
|
else
|
|
VERSION="`date +'%y.%-m'`.0"
|
|
fi
|
|
fi
|
|
else
|
|
VERSION=""
|
|
fi
|
|
|
|
echo "VERSION: ${VERSION}"
|
|
echo "VERSION=${VERSION}" >> $GITHUB_ENV
|
|
|
|
if [ -n "${VERSION}" ]; then
|
|
# Modify Source File
|
|
echo "${VERSION}" > VERSION
|
|
echo "${VERSION}" > files/board/arpl/p1/ARPL-VERSION
|
|
sed 's/^ARPL_VERSION=.*/ARPL_VERSION="'${VERSION}'"/' -i files/board/arpl/overlayfs/opt/arpl/include/consts.sh
|
|
|
|
git pull
|
|
status=$(git status -s | awk '{printf " %s", $2}')
|
|
if [ -n "${status}" ]; then
|
|
git add ${status}
|
|
git commit -m "update $(date +%Y-%m-%d" "%H:%M:%S)"
|
|
git push -f
|
|
fi
|
|
fi
|
|
|
|
# Convert po2mo, Get extractor, LKM, addons and Modules
|
|
- name: Convert po2mo, Get extractor, LKM, addons and Modules
|
|
run: |
|
|
# Convert po2mo
|
|
echo "Convert po2mo"
|
|
if [ -d files/board/arpl/overlayfs/opt/arpl/lang ]; then
|
|
for P in "`ls files/board/arpl/overlayfs/opt/arpl/lang/*.po`"
|
|
do
|
|
# Use msgfmt command to compile the .po file into a binary .mo file
|
|
msgfmt ${P} -o ${P/.po/.mo}
|
|
done
|
|
fi
|
|
|
|
|
|
# Get extractor
|
|
echo "Getting syno extractor"
|
|
TOOL_PATH="files/board/arpl/p3/extractor"
|
|
CACHE_DIR="/tmp/pat"
|
|
|
|
rm -rf "${TOOL_PATH}"
|
|
mkdir -p "${TOOL_PATH}"
|
|
rm -rf "${CACHE_DIR}"
|
|
mkdir -p "${CACHE_DIR}"
|
|
|
|
OLDPAT_URL="https://global.download.synology.com/download/DSM/release/7.0.1/42218/DSM_DS3622xs%2B_42218.pat"
|
|
OLDPAT_FILE="DSM_DS3622xs+_42218.pat"
|
|
STATUS=`curl -# -w "%{http_code}" -L "${OLDPAT_URL}" -o "${CACHE_DIR}/${OLDPAT_FILE}"`
|
|
if [ $? -ne 0 -o ${STATUS} -ne 200 ]; then
|
|
echo "[E] DSM_DS3622xs%2B_42218.pat download error!"
|
|
rm -rf ${CACHE_DIR}
|
|
exit 1
|
|
fi
|
|
|
|
mkdir -p "${CACHE_DIR}/ramdisk"
|
|
tar -C "${CACHE_DIR}/ramdisk/" -xf "${CACHE_DIR}/${OLDPAT_FILE}" rd.gz 2>&1
|
|
if [ $? -ne 0 ]; then
|
|
echo "[E] extractor rd.gz error!"
|
|
rm -rf ${CACHE_DIR}
|
|
exit 1
|
|
fi
|
|
(cd "${CACHE_DIR}/ramdisk"; xz -dc < rd.gz | cpio -idm) >/dev/null 2>&1 || true
|
|
|
|
# Copy only necessary files
|
|
for f in libcurl.so.4 libmbedcrypto.so.5 libmbedtls.so.13 libmbedx509.so.1 libmsgpackc.so.2 libsodium.so libsynocodesign-ng-virtual-junior-wins.so.7; do
|
|
cp "${CACHE_DIR}/ramdisk/usr/lib/${f}" "${TOOL_PATH}"
|
|
done
|
|
cp "${CACHE_DIR}/ramdisk/usr/syno/bin/scemd" "${TOOL_PATH}/syno_extract_system_patch"
|
|
rm -rf ${CACHE_DIR}
|
|
|
|
|
|
# Get latest LKMs
|
|
echo "Getting latest LKMs"
|
|
TAG=`curl -s https://api.github.com/repos/wjz304/redpill-lkm/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3)}'`
|
|
STATUS=`curl -w "%{http_code}" -L "https://github.com/wjz304/redpill-lkm/releases/download/${TAG}/rp-lkms.zip" -o /tmp/rp-lkms.zip`
|
|
echo "Status=${STATUS}"
|
|
[ ${STATUS} -ne 200 ] && exit 1
|
|
# Unzip LKMs
|
|
rm -rf files/board/arpl/p3/lkms
|
|
mkdir -p files/board/arpl/p3/lkms
|
|
unzip /tmp/rp-lkms.zip -d files/board/arpl/p3/lkms
|
|
|
|
# Get latest addons and install its
|
|
echo "Getting latest Addons"
|
|
TAG=`curl -s https://api.github.com/repos/wjz304/arpl-addons/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3)}'`
|
|
STATUS=`curl -w "%{http_code}" -L "https://github.com/wjz304/arpl-addons/releases/download/${TAG}/addons.zip" -o /tmp/addons.zip`
|
|
echo "Status=${STATUS}"
|
|
[ ${STATUS} -ne 200 ] && exit 1
|
|
# Install Addons
|
|
mkdir -p /tmp/addons
|
|
unzip /tmp/addons.zip -d /tmp/addons
|
|
DEST_PATH="files/board/arpl/p3/addons"
|
|
echo "Installing addons to ${DEST_PATH}"
|
|
for PKG in `ls /tmp/addons/*.addon`; do
|
|
ADDON=`basename "${PKG}" .addon`
|
|
mkdir -p "${DEST_PATH}/${ADDON}"
|
|
echo "Extracting ${PKG} to ${DEST_PATH}/${ADDON}"
|
|
tar xaf "${PKG}" -C "${DEST_PATH}/${ADDON}"
|
|
done
|
|
|
|
# Get latest modules
|
|
echo "Getting latest Modules"
|
|
MODULES_DIR="files/board/arpl/p3/modules"
|
|
TAG=`curl -s https://api.github.com/repos/wjz304/arpl-modules/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3)}'`
|
|
STATUS=`curl -w "%{http_code}" -L "https://github.com/wjz304/arpl-modules/releases/download/${TAG}/modules.zip" -o "/tmp/modules.zip"`
|
|
echo "Status=${STATUS}"
|
|
[ ${STATUS} -ne 200 ] && exit 1
|
|
# Unzip Modules
|
|
rm -rf "${MODULES_DIR}/"*
|
|
unzip /tmp/modules.zip -d "${MODULES_DIR}"
|
|
|
|
echo OK
|
|
|
|
# Build incremental from caches
|
|
- name: Build image
|
|
run: |
|
|
# Remove old files
|
|
rm -rf .buildroot/output/target/opt/arpl
|
|
rm -rf .buildroot/board/arpl/overlayfs
|
|
rm -rf .buildroot/board/arpl/p1
|
|
rm -rf .buildroot/board/arpl/p3
|
|
|
|
# Copy files
|
|
echo "Copying files"
|
|
cp -Ru files/* .buildroot/
|
|
|
|
cd .buildroot
|
|
echo "Generating default config"
|
|
make BR2_EXTERNAL=../external arpl_defconfig
|
|
echo "Building..."
|
|
make BR2_EXTERNAL=../external
|
|
cd -
|
|
qemu-img convert -O vmdk arpl.img arpl-dyn.vmdk
|
|
qemu-img convert -O vmdk -o adapter_type=lsilogic arpl.img -o subformat=monolithicFlat arpl.vmdk
|
|
|
|
# Upload artifact
|
|
- name: Upload
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: Images
|
|
path: |
|
|
arpl.img
|
|
arpl*.vmdk
|
|
retention-days: 5
|
|
|
|
# Zip image and generate checksum
|
|
- name: Pack
|
|
if: env.VERSION != ''
|
|
run: |
|
|
zip -9 "arpl-i18n-${{ env.VERSION }}.img.zip" arpl.img
|
|
zip -9 "arpl-i18n-${{ env.VERSION }}.vmdk-dyn.zip" arpl-dyn.vmdk
|
|
zip -9 "arpl-i18n-${{ env.VERSION }}.vmdk-flat.zip" arpl.vmdk arpl-flat.vmdk
|
|
sha256sum update-list.yml > sha256sum
|
|
zip -9j update.zip update-list.yml
|
|
while read F; do
|
|
if [ -d "${F}" ]; then
|
|
FTGZ="`basename "${F}"`.tgz"
|
|
tar czf "${FTGZ}" -C "${F}" .
|
|
sha256sum "${FTGZ}" >> sha256sum
|
|
zip -9j update.zip "${FTGZ}"
|
|
rm "${FTGZ}"
|
|
else
|
|
(cd `dirname ${F}` && sha256sum `basename ${F}`) >> sha256sum
|
|
zip -9j update.zip "${F}"
|
|
fi
|
|
done < <(yq '.replace | explode(.) | to_entries | map([.key])[] | .[]' update-list.yml)
|
|
zip -9j update.zip sha256sum
|
|
|
|
# Publish a release if is a tag
|
|
- name: Release
|
|
uses: softprops/action-gh-release@v1
|
|
if: env.VERSION != ''
|
|
with:
|
|
tag_name: ${{ env.VERSION }}
|
|
files: |
|
|
arpl-i18n-${{ env.VERSION }}.img.zip
|
|
arpl-i18n-${{ env.VERSION }}.vmdk-dyn.zip
|
|
arpl-i18n-${{ env.VERSION }}.vmdk-flat.zip
|
|
update.zip
|