-
Notifications
You must be signed in to change notification settings - Fork 0
207 lines (183 loc) · 7.51 KB
/
check.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
name: Check firmware update
on:
workflow_dispatch:
schedule:
- cron: "0 12 * * *"
push:
jobs:
update:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
# GTS9FE_EUR_OPEN
- model: "SM-X516B"
csc: "EUX"
omc: "OXM"
imei: 354136921234567
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
submodules: true
- name: Compare latest version with current version
run: |
need_update=0
latest=`curl --retry 5 --retry-delay 5 http://fota-cloud-dn.ospserver.net/firmware/${{ matrix.csc }}/${{ matrix.model }}/version.xml | grep latest | sed 's/^[^>]*>//' | sed 's/<.*//'`
latest_short=`echo $latest | cut -d'/' -f1`
latest_csc=`echo $latest | cut -d'/' -f2`
latest_modem=`echo $latest | cut -d'/' -f3`
current=`cat current.${{ matrix.model }}_${{ matrix.omc }}` || need_update=1
[[ $latest != $current ]] && need_update=1
echo "latest_version=$latest" >> $GITHUB_ENV
echo "latest_shortversion=$latest_short" >> $GITHUB_ENV
echo "latest_cscversion=$latest_csc" >> $GITHUB_ENV
echo "latest_modemversion=$latest_modem" >> $GITHUB_ENV
echo "need_update=$need_update" >> $GITHUB_ENV
- name: Set up Node.js
if: env.need_update == 1
uses: actions/setup-node@v4
with:
node-version: 'latest'
- name: Set up Python 3
if: env.need_update == 1
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install dependencies
if: env.need_update == 1
run: |
sudo apt-get update
sudo apt-get install -y liblz4-tool zip simg2img f2fs-tools
sudo wget -O /usr/bin/samfirm https://github.com/DavidArsene/samfirm.js/releases/download/v0.3.0/samfirm.js && sudo chmod +x /usr/bin/samfirm
- name: Fetch firmware
if: env.need_update == 1
run:
samfirm -m ${{ matrix.model }} -r ${{ matrix.csc }} -i ${{ matrix.imei }}
- name: Get path of files
if: env.need_update == 1
run: |
echo "ap_tar=`find -name AP*`" >> $GITHUB_ENV
echo "bl_tar=`find -name BL*`" >> $GITHUB_ENV
echo "cp_tar=`find -name CP*`" >> $GITHUB_ENV
echo "csc_tar=`find -name CSC*`" >> $GITHUB_ENV
echo "home_csc_tar=`find -name HOME_CSC*`" >> $GITHUB_ENV
- name: Check downloaded firmware version
if: env.need_update == 1
run: |
version_short=`echo ${{ env.ap_tar }} | cut -d'_' -f3`
version_csc=`echo ${{ env.csc_tar }} | cut -d'_' -f4`
version_modem=`echo ${{ env.cp_tar }} | cut -d'_' -f3`
[[ $version_short == ${{ env.latest_shortversion }} ]]
[[ $version_csc == ${{ env.latest_cscversion }} ]]
[[ $version_modem == ${{ env.latest_modemversion }} ]]
echo PDA version: $version_short > versions.txt
echo CSC version: $version_csc >> versions.txt
echo Modem version: $version_modem >> versions.txt
- name: Cleanup space
if: env.need_update == 1
run: |
sudo apt-get remove --purge -y "php*" "dotnet*" "mysql*" "nodejs*" "clang*" "google*"
sudo apt-get autoremove -y
sudo apt-get clean
sudo rm -rf /usr/local
- name: Extract kernel images
if: env.need_update == 1
env:
FILES: boot.img.lz4 dtbo.img.lz4 init_boot.img.lz4 vbmeta.img.lz4 vendor_boot.img.lz4
run: |
for file in $FILES; do tar xvf ${{ env.ap_tar }} ${file}; done
tar cvf ${{ env.latest_shortversion }}_kernel.tar *.lz4
rm *.lz4
- name: Extract PIT file
if: env.need_update == 1
run: |
tar --wildcards --exclude='*/*' -xvf ${{ env.csc_tar }} '*.pit'
echo "pit_file=`find -name *.pit`" >> $GITHUB_ENV
- name: Generate patched vbmeta
if: env.need_update == 1
run: |
tar xvf ${{ env.ap_tar }} vbmeta.img.lz4
lz4 -d vbmeta.img.lz4 vbmeta.img
rm vbmeta.img.lz4
printf "$(printf '\\x%02X' 3)" | dd of="vbmeta.img" bs=1 seek=123 count=1 conv=notrunc &> /dev/null
tar cvf ${{ env.latest_shortversion }}_patched_vbmeta.tar vbmeta.img
rm vbmeta.img
- name: Extract vendor and vendor_dlkm partition
if: env.need_update == 1
run: |
tar xvf ${{ env.ap_tar }} super.img.lz4
lz4 -d super.img.lz4 super.img
rm super.img.lz4
simg2img super.img super_raw.img
rm super.img
mv super_raw.img super.img
python3 tools/bin/lpunpack.py -p vendor,vendor_dlkm super.img .
rm super.img
[[ -e vendor.img ]] && zip ${{ env.latest_shortversion }}_vendor.zip vendor.img
[[ -e vendor_dlkm.img ]] && zip ${{ env.latest_shortversion }}_vendor_dlkm.zip vendor_dlkm.img
[[ -e vendor.img ]] && rm vendor.img
[[ -e vendor_dlkm.img ]] && rm vendor_dlkm.img
- name: Extract boot partition
if: env.need_update == 1
run: |
tar xvf ${{ env.ap_tar }} boot.img.lz4
lz4 -d boot.img.lz4 boot.img
rm boot.img.lz4
- name: Extract vendor_boot partition
if: env.need_update == 1
run: |
tar xvf ${{ env.ap_tar }} vendor_boot.img.lz4
lz4 -d vendor_boot.img.lz4 vendor_boot.img
rm vendor_boot.img.lz4
- name: Extract init_boot partition
if: env.need_update == 1
run: |
tar xvf ${{ env.ap_tar }} init_boot.img.lz4
lz4 -d init_boot.img.lz4 init_boot.img
rm init_boot.img.lz4
- name: Extract dtbo partition
if: env.need_update == 1
run: |
tar xvf ${{ env.ap_tar }} dtbo.img.lz4
lz4 -d dtbo.img.lz4 dtbo.img
rm dtbo.img.lz4
- name: Update current version
if: env.need_update == 1
run: |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git pull origin ${{github.ref}} --ff-only
echo ${{ env.latest_version }} > current.${{ matrix.model }}_${{ matrix.omc }}
git add current.${{ matrix.model }}_${{ matrix.omc }}
git commit -m "${{ matrix.model }}: ${{ env.latest_version }}"
git tag "${{ env.latest_shortversion }}_${{ matrix.omc }}"
- name: Push changes to repo
if: env.need_update == 1
uses: ad-m/github-push-action@master
with:
tags: true
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Upload release assets
if: env.need_update == 1
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
body_path: versions.txt
tag_name: "${{ env.latest_shortversion }}_${{ matrix.omc }}"
name: "${{ env.latest_shortversion }} - ${{ matrix.model }} - ${{ matrix.omc }}"
files: |
${{ env.bl_tar }}
${{ env.cp_tar }}
${{ env.home_csc_tar }}
${{ env.latest_shortversion }}_kernel.tar
${{ env.pit_file }}
${{ env.latest_shortversion }}_patched_vbmeta.tar
${{ env.latest_shortversion }}_vendor.zip
boot.img
vendor_boot.img
init_boot.img
dtbo.img
${{ env.latest_shortversion }}_vendor_dlkm.zip