-
Notifications
You must be signed in to change notification settings - Fork 26
384 lines (362 loc) · 17 KB
/
generate-friwrt-amlogic.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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
#=====================================================================================
#
# Description: Build OpenWrt with Image Builder
# This file is a part of the make OpenWrt for Amlogic s9xxx tv box
# https://github.com/ophub/amlogic-s9xxx-openwrt
#
# Documentation: https://openwrt.org/docs/guide-user/additional-software/imagebuilder
# Download from: https://downloads.openwrt.org/releases
# https://downloads.immortalwrt.org/releases
#
#=====================================================================================
name: Generate friWrt Amlogic Firmware
on:
workflow_dispatch:
inputs:
release_branch:
description: "Select the release branch:"
required: true
default: "openwrt:23.05.3"
type: choice
options:
- openwrt:21.02.7
- openwrt:23.05.2
- openwrt:23.05.3
- immortalwrt:21.02.7
- immortalwrt:23.05.1
- immortalwrt:23.05.2
target:
description: "Select device board"
required: false
default: "hg680p"
type: choice
options:
- all
- hg680p
- b860h
- nanopi-r5s
openwrt_kernel:
description: "Select kernel version"
required: false
default: "5.15.1_6.1.1"
type: choice
options:
- 5.4.1_5.10.1
- 5.15.1_6.1.1
- 5.4.1
- 5.10.1
- 5.15.1
- 6.1.1
auto_kernel:
description: "Auto use the latest kernel"
required: false
default: true
type: boolean
kernel_repo:
description: "Set the kernel repository"
required: false
default: "ophub/kernel"
type: choice
options:
- ophub/kernel
kernel_usage:
description: "Set the tags of the stable kernel."
required: false
default: "stable"
type: choice
options:
- stable
- flippy
- dev
- beta
tunnel:
description: "Select VPN Client app (!neko and passwall only support for newer branch with fw4 firewall!):"
required: true
default: "openclash"
type: choice
options:
- all
- openclash
- neko
- passwall
- neko-openclash
- openclash-passwall
- neko-passwall
- openclash-passwall-neko
- no-tunnel
clean:
description: "Do 'make clean' for each run"
required: false
default: "true"
type: boolean
upload-prerelease:
description: "Upload as pre-release"
required: false
default: "false"
type: boolean
revision-tag:
description: "Revision img tag"
required: false
default: "false"
type: boolean
env:
TYPE: AMLOGIC
TARGET: ${{ inputs.target }}
RELEASE_BRANCH: ${{ inputs.release_branch }}
TUNNEL: ${{ inputs.tunnel }}
CLEAN: ${{ inputs.clean }}
TZ: Asia/Jakarta
PRE_RELEASE: ${{ inputs.upload-prerelease }}
REVISION_TAG: ${{ inputs.revision-tag }}
jobs:
Generate:
name: amlogic-${{ inputs.target }}-${{ inputs.release_branch }}-${{ inputs.tunnel }}
runs-on: ubuntu-22.04
steps:
- name: Checking Tunnel Option
id: tunnelopt
run: |
if [[ ("$TUNNEL" == "neko" || "$TUNNEL" == "passwall" || "$TUNNEL" == "openclash-passwall" || "$TUNNEL" == "neko-passwall" || "$TUNNEL" == "neko-openclash" || "$TUNNEL" == "openclash-passwall-neko") && "${RELEASE_BRANCH#*:}" == "21.02.7" ]]; then
echo "Cannot continue the process because the selected tunnel [$TUNNEL]"
echo "only support for newer branch with fw4 firewall!"
exit 1
else
echo "Selected tunnel option: [$TUNNEL]"
echo "status=success" >> $GITHUB_OUTPUT
fi
- name: Initialization environment (normal)
if: github.event.inputs.target != 'all' && steps.tunnelopt.outputs.status == 'success' && !cancelled()
env:
DEBIAN_FRONTEND: noninteractive
run: |
sudo apt-get -qq update
sudo apt-get -qq install build-essential libncurses5-dev libncursesw5-dev zlib1g-dev gawk git gettext libssl-dev xsltproc rsync wget unzip tar gzip qemu-utils mkisofs
sudo timedatectl set-timezone "$TZ"
- name: Initialization environment (deep)
id: init
if: github.event.inputs.target == 'all' && steps.tunnelopt.outputs.status == 'success' && !cancelled()
env:
DEBIAN_FRONTEND: noninteractive
run: |
docker rmi $(docker images -q) 2>/dev/null
[[ -n "${AGENT_TOOLSDIRECTORY}" ]] && sudo rm -rf "${AGENT_TOOLSDIRECTORY}"
sudo rm -rf /usr/share/dotnet /etc/apt/sources.list.d /usr/local/lib/android 2>/dev/null
sudo swapoff -a
sudo rm -f /swapfile /mnt/swapfile
sudo -E apt-get -y update
sudo -E apt-get -y purge azure-cli ghc* zulu* llvm* firefox google* dotnet* powershell openjdk* mongodb* moby* || true
sudo -E apt-get -y install $(curl -fsSL https://is.gd/depend_ubuntu2204_openwrt)
sudo -E systemctl daemon-reload
#sudo -E apt-get -y full-upgrade
sudo -E apt-get -y autoremove --purge
sudo -E apt-get clean
sudo sed -i '/NVM_DIR/d;/skel/d' /root/{.bashrc,.profile}
sudo rm -rf ~/{.cargo,.dotnet,.rustup}
sudo timedatectl set-timezone "${TZ}"
echo "status=success" >> ${GITHUB_OUTPUT}
- name: Create simulated physical disk
if: github.event.inputs.target == 'all'
run: |
mnt_size=$(expr $(df -h /mnt | tail -1 | awk '{print $4}' | sed 's/[[:alpha:]]//g' | sed 's/\..*//') - 1)
root_size=$(expr $(df -h / | tail -1 | awk '{print $4}' | sed 's/[[:alpha:]]//g' | sed 's/\..*//') - 4)
sudo truncate -s "${mnt_size}"G /mnt/mnt.img
sudo truncate -s "${root_size}"G /root.img
sudo losetup /dev/loop6 /mnt/mnt.img
sudo losetup /dev/loop7 /root.img
sudo pvcreate /dev/loop6
sudo pvcreate /dev/loop7
sudo vgcreate github /dev/loop6 /dev/loop7
sudo lvcreate -n runner -l 100%FREE github
sudo mkfs.xfs /dev/github/runner
sudo mkdir -p /builder
sudo mount /dev/github/runner /builder
sudo chown -R runner.runner /builder
df -Th
- name: Checkout
uses: actions/checkout@v4
with:
path: origin
- name: Setup Environment Variables
run: |
if [ "$TARGET" == "all" ]; then
echo "openwrt_board=all" >> $GITHUB_ENV
elif [ "$TARGET" == "hg680p" ] || [ "$TARGET" == "b860h" ]; then
echo "openwrt_board=s905x" >> $GITHUB_ENV
elif [ "$TARGET" == "nanopi-r5s" ]; then
echo "openwrt_board=rk3568" >> $GITHUB_ENV
fi
if [ "$(echo "${RELEASE_BRANCH#*:}" | cut -d'.' -f1)" == "23" ]; then
echo "PROFILE=generic" >> $GITHUB_ENV
echo "TARGET_SYSTEM=armsr/armv8" >> $GITHUB_ENV
echo "TARGET_NAME=armsr-armv8" >> $GITHUB_ENV
TARGET_NAME="armsr-armv8"
echo "ARCH_1=arm64" >> $GITHUB_ENV
echo "ARCH_2=aarch64" >> $GITHUB_ENV
echo "ARCH_3=aarch64_generic" >> $GITHUB_ENV
else
echo "PROFILE=Default" >> $GITHUB_ENV
echo "TARGET_SYSTEM=armvirt/64" >> $GITHUB_ENV
echo "TARGET_NAME=armvirt-64" >> $GITHUB_ENV
TARGET_NAME="armvirt-64"
echo "ARCH_1=arm64" >> $GITHUB_ENV
echo "ARCH_2=aarch64" >> $GITHUB_ENV
echo "ARCH_3=aarch64_generic" >> $GITHUB_ENV
fi
echo "WORKING_DIR="${RELEASE_BRANCH%:*}"-imagebuilder-"$TARGET_NAME".Linux-x86_64" >> $GITHUB_ENV
echo "DOWNLOAD_BASE=https://downloads."${RELEASE_BRANCH%:*}".org" >> $GITHUB_ENV
echo "BASE=${RELEASE_BRANCH%:*}" >> $GITHUB_ENV
echo "BRANCH=${RELEASE_BRANCH#*:}" >> $GITHUB_ENV
echo "DATE=$(date +'%Y%m%d')" >> $GITHUB_ENV
echo "DATETIME=$(date +'%Y.%m.%d-%H:%M:%S')" >> $GITHUB_ENV
echo "DATEMONTH=$(date +"%B-%Y" | awk '{print tolower($0)}')" >> $GITHUB_ENV
- name: Download Image Builder
id: download
run: |
RELEASE="$DOWNLOAD_BASE/releases/$BRANCH/targets/$TARGET_SYSTEM/$BASE-imagebuilder-$BRANCH-$TARGET_NAME.Linux-x86_64.tar.xz"
wget -nv "$RELEASE"
tar -xJf *-imagebuilder-* && sync && rm -f *-imagebuilder-*.tar.xz && mv *-imagebuilder-* $WORKING_DIR && sync
cp -r $GITHUB_WORKSPACE/origin/* $GITHUB_WORKSPACE/$WORKING_DIR
if [ "$TARGET" == "all" ]; then
mkdir -p /builder/$WORKING_DIR
ln -sf /builder/$WORKING_DIR $GITHUB_WORKSPACE/$WORKING_DIR
ln -sf /builder/$WORKING_DIR /home/runner/work/_actions/ophub/amlogic-s9xxx-openwrt/main/openwrt
fi
echo "status=success" >> $GITHUB_OUTPUT
- name: Download External Packages
id: packages
if: steps.download.outputs.status == 'success' && !cancelled()
run: |
cd $WORKING_DIR
bash scripts/external-package-urls.sh
if [[ "$BRANCH" == "21.02.7" ]]; then
grep -E "^all-all|^old-21.02|^amlogic-$tags|^amlogic" external-package-urls.txt | awk '{print $2}' > output_url.txt
else
grep -E "^all-all|^all|^amlogic" external-package-urls.txt | grep -vE "^amlogic-21.02" | awk '{print $2}' > output_url.txt
fi
wget --no-check-certificate -i output_url.txt -nv -P packages
echo "status=success" >> $GITHUB_OUTPUT
- name: Run Patch and DIY Scripts
id: scripts
if: steps.packages.outputs.status == 'success' && !cancelled()
run: |
cd $WORKING_DIR
bash scripts/builder-patch.sh
bash scripts/agh-core.sh
bash scripts/misc.sh
if [[ "$TUNNEL" == "all" && "$BRANCH" != "21.02.7" ]]; then
echo "VPN Client: $TUNNEL"
bash scripts/tunnel_app.sh openclash-passwall-neko
elif [[ ("$TUNNEL" == "passwall" || "$TUNNEL" == "openclash-passwall" || "$TUNNEL" == "neko-passwall" || "$TUNNEL" == "neko-openclash" || "$TUNNEL" == "openclash-passwall-neko") && "$BRANCH" != "21.02.7" || "$TUNNEL" == "openclash" || "$TUNNEL" == "neko" ]]; then
echo "VPN Client: $TUNNEL"
bash scripts/tunnel_app.sh "$TUNNEL"
elif [[ "$TUNNEL" == "all" && "$BRANCH" = "21.02.7" ]]; then
echo "VPN Client: $TUNNEL"
bash scripts/tunnel_app.sh openclash
else
echo "No VPN Client selected"
fi
if [ "$TUNNEL" = "openclash" ] || [ "$TUNNEL" = "openclash-passwall" ]; then bash scripts/clash-core.sh; fi
if [ "$TUNNEL" = "neko" ] || [ "$TUNNEL" = "neko-passwall" ]; then bash scripts/neko_core.sh; fi
if [ "$TUNNEL" = "openclash-passwall-neko" ] || [ "$TUNNEL" == "neko-openclash" ] || [ "$TUNNEL" = "all" ]; then bash scripts/clash-core.sh; bash scripts/neko_core.sh; fi
echo "Total custom packages: $(find packages -type f -name "*.ipk" | wc -l)"
ls packages
echo "status=success" >> $GITHUB_OUTPUT
echo -e "Server space usage before starting to compile: \n$(df -hT ${PWD}) \n"
- name: Build Rootfs ${{ inputs.release_branch }}
id: compile
if: steps.scripts.outputs.status == 'success' && !cancelled()
run: |
cd $WORKING_DIR
mkdir -p compiled_images
if [[ "$TUNNEL" == "all" && "$BRANCH" != "21.02.7" ]]; then
for t in openclash-passwall neko-passwall neko-openclash openclash-passwall-neko openclash passwall neko no-tunnel; do
echo "Compiling with VPN Client: $t"
if [ "$CLEAN" == "true" ]; echo "Start 'make clean' before building images."; then make clean; fi
time bash make-build.sh $PROFILE $t
for file in bin/targets/"$TARGET_SYSTEM"/*rootfs.tar.gz; do mv "$file" compiled_images; done
done
elif [[ "$TUNNEL" == "all" && "$BRANCH" = "21.02.7" ]]; then
for t in openclash no-tunnel; do
echo "Compiling with VPN Client: $t"
if [ "$CLEAN" == "true" ]; echo "Start 'make clean' before building images."; then make clean; fi
time bash make-build.sh $PROFILE $t
for file in bin/targets/"$TARGET_SYSTEM"/*rootfs.tar.gz; do mv "$file" compiled_images; done
done
elif [[ ("$TUNNEL" == "neko" || "$TUNNEL" == "passwall" || "$TUNNEL" == "openclash-passwall" || "$TUNNEL" == "neko-passwall" || "$TUNNEL" == "neko-openclash" || "$TUNNEL" == "openclash-passwall-neko") && "$BRANCH" != "21.02.7" || "$TUNNEL" == "openclash" || "$TUNNEL" == "no-tunnel" ]]; then
echo "Compiling with VPN Client: $TUNNEL"
bash make-build.sh $PROFILE $TUNNEL
for file in bin/targets/"$TARGET_SYSTEM"/*rootfs.tar.gz; do mv "$file" compiled_images; done
fi
ls -l compiled_images
echo "status=success" >> $GITHUB_OUTPUT
echo -e "Server space usage after compilation: \n$(df -hT ${PWD}) \n"
- name: Clear server space
if: ${{ steps.imagebuilder.outputs.status }} == 'success' && !cancelled()
run: |
cd $WORKING_DIR
rm -rf $(ls . | grep -vE "^compiled_images$|^changelog_amlogic.md$" | xargs) 2>/dev/null
df -hT ${PWD}
- name: Packaging ${{ inputs.release_branch }}
if: ${{ steps.imagebuilder.outputs.status }} == 'success' && !cancelled()
uses: ophub/amlogic-s9xxx-openwrt@main
with:
openwrt_path: $WORKING_DIR/compiled_images/*rootfs.tar.gz
openwrt_board: ${{ env.openwrt_board }}
openwrt_kernel: ${{ inputs.openwrt_kernel }}
auto_kernel: ${{ inputs.auto_kernel }}
kernel_repo: ${{ inputs.kernel_repo }}
kernel_usage: ${{ inputs.kernel_usage }}
builder_name: friWrt
- name: Prepare file before upload
if: ${{ env.PACKAGED_STATUS }} == 'success' && !cancelled()
id: prep_upload
run: |
cd $WORKING_DIR
for file in compiled_images/*rootfs.tar.gz; do mv "$file" ${{ env.PACKAGED_OUTPUTPATH }}; done
cd ${{ env.PACKAGED_OUTPUTPATH }}
for file in *.img.gz; do mv "$file" fri_$(basename "$file" .img.gz)$( echo "_$TUNNEL" )$([ "$REVISION_TAG" == "true" ] && echo _rev).img.gz; done
for file in *rootfs.tar.gz; do mv "$file" fri_$(basename "$file" .tar.gz)$( echo "_$TUNNEL" )$([ "$REVISION_TAG" == "true" ] && echo _rev).tar.gz; done
if wget -q https://github.com/frizkyiman/friWrt-MyWrtBuilder/releases/download/amlogic-${{ env.openwrt_board }}-${{ env.BASE }}-${{ env.BRANCH }}-${{ env.DATEMONTH }}/sha256sums; then
rm -r *.sha && sha256sum *.gz >> sha256sums
else
rm -r *.sha && sha256sum *.gz > sha256sums
fi
ls -l
echo "status=success" >> $GITHUB_OUTPUT
- name: Add changelog info and set tag name to new release
if: ${{ env.PACKAGED_STATUS }} == 'success' && !cancelled()
id: changelog
shell: bash
run: |
cd $WORKING_DIR
echo "RELEASE_TAG=amlogic-${{ env.openwrt_board }}-$BASE-$BRANCH-$DATEMONTH$([ "$REVISION_TAG" == "true" ] && echo -rev)" >> $GITHUB_ENV
r=$(awk '/^\*\*Changelog\*\*/ {if(found) exit; found=1} found' changelog_amlogic.md)
r="${r//'%'/'%25'}"
r="${r//$'\n'/'%0A'}"
r="${r//$'\r'/'%0D'}"
echo "CHANGELOG=$r" >> $GITHUB_OUTPUT
- name: Upload Firmware to Release
uses: svenstaro/upload-release-action@v2
if: ${{ steps.prep_upload.outputs.status }} == 'success' && !cancelled()
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file_glob: true
file: ${{ env.PACKAGED_OUTPUTPATH }}/*
asset_name: ${{ github.event.repository.name }}-${{ github.sha }}
tag: ${{ env.RELEASE_TAG }}
release_name: ${{ env.RELEASE_TAG }}
overwrite: true
prerelease: ${{ env.PRE_RELEASE }}
body: |
![GitHub Downloads (all assets, specific tag)](https://img.shields.io/github/downloads/frizkyiman/friWrt-MyWrtBuilder/${{ env.RELEASE_TAG }}/total?style=for-the-badge&logo=Openwrt)
### friWrt ${{ env.BASE }}-${{ env.BRANCH }} Image information
Build date: ${{ env.DATETIME }}
${{ steps.changelog.outputs.CHANGELOG }}
See [here](https://github.com/frizkyiman/friWrt-MyWrtBuilder?tab=readme-ov-file#firmware-details) for more detail feature and other information.
- Default IP: 192.168.1.1
- Default username: root
- Default password: friwrt
- Default WIFI name: friWrt_2g | friWrt_5g (if device supported)
- Default WIFI password: friwrt2024 (if device supported)
### Install to EMMC
- Login to OpenWrt → System → Amlogic Service → Install OpenWrt