Skip to content

Commit 0bef069

Browse files
committed
添加 cks.yml 工作流
1 parent 1622b46 commit 0bef069

File tree

2 files changed

+308
-4
lines changed

2 files changed

+308
-4
lines changed

.github/workflows/cks.yml

Lines changed: 303 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,303 @@
1+
#
2+
# Copyright (C) 2022 Ing <https://github.com/wjz304>
3+
#
4+
# This is free software, licensed under the MIT License.
5+
# See /LICENSE for more information.
6+
#
7+
8+
name: Build cks
9+
10+
on:
11+
workflow_dispatch:
12+
inputs:
13+
version:
14+
description: "format %y.%-m.$i or auto"
15+
required: false
16+
type: string
17+
prerelease:
18+
description: "pre release"
19+
default: false
20+
type: boolean
21+
22+
jobs:
23+
build:
24+
strategy:
25+
matrix:
26+
include:
27+
#- version: 7.1
28+
# platform: rtd1619b
29+
# config: ""
30+
- version: 7.2
31+
platform: rtd1619b
32+
config: ""
33+
34+
runs-on: ubuntu-latest
35+
steps:
36+
- name: Checkout
37+
uses: actions/checkout@main
38+
39+
- name: Checkout
40+
uses: actions/checkout@main
41+
with:
42+
repository: RROrg/rp-modules
43+
token: ${{ secrets.RRORG }}
44+
path: rp-modules
45+
46+
- name: Checkout
47+
uses: actions/checkout@main
48+
with:
49+
repository: RROrg/rrr-cks
50+
token: ${{ secrets.RRORG }}
51+
path: rrr-cks
52+
53+
- name: Init Env
54+
run: |
55+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
56+
git config --global user.name "github-actions[bot]"
57+
sudo timedatectl set-timezone "Asia/Shanghai"
58+
59+
sudo apt update
60+
sudo apt install -y curl build-essential bison flex dwarves ruby libncurses-dev libssl-dev libelf-dev
61+
62+
- name: Make modules
63+
run: |
64+
ROOT_PATH=${{ github.workspace }}
65+
VERSION=${{ matrix.version }}
66+
PLATFORM=${{ matrix.platform }}
67+
CONFIG=${{ matrix.config }}
68+
69+
if [ "${VERSION}" = "7.2" ]; then
70+
git clone --depth=1 https://github.com/RROrg/linux_dsm_rtd1619b.git
71+
else
72+
echo "Only support 7.2"
73+
exit 1
74+
fi
75+
76+
. ${ROOT_PATH}/rp-modules/compile-ck.sh
77+
78+
echo "makeEnvDeploy"
79+
makeEnvDeploy "${ROOT_PATH}" "${VERSION}" "${PLATFORM}"
80+
81+
echo "makekernel"
82+
if [ -n "${CONFIG}" ]; then
83+
if [ -f "${ROOT_PATH}/linux_dsm_rtd1619b/synology/synoconfigs/${PLATFORM}_${CONFIG}" ]; then
84+
cp -f "${ROOT_PATH}/linux_dsm_rtd1619b/synology/synoconfigs/${PLATFORM}_${CONFIG}" "${ROOT_PATH}/linux_dsm_rtd1619b/synology/synoconfigs/${PLATFORM}"
85+
else
86+
echo "Config ${PLATFORM}_${CONFIG} does not exist."
87+
exit 1
88+
fi
89+
fi
90+
makekernel "${ROOT_PATH}" "${VERSION}" "${PLATFORM}" "${ROOT_PATH}/linux_dsm_rtd1619b" "${ROOT_PATH}/output"
91+
92+
echo "makemodules"
93+
KVER="$(getKver "${ROOT_PATH}" "${VERSION}" "${PLATFORM}" "${ROOT_PATH}/linux_dsm_rtd1619b")"
94+
cp -f "${ROOT_PATH}/rp-modules/src/${KVER}-ck/defines.${PLATFORM}" "${ROOT_PATH}/rp-modules/src/${KVER}-ck/defines"
95+
makemodules "${ROOT_PATH}" "${VERSION}" "${PLATFORM}" "${ROOT_PATH}/linux_dsm_rtd1619b" "${ROOT_PATH}/rp-modules/src/${KVER}-ck" "${ROOT_PATH}/modules"
96+
cp -rf "${ROOT_PATH}/modules/"* "${ROOT_PATH}/output"
97+
98+
- name: Tar to Artifacts
99+
run: |
100+
ROOT_PATH=${{ github.workspace }}
101+
VERSION=${{ matrix.version }}
102+
PLATFORM=${{ matrix.platform }}
103+
104+
. ${ROOT_PATH}/rp-modules/compile-ck.sh
105+
106+
KVER="$(getKver "${ROOT_PATH}" "${VERSION}" "${PLATFORM}" "linux_dsm_rtd1619b")"
107+
if [ "${PLATFORM}" = "rtd1619b" ]; then
108+
PARTY3RD_PATH="${ROOT_PATH}/rrr-cks/thirdparty/${PLATFORM}-${VERSION}-${KVER}"
109+
else
110+
PARTY3RD_PATH="${ROOT_PATH}/rrr-cks/thirdparty/${PLATFORM}-${KVER}"
111+
fi
112+
113+
echo "copy 3rd modules"
114+
[ -d "${PARTY3RD_PATH}" ] && cp -rf ${PARTY3RD_PATH}/* ${ROOT_PATH}/output/modules/
115+
116+
echo "check depends"
117+
for M in $(ls ${ROOT_PATH}/output/modules 2>/dev/null); do
118+
function _copydepends() {
119+
if [ ! -f "${ROOT_PATH}/output/modules/${1}" ] && [ ! -f "${OFFICIAL_PATH/hda1/rd}/${1}" ]; then
120+
if [ -f "${OFFICIAL_PATH}/${1}" ]; then
121+
cp -f "${OFFICIAL_PATH}/${1}" "${ROOT_PATH}/output/modules"
122+
else
123+
echo "[E] '${PLATFORM}-${KVER}' - '${M}' depends '${1}' does not exist."
124+
fi
125+
fi
126+
D=""
127+
[ -z "${D}" ] && [ -f "${ROOT_PATH}/output/modules/${1}" ] && D="${ROOT_PATH}/output/modules/${1}"
128+
[ -z "${D}" ] && [ -f "${OFFICIAL_PATH/hda1/rd}/${1}" ] && D="${OFFICIAL_PATH/hda1/rd}/${1}"
129+
if [ -n "${D}" ]; then
130+
# modinfo "${D}" || true
131+
depends=($(modinfo "${D}" 2>/dev/null | grep depends: | awk -F: '{print $2}' | awk '$1=$1' | sed 's/,/ /g')) || true
132+
if [ ${#depends[*]} -gt 0 ]; then
133+
for k in ${depends[@]}; do
134+
[ -f "${ROOT_PATH}/output/modules/${k}.ko" ] && continue # Recursively skip wext-priv and wext-core dependencies on each other.
135+
_copydepends "${k}.ko"
136+
done
137+
fi
138+
fi
139+
}
140+
_copydepends "${M}"
141+
done
142+
if [ "${PLATFORM}" = "rtd1619b" ]; then
143+
tar -zcf ${ROOT_PATH}/modules-${PLATFORM}-${VERSION}-${KVER}.tgz -C ${ROOT_PATH}/output/modules .
144+
gzip -c ${ROOT_PATH}/output/bzImage >${ROOT_PATH}/bzImage-${PLATFORM}-${VERSION}-${KVER}.gz
145+
else
146+
tar -zcf ${ROOT_PATH}/${PLATFORM}-${KVER}.tgz -C ${ROOT_PATH}/output/modules .
147+
gzip -c ${ROOT_PATH}/output/bzImage >${ROOT_PATH}/bzImage-${PLATFORM}-${KVER}.gz
148+
fi
149+
150+
- name: Upload to Artifacts
151+
uses: actions/upload-artifact@v4
152+
with:
153+
name: rrr-cks${{ matrix.config }}-${{ matrix.version }}-${{ matrix.platform }}
154+
path: |
155+
*.tgz
156+
*.gz
157+
158+
firmware:
159+
needs: build
160+
strategy:
161+
matrix:
162+
include:
163+
- config: ""
164+
165+
runs-on: ubuntu-latest
166+
steps:
167+
- name: Checkout
168+
uses: actions/checkout@main
169+
170+
- name: Checkout
171+
uses: actions/checkout@main
172+
with:
173+
repository: RROrg/rrr-cks
174+
token: ${{ secrets.RRORG }}
175+
path: rrr-cks
176+
177+
- name: Init Env
178+
run: |
179+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
180+
git config --global user.name "github-actions[bot]"
181+
sudo timedatectl set-timezone "Asia/Shanghai"
182+
183+
- name: download to artifacts
184+
uses: actions/download-artifact@v4
185+
with:
186+
path: output
187+
pattern: rrr-cks${{ matrix.config }}-*
188+
merge-multiple: true
189+
190+
- name: firmware
191+
run: |
192+
ROOT_PATH=${{ github.workspace }}
193+
194+
mkdir -p ${ROOT_PATH}/firmware
195+
196+
echo "copy 3rd modules"
197+
PARTY3RD_PATH="${ROOT_PATH}/rrr-cks/thirdparty/firmware"
198+
[ -d "${PARTY3RD_PATH}" ] && cp -rf ${PARTY3RD_PATH}/* ${ROOT_PATH}/firmware/
199+
200+
echo "extract all modules"
201+
for F in output/*.tgz; do
202+
echo "${F}"
203+
mkdir -p "${F%.tgz}"
204+
tar -zxf "${F}" -C "${F%.tgz}" || echo "Failed to extract ${F}"
205+
done
206+
207+
echo "get firmware"
208+
SOURCE=/tmp/linux-firmware
209+
git clone --depth=1 https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git ${SOURCE}
210+
while read L; do
211+
[ -z "${L}" ] && continue
212+
if [ -e "${SOURCE}/${L}" ]; then
213+
mkdir -p "$(dirname firmware/${L})"
214+
cp -f "${SOURCE}/${L}" "firmware/${L}"
215+
else
216+
[ -e "firmware/${L}" ] && echo "Used thirdparty ${L}" || echo "Missing ${L}"
217+
fi
218+
done <<<$(find output -name \*.ko -exec sh -c 'modinfo {} | grep ^firmware' \; | awk '{print $2}')
219+
220+
tar -zcf firmware.tgz -C firmware .
221+
222+
- name: Upload to Artifacts
223+
uses: actions/upload-artifact@v4
224+
with:
225+
name: rrr-cks${{ matrix.config }}-firmware
226+
path: |
227+
firmware.tgz
228+
229+
release:
230+
runs-on: ubuntu-latest
231+
needs: firmware
232+
steps:
233+
- name: Checkout
234+
uses: actions/checkout@main
235+
236+
- name: Init Env
237+
run: |
238+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
239+
git config --global user.name "github-actions[bot]"
240+
sudo timedatectl set-timezone "Asia/Shanghai"
241+
242+
- name: Calculate version
243+
run: |
244+
# Calculate version
245+
VERSION=""
246+
if [ -n "${{ inputs.version }}" ]; then
247+
if [ "$(echo ${{ inputs.version }} | cut -d '.' -f 1,2)" = "$(date +'%y.%-m')" ]; then
248+
VERSION="${{ inputs.version }}"
249+
else
250+
LATEST_TAG="$(curl -skLH "Authorization: token ${{ secrets.RRORG }}" "https://api.github.com/repos/RROrg/rrr-cks/releases" | jq -r ".[0].tag_name" 2>/dev/null)"
251+
if [ -n "${LATEST_TAG}" ] && [ "$(echo ${LATEST_TAG} | cut -d '.' -f 1,2)" = "$(date +'%y.%-m')" ]; then # format %y.%-m.$i
252+
VERSION="$(echo ${LATEST_TAG} | awk -F '.' '{$3=$3+1}1' OFS='.')"
253+
else
254+
VERSION="$(date +'%y.%-m').0"
255+
fi
256+
fi
257+
else
258+
VERSION=""
259+
fi
260+
261+
echo "VERSION: ${VERSION}"
262+
echo "VERSION=${VERSION}" >> $GITHUB_ENV
263+
264+
- name: download to artifacts
265+
uses: actions/download-artifact@v4
266+
with:
267+
path: output
268+
pattern: rrr-cks-*
269+
merge-multiple: true
270+
271+
- name: delete-artifact
272+
uses: geekyeggo/delete-artifact@v5
273+
with:
274+
name: |
275+
rrr-cks-*
276+
277+
- name: Zip modules
278+
run: |
279+
VERSION="${{ env.VERSION }}"
280+
VERSION="${VERSION:-"test"}"
281+
282+
echo "${VERSION}" > "output/VERSION"
283+
zip -9 rrr-cks-${VERSION}.zip -j output/*
284+
285+
- name: Upload to Artifacts
286+
if: success() && env.VERSION == ''
287+
uses: actions/upload-artifact@v4
288+
with:
289+
name: rrr-cks
290+
path: |
291+
rrr-cks-*.zip
292+
retention-days: 5
293+
294+
- name: Release
295+
if: success() && env.VERSION != ''
296+
uses: ncipollo/release-action@v1
297+
with:
298+
tag: ${{ env.VERSION }}
299+
prerelease: ${{ inputs.prerelease }}
300+
artifacts: rrr-cks*.zip
301+
owner: RROrg
302+
repo: rrr-cks
303+
token: ${{ secrets.RRORG }}

.github/workflows/modules.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,14 +117,14 @@ jobs:
117117
done
118118
119119
echo "copy 3rd modules"
120-
[ -d "${PARTY3RD_PATH}" ] && sudo cp -rf "${PARTY3RD_PATH}/." "${ROOT_PATH}/output"
120+
[ -d "${PARTY3RD_PATH}" ] && cp -rf ${PARTY3RD_PATH}/* ${ROOT_PATH}/output/
121121
122122
echo "check depends"
123123
for M in $(ls ${ROOT_PATH}/output 2>/dev/null); do
124124
function _copydepends() {
125125
if [ ! -f "${ROOT_PATH}/output/${1}" ] && [ ! -f "${OFFICIAL_PATH/hda1/rd}/${1}" ]; then
126126
if [ -f "${OFFICIAL_PATH}/${1}" ]; then
127-
sudo cp -f "${OFFICIAL_PATH}/${1}" "${ROOT_PATH}/output"
127+
cp -f "${OFFICIAL_PATH}/${1}" "${ROOT_PATH}/output"
128128
else
129129
echo "[E] '${PLATFORM}-${KVER}' - '${M}' depends '${1}' does not exist."
130130
fi
@@ -193,7 +193,7 @@ jobs:
193193
194194
echo "copy 3rd modules"
195195
PARTY3RD_PATH="${ROOT_PATH}/rrr-modules/thirdparty/firmware"
196-
cp -rf ${PARTY3RD_PATH}/* ${ROOT_PATH}/firmware/ || true
196+
[ -d "${PARTY3RD_PATH}" ] && cp -rf ${PARTY3RD_PATH}/* ${ROOT_PATH}/firmware/
197197
198198
echo "extract all modules"
199199
for F in output/*.tgz; do
@@ -206,13 +206,14 @@ jobs:
206206
SOURCE=/tmp/linux-firmware
207207
git clone --depth=1 https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git ${SOURCE}
208208
while read L; do
209+
[ -z "${L}" ] && continue
209210
if [ -e "${SOURCE}/${L}" ]; then
210211
mkdir -p "$(dirname firmware/${L})"
211212
cp -f "${SOURCE}/${L}" "firmware/${L}"
212213
else
213214
[ -e "firmware/${L}" ] && echo "Used thirdparty ${L}" || echo "Missing ${L}"
214215
fi
215-
done <<<$(find output -name \*.ko -exec sh -c '/sbin/modinfo {} | grep ^firmware' \; | awk '{print $2}')
216+
done <<<$(find output -name \*.ko -exec sh -c 'modinfo {} | grep ^firmware' \; | awk '{print $2}')
216217
217218
tar -zcf firmware.tgz -C firmware .
218219

0 commit comments

Comments
 (0)