This repository has been archived by the owner on May 8, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
180 lines (166 loc) · 6.81 KB
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
name: Build image
on:
push:
branches:
- main
tags:
- v*
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
# 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') }}
# Install dependencies
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y libelf-dev qemu-utils
sudo cp -f files/board/arpl/overlayfs/usr/bin/yq /usr/bin/yq
# Get latests LKM, addons and modules
- name: Get latests LKM, addons and Modules
run: |
# Get latest LKMs
echo "Getting latest LKMs"
TAG=`curl -s https://api.github.com/repos/fbelavenuto/redpill-lkm/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3)}'`
STATUS=`curl -w "%{http_code}" -L "https://github.com/fbelavenuto/redpill-lkm/releases/download/${TAG}/rp-lkms.zip" -o /tmp/rp-lkms.zip`
echo "Status=${STATUS}"
[ ${STATUS} -ne 200 ] && exit 1
# Get latest addons and install its
echo "Getting latest Addons"
TAG=`curl -s https://api.github.com/repos/fbelavenuto/arpl-addons/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3)}'`
STATUS=`curl -w "%{http_code}" -L "https://github.com/fbelavenuto/arpl-addons/releases/download/${TAG}/addons.zip" -o /tmp/addons.zip`
echo "Status=${STATUS}"
[ ${STATUS} -ne 200 ] && exit 1
# Get latest modules
echo "Getting latest modules"
MODULES_DIR="files/board/arpl/p3/modules"
TAG=`curl -s https://api.github.com/repos/fbelavenuto/arpl-modules/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3)}'`
while read PLATFORM KVER; do
FILE="${PLATFORM}-${KVER}"
STATUS=`curl -w "%{http_code}" -L "https://github.com/fbelavenuto/arpl-modules/releases/download/${TAG}/${FILE}.tgz" -o "${MODULES_DIR}/${FILE}.tgz"`
echo "Status=${STATUS}"
[ ${STATUS} -ne 200 ] && exit 1
done < PLATFORMS
STATUS=`curl -w "%{http_code}" -L "https://github.com/fbelavenuto/arpl-modules/releases/download/${TAG}/firmware.tgz" -o "${MODULES_DIR}/firmware.tgz"`
echo "Status=${STATUS}"
[ ${STATUS} -ne 200 ] && exit 1
echo OK
# 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
# Build incremental from caches
- name: Build image
id: build
run: |
VERSION=`<VERSION`
echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT
# 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
# Unzip LKMs
rm -rf files/board/arpl/p3/lkms/*
unzip /tmp/rp-lkms.zip -d files/board/arpl/p3/lkms
# 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} | sed 's|.addon||'`
mkdir -p "${DEST_PATH}/${ADDON}"
echo "Extracting ${PKG} to ${DEST_PATH}/${ADDON}"
tar xaf "${PKG}" -C "${DEST_PATH}/${ADDON}"
done
# Copy files
echo "Copying files"
sed 's/^ARPL_VERSION=.*/ARPL_VERSION="'${VERSION}'"/' -i files/board/arpl/overlayfs/opt/arpl/include/consts.sh
echo "${VERSION}" > files/board/arpl/p1/ARPL-VERSION
cp -Ru files/* .buildroot/
cd .buildroot
echo "Generating default config"
make BR2_EXTERNAL=../external arpl_defconfig
echo "Version: ${VERSION}"
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
# Zip image and generate checksum
- name: Pack
shell: bash
run: |
zip -9 "arpl-${{ steps.build.outputs.VERSION }}.img.zip" arpl.img
zip -9 "arpl-${{ steps.build.outputs.VERSION }}.vmdk-dyn.zip" arpl-dyn.vmdk
zip -9 "arpl-${{ steps.build.outputs.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
# Upload artifact
- name: Upload
uses: actions/upload-artifact@v3
with:
name: Images
path: |
arpl.img
arpl*.vmdk
retention-days: 5
# Publish a release if is a tag
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
arpl-${{ steps.build.outputs.VERSION }}.img.zip
arpl-${{ steps.build.outputs.VERSION }}.vmdk-dyn.zip
arpl-${{ steps.build.outputs.VERSION }}.vmdk-flat.zip
update.zip