Skip to content

Commit

Permalink
添加 linux3环境下载的dsm7.1编译过程😔
Browse files Browse the repository at this point in the history
  • Loading branch information
tossp committed Apr 12, 2022
1 parent 4831cd2 commit c82a672
Show file tree
Hide file tree
Showing 4 changed files with 111 additions and 3 deletions.
106 changes: 106 additions & 0 deletions .github/workflows/pat.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
name: 构建DSM7.1

on:
workflow_dispatch:
inputs:
clean_cache:
description: 'Clear caches'
required: false
type: boolean
push:
branches:
- master
paths:
- "docker/**"
- "**.sh"
- "**.json"

jobs:
build:
runs-on: ubuntu-latest
name: 编译 "${{matrix.platform}} ${{matrix.version}}"
strategy:
fail-fast: false
matrix:
include:
# 两行一组,删除不需要的版本
- platform: ds3615xs
version: 7.1.0-42661

- platform: ds3617xs
version: 7.1.0-42661

steps:
- name: 检出项目文件
uses: actions/checkout@v3

- name: 缓存加速
uses: actions/cache@v3
with:
path: |
cache/*.pat
cache/*.org
docker/downloads/*.txz
key: ${{matrix.platform}}-${{matrix.version}}-${{ hashFiles('global_config.json') }}
restore-keys: ${{matrix.platform}}-${{matrix.version}}-

- name: 清理缓存
if: "${{ github.event.inputs.clean_cache == 'true' }}"
run: |
rm -rf cache/*.pat
rm -rf cache/*.org
rm -rf docker/downloads/*.txz
- name: 准备构建环境
run: |
./redpill_tool_chain.sh build ${{matrix.platform}}-${{matrix.version}}
- name: 配置引导镜像
run: |
cp sample_user_config.json ${{matrix.platform}}_user_config.json
# 调整VID和PID
sed -i -e 's/0x0001/0x88AA/g' -e 's/0x46f4/0x88AA/g' ${{matrix.platform}}_user_config.json
# 调整SN和MAC,最好使用 actions secrets 引入,SN应该是固定值不应该每次生成
sn=`./redpill_tool_chain.sh sn ${{matrix.platform}} | grep 'Serial Number' | awk '{print $3}'`
sed -i -e "s/1234XXX123/${sn:="1130LWN123456"}/g" -e 's/XXYYXXYYXXYY/0011323D47F7/g' ${{matrix.platform}}_user_config.json
# 添加第二张网卡mac并设置网卡数量
sed -i -e 's/0011323D47F7"/&,\n\t"mac2": "0011323D47F8",\n\t"netif_num": 2/' ${{matrix.platform}}_user_config.json
# 调整synoinfo
sed -i -e 's/"synoinfo": {},/"synoinfo": {\n\t"maxlanport": "2"\n },/' ${{matrix.platform}}_user_config.json
cat ${{matrix.platform}}_user_config.json
- name: 添加扩展驱动
if: matrix.platform != 'dva3221'
run: |
./redpill_tool_chain.sh add https://github.com/tossp/redpill-tool-chain/raw/master/extensions/redpill-boot-wait.json
./redpill_tool_chain.sh add https://github.com/tossp/redpill-tool-chain/raw/master/extensions/redpill-acpid.json
./redpill_tool_chain.sh add https://github.com/tossp/redpill-tool-chain/raw/master/extensions/redpill-virtio.json
./redpill_tool_chain.sh add https://github.com/tossp/redpill-tool-chain/raw/master/extensions/redpill-misc
- name: 编译引导镜像
run: |
sed -i 's/debian:8-slim/debian:10-slim/g' global_config.json
./redpill_tool_chain.sh build ${{matrix.platform}}-${{matrix.version}}
./redpill_tool_chain.sh pat ${{matrix.platform}}-${{matrix.version}}
sed -i 's/debian:10-slim/debian:8-slim/g' global_config.json
./redpill_tool_chain.sh build ${{matrix.platform}}-${{matrix.version}}
./redpill_tool_chain.sh auto ${{matrix.platform}}-${{matrix.version}}
- name: 上传引导镜像到 github actions
uses: actions/upload-artifact@v3
with:
name: dsm-${{matrix.platform}}-${{matrix.version}}
path: images/redpill-*.img
if-no-files-found: error

- name: 删除旧的工作流
uses: Mattraks/delete-workflow-runs@v2
with:
retain_days: 1
keep_minimum_runs: 3
2 changes: 1 addition & 1 deletion docker/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ build_redpill_load:
echo "#############################################"
@read -a KVERS <<< "$$(modinfo --field=vermagic redpill-lkm/redpill.ko)" && \
cp -f $(REDPILL_LKM_SRC)/redpill.ko $(REDPILL_LOAD_SRC)/ext/rp-lkm/redpill-linux-v$${KVERS[0]}.ko
./helper.sh "${TARGET_NAME}" "${TARGET_VERSION}-${TARGET_REVISION}"
./helper.sh
pushd $(REDPILL_LOAD_SRC) && ./build-loader.sh '$(TARGET_NAME)' '$(TARGET_VERSION)-$(TARGET_REVISION)'

.PHONY: build_all
Expand Down
2 changes: 1 addition & 1 deletion docker/helper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

set -u

if [ ${TARGET_REVISION} -lt 42218 ];then
if [ ${TARGET_REVISION} -lt 42661 ];then
exit 0
fi

Expand Down
4 changes: 3 additions & 1 deletion redpill_tool_chain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ function runContainer(){
--env REVISION="${TARGET_REVISION}" \
--env LOCAL_RP_LKM_USE="${LOCAL_RP_LKM_USE}" \
--env LOCAL_RP_LOAD_USE="${LOCAL_RP_LOAD_USE}" \
${DOCKER_IMAGE_NAME}:${ID} $( [ "${CMD}" == "run" ] && echo "/bin/bash")
${DOCKER_IMAGE_NAME}:${ID} $( [ "${CMD}" == "run" ] && echo "/bin/bash") $( [ "${CMD}" == "pat" ] && echo "/opt/helper.sh")
}

function __ext_add(){
Expand Down Expand Up @@ -345,6 +345,8 @@ case "${ACTION}" in
;;
run) runContainer "run"
;;
pat) runContainer "pat"
;;
auto) runContainer "auto"
;;
clean) clean
Expand Down

0 comments on commit c82a672

Please sign in to comment.