-
Notifications
You must be signed in to change notification settings - Fork 2
201 lines (184 loc) · 9.31 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
name: Check firmware update
on:
workflow_dispatch:
schedule:
- cron: "0 12 * * *"
push:
jobs:
update:
runs-on: ubuntu-latest
strategy:
fail-fast: false
max-parallel: 2
matrix:
include:
- model: "SM-N976N"
region: "KOO"
codename: "d2xks"
- model: "SM-N971N"
region: "KOO"
codename: "d1xks"
- model: "SM-N976B"
region: "XEU"
codename: "d2x"
- model: "SM-N970F"
region: "DBT"
codename: "d1"
- model: "SM-N975F"
region: "DBT"
codename: "d2s"
steps:
- name: Checkout repo
uses: actions/checkout@v3
with:
submodules: true
- name: Compare latest version with current version
id: check
run: |
need_update=0
latest=`curl --retry 5 --retry-delay 5 http://fota-cloud-dn.ospserver.net/firmware/${{ matrix.region }}/${{ 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 }}` || 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: Install dependencies
if: env.need_update == 1
run: |
sudo apt-get update
sudo apt-get install -y liblz4-tool zip
sudo wget -O /usr/bin/dtc https://corsica.nu/dtc && sudo chmod +x /usr/bin/dtc
sudo wget -O /usr/bin/mkdtimg https://corsica.nu/mkdtimg && sudo chmod +x /usr/bin/mkdtimg
sudo wget -O /usr/bin/splitdt https://corsica.nu/splitdt && sudo chmod +x /usr/bin/splitdt
sudo wget -O /usr/bin/unpackbootimg https://corsica.nu/unpackbootimg && sudo chmod +x /usr/bin/unpackbootimg
sudo wget -O /usr/bin/extract-ikconfig https://corsica.nu/extract-ikconfig && sudo chmod +x /usr/bin/extract-ikconfig
sudo wget -O /usr/bin/samfirm https://github.com/ananjaser1211/SamFirm.NET/releases/latest/download/linux-x64 && sudo chmod +x /usr/bin/samfirm
- name: Fetch firmware
if: env.need_update == 1
run: samfirm -m ${{ matrix.model }} -r ${{ matrix.region }}
- name: Print directory structure
if: env.need_update == 1
run: ls -la ${{ matrix.model }}_${{ matrix.region }}
- name: Get path of files
if: env.need_update == 1
id: files
run: |
echo "bl=`find -name BL*`" >> $GITHUB_ENV
echo "ap=`find -name AP*`" >> $GITHUB_ENV
echo "cp=`find -name CP*`" >> $GITHUB_ENV
echo "csc=`find -name HOME_CSC*`" >> $GITHUB_ENV
- name: Check downloaded firmware version
if: env.need_update == 1
run: |
version_short=`echo ${{ env.ap }} | cut -d'_' -f3`
version_csc=`echo ${{ env.csc }} | cut -d'_' -f5`
version_modem=`echo ${{ env.cp }} | cut -d'_' -f3`
changelist=`echo ${{ env.ap }} | cut -d'_' -f4`
[[ $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
echo Changelist: $changelist >> versions.txt
- name: Print available disk space
if: env.need_update == 1
run: |
pwd
sudo df -h
- name: Create zip environment
if: env.need_update == 1
run: |
target_device=`echo ${{ matrix.model }} | cut -d'-' -f2`
target_version=${{ env.latest_shortversion }}
mkdir -p $target_version configs tmp
cp -r bootloader_modem $target_version
cp -r device_tree $target_version
sed -i "s/target_device/$target_device/g" $target_version/bootloader_modem/META-INF/com/google/android/updater-script
sed -i "s/target_version/$target_version/g" $target_version/bootloader_modem/META-INF/com/google/android/updater-script
sed -i "s/target_device/$target_device/g" $target_version/device_tree/META-INF/com/google/android/updater-script
sed -i "s/target_version/$target_version/g" $target_version/device_tree/META-INF/com/google/android/updater-script
if echo $target_device | grep N97[05]F; then sed -i '/modem_5g/d' $target_version/bootloader_modem/META-INF/com/google/android/updater-script;fi
- name: Extract images from AP/BL, dump configs and create zips
if: env.need_update == 1
id: releases
run: |
target_version=${{ env.latest_shortversion }}
bls=(cm.bin dt.img dtbo.img keystorage.bin modem.bin modem_5g.bin sboot.bin uh.bin up_param.bin)
tar xvf ${{ env.ap }} dt.img.lz4 dtbo.img.lz4 boot.img.lz4 recovery.img.lz4
tar xvf ${{ env.bl }}
tar xvf ${{ env.cp }}
for i in `ls | grep lz4`; do lz4 -dm $i ; rm -rf $i; done
extract-ikconfig boot.img > configs/exynos9820-${{ matrix.codename }}_defconfig
cd tmp
unpackbootimg -i ../boot.img >> ../configs/bootimg.args && mkdtimg dump ../dt.img >> ../configs/exynos9825.cfg
splitdt ../dt.img && dtc dtbdump_* -I dtb -O dts -o ../configs/exynos9825.dts && rm -rf *
mkdtimg dump ../dtbo.img >> ../configs/${{ matrix.codename }}.cfg && splitdt ../dtbo.img
for i in `ls | grep dtbdump_`; do dtc $i -I dtb -O dts -o $i.txt; done
for i in `ls | grep txt`;
do mv $i ../configs/$(cat $i | grep "model =" | sed 's/Samsung //; s/\t//g; s/\"//g; s/model = //; s/\;//' | awk '{print tolower($8"-"$1"_"$2"_"$3"_"$4".dts")}');
done
cd ../configs
for i in `ls | grep dts`; do sed -i 's/ /\t/g; s/0x0/0x/g; s/0x0/0x/g; s/0x0/0x/g; s/0x0/0x/g; s/0x0/0x/g; s/0x0/0x/g; s/0x0/0x/g; s/0x0/0x/g; s/0x0/0x/g; s/0x0/0x/g; s/0x0/0x/g; s/0x0/0x/g; s/0x0/0x/g; s/0x0/0x/g; s/0x0/0x/g; s/0x0/0x/g; s/0x0/0x/g; s/0x0/0x/g; s/0x0/0x/g; s/0x0/0x/g; s/0x;/0x0;/g; s/0x>/0x0>/g; s/0x /0x0 /g; s/\\0/\", \"/g' $i; done;
zip -r ../$target_version-configs.zip *
cd ..
mv boot.img $target_version-stock_boot.img
mv recovery.img $target_version-stock_recovery.img
bls=(cm.bin keystorage.bin modem.bin modem_5g.bin sboot.bin uh.bin up_param.bin)
for i in ${bls[@]}; do [[ -e $i ]] && mv $i $target_version/bootloader_modem/$i; done
cd $target_version/bootloader_modem
zip -r ../../$target_version-bootloader_modem-twrp_flashable.zip *
rm -rf META-INF
tar cvf ../../$target_version-bootloader_modem-odin_flashable.tar *
cd ../../
dts=(dt.img dtbo.img)
for i in ${dts[@]}; do [[ -e $i ]] && mv $i $target_version/device_tree/$i; done
cd $target_version/device_tree
zip -r ../../$target_version-device_tree-twrp_flashable.zip *
rm -rf META-INF
tar cvf ../../$target_version-device_tree-odin_flashable.tar *
cd ../../
echo "blzip=`find -name $target_version-bootloader_modem-twrp_flashable.zip`" >> $GITHUB_ENV
echo "bltar=`find -name $target_version-bootloader_modem-odin_flashable.tar`" >> $GITHUB_ENV
echo "dtzip=`find -name $target_version-device_tree-twrp_flashable.zip`" >> $GITHUB_ENV
echo "dttar=`find -name $target_version-device_tree-odin_flashable.tar`" >> $GITHUB_ENV
echo "boot=`find -name $target_version-stock_boot.img`" >> $GITHUB_ENV
echo "recovery=`find -name $target_version-stock_recovery.img`" >> $GITHUB_ENV
echo "configs=`find -name $target_version-configs.zip`" >> $GITHUB_ENV
- 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 }}
git add current.${{ matrix.model }}
git commit -m "${{ matrix.model }}: ${{ env.latest_version }}"
git tag ${{ env.latest_shortversion }}
- name: Push changes to repo
if: env.need_update == 1
uses: ad-m/github-push-action@master
with:
tags: true
github_token: ${{ secrets.TOKEN }}
- name: Upload release assets
if: env.need_update == 1
uses: CaptainThrowback/action-gh-release@master
env:
GITHUB_TOKEN: ${{ secrets.TOKEN }}
with:
body_path: versions.txt
tag_name: ${{ env.latest_shortversion }}
files: |
${{ env.blzip }}
${{ env.bltar }}
${{ env.dtzip }}
${{ env.dttar }}
${{ env.boot }}
${{ env.recovery }}
${{ env.configs }}