-
Notifications
You must be signed in to change notification settings - Fork 89
executable file
·419 lines (404 loc) · 20.4 KB
/
ci.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
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
name: a1to5x
on:
workflow_dispatch:
inputs:
mode:
description: 'Download mode(aria2c,curl,axel,wget)'
required: true
default: 'aria2c'
output:
description: 'Output(wget=O)'
required: true
default: 'o'
filename:
description: 'ROM NAME(Optional)'
filelink:
description: 'ROM LINK(Support gdrive link)'
required: true
release:
description: 'Upload ROM to Release(Please set the token)'
required: true
default: 'true'
anon:
description: 'Upload ROM to Anonfile'
required: true
default: 'false'
we:
description: 'Upload ROM to WeTransfer'
required: true
default: 'false'
muse:
description: 'Upload ROM to MuseTransfer'
required: true
default: 'false'
fstab:
description: 'Fstab Patching Mode(Default)'
required: true
default: 'dd'
flags:
description: 'Flags(Default)'
required: true
default: 'true'
jobs:
a1to5x:
runs-on: ubuntu-20.04
continue-on-error: false
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Initialization environment
run: |
sudo apt-get update -y
sudo apt-get install -y git wget curl aria2 python python3 python3-setuptools unzip axel cpio file
pip3 install protobuf
pip3 install gdown
- id: var
name: Download
run: |
echo "Download"
if [[ ${{ github.event.inputs.filelink }} == *"drive.google.com"* ]]; then
if [[ ${{ github.event.inputs.filelink }} == *"file"* ]]; then
DOWNLOAD_LINK=$(echo ${{ github.event.inputs.filelink }} | cut -d / -f 6)
echo "DOWNLOAD_LINK: $DOWNLOAD_LINK"
gdown https://drive.google.com/uc?id=${DOWNLOAD_LINK}
elif [[ ${{ github.event.inputs.filelink }} == *"id"* ]]; then
DOWNLOAD_LINK1=$(echo ${{ github.event.inputs.filelink }} | cut -d = -f 2 | cut -d '&' -f 1)
DOWNLOAD_LINK2=$(echo ${{ github.event.inputs.filelink }} | cut -d = -f 4)
echo "DOWNLOAD_LINK1: $DOWNLOAD_LINK1"
echo "DOWNLOAD_LINK2: $DOWNLOAD_LINK2"
gdown https://drive.google.com/uc?id=${DOWNLOAD_LINK1} || gdown https://drive.google.com/uc?id=${DOWNLOAD_LINK2}
fi
else
if [[ ! -z "${{ github.event.inputs.filename }}" ]]; then
FILENAME="${{ github.event.inputs.filename }}"
${{ github.event.inputs.mode }} ${{ github.event.inputs.filelink }} -${{ github.event.inputs.output }} "$FILENAME"
else
${{ github.event.inputs.mode }} ${{ github.event.inputs.filelink }}
fi
fi
ls
FILENAME="$(find . -size +100M -exec ls -lS {} \+ | head -1 | awk '{print $9}')"
if [[ -z "$FILENAME" ]]; then
exit 1
echo "The file was not downloaded successfully"
fi
echo "FILENAME: $FILENAME"
FILENAME=$(basename ${FILENAME})
NAME=$(basename $FILENAME .zip)
echo "filename=$FILENAME" >> $GITHUB_OUTPUT
echo "name=$NAME" >> $GITHUB_OUTPUT
- name: Payload Extracting
run: |
echo "Payload Extracting"
echo "filename: ${{ steps.var.outputs.filename }}"
unzip ${{ steps.var.outputs.filename }} payload.bin
rm -rf ${{ steps.var.outputs.filename }}
python3 update-payload-extractor/extract.py payload.bin --output_dir output/
rm -rf payload.bin
ls
- name: Fstab Patching
run: |
echo "system"
echo "**************************************"
ls -al
echo "**************************************"
ls -al output/system.img
sudo mkdir system
sudo mount output/system.img system
sudo du -sb system
cat system/system/vendor/etc/fstab.qcom
sudo cp -f system/system/vendor/etc/fstab.qcom fstab.qcom
fstab="system/system/vendor/etc/fstab.qcom"
echo "**************************************"
ls -al $fstab
echo "**************************************"
if [[ "${{ github.event.inputs.fstab }}" == "i" ]]; then
sudo sed -i 's/,slotselect//g' $fstab
sudo sed -i 's/,verify//g' $fstab
sudo sed -i 's/,avb//g' $fstab
sudo sed -i 's/forceencrypt/encryptable/g' $fstab
sudo sed -i 's/fileencryption=ice/encryptable=footer/g' $fstab
if [[ "${{ github.event.inputs.flags }}" == "true" ]]; then
sudo sed -i '/mnt_point/{n;/system/d;}' $fstab
sudo sed -i '/mnt_point/a\/dev/block/bootdevice/by-name/system /system ext4 ro wait,recoveryonly' $fstab
sudo sed -i '/mnt_point/G' $fstab
sudo sed -i '/mnt_point/a\/dev/block/bootdevice/by-name/recovery /recovery emmc defaults defaults' $fstab
sudo sed -i '/mnt_point/a\/dev/block/bootdevice/by-name/boot /boot emmc defaults defaults' $fstab
sudo sed -i '/persist/i\/dev/block/bootdevice/by-name/cache /cache f2fs nosuid,nodev,noatime,inline_xattr,flush_merge,data_flush wait,formattable,check' $fstab
sudo sed -i '/cache/a\/dev/block/bootdevice/by-name/cache /cache ext4 nosuid,nodev,noatime wait,formattable,check' $fstab
sudo sed -i '/modem/d' $fstab
sudo sed -i '/misc/i\/dev/block/bootdevice/by-name/modem /vendor/firmware_mnt vfat ro,context=u:object_r:firmware_file:s0,shortname=lower,uid=1000,gid=1000,dmask=227,fmask=337 wait' $fstab
fi
elif [[ "${{ github.event.inputs.fstab }}" == "dd" ]]; then
sudo chmod 777 $fstab
num_bytes=$(sudo sed 's/,slotselect//g' $fstab | wc -c)
sudo sed 's/,slotselect//g' $fstab 1<> $fstab
sudo dd if=/dev/null of=$fstab bs="$num_bytes" seek=1
echo "---------------------"
num_bytes=$(sudo sed 's/,verify//g' $fstab | wc -c)
sudo sed 's/,verify//g' $fstab 1<> $fstab
sudo dd if=/dev/null of=$fstab bs="$num_bytes" seek=1
echo "---------------------"
num_bytes=$(sudo sed 's/,avb//g' $fstab | wc -c)
sudo sed 's/,avb//g' $fstab 1<> $fstab
sudo dd if=/dev/null of=$fstab bs="$num_bytes" seek=1
echo "---------------------"
num_bytes=$(sudo sed 's/forceencrypt/encryptable/g' $fstab | wc -c)
sudo sed 's/forceencrypt/encryptable/g' $fstab 1<> $fstab
sudo dd if=/dev/null of=$fstab bs="$num_bytes" seek=1
echo "---------------------"
num_bytes=$(sudo sed 's/fileencryption=ice/encryptable=footer/g' $fstab | wc -c)
sudo sed 's/fileencryption=ice/encryptable=footer/g' $fstab 1<> $fstab
sudo dd if=/dev/null of=$fstab bs="$num_bytes" seek=1
echo "---------------------"
if [[ "${{ github.event.inputs.flags }}" == "true" ]]; then
num_bytes=$(sudo sed '/mnt_point/{n;/system/d;}' $fstab | wc -c)
sudo sed '/mnt_point/{n;/system/d;}' $fstab 1<> $fstab
sudo dd if=/dev/null of=$fstab bs="$num_bytes" seek=1
echo "---------------------"
num_bytes=$(sudo sed '/mnt_point/a\/dev/block/bootdevice/by-name/system /system ext4 ro wait,recoveryonly' $fstab | wc -c)
sudo sed '/mnt_point/a\/dev/block/bootdevice/by-name/system /system ext4 ro wait,recoveryonly' $fstab 1<> $fstab
sudo dd if=/dev/null of=$fstab bs="$num_bytes" seek=1
echo "---------------------"
num_bytes=$(sudo sed '/mnt_point/G' $fstab | wc -c)
sudo sed '/mnt_point/G' $fstab 1<> $fstab
sudo dd if=/dev/null of=$fstab bs="$num_bytes" seek=1
echo "---------------------"
num_bytes=$(sudo sed '/mnt_point/a\/dev/block/bootdevice/by-name/recovery /recovery emmc defaults defaults' $fstab | wc -c)
sudo sed '/mnt_point/a\/dev/block/bootdevice/by-name/recovery /recovery emmc defaults defaults' $fstab 1<> $fstab
sudo dd if=/dev/null of=$fstab bs="$num_bytes" seek=1
echo "---------------------"
num_bytes=$(sudo sed '/mnt_point/a\\n/dev/block/bootdevice/by-name/boot /boot emmc defaults defaults' $fstab | wc -c)
sudo sed '/mnt_point/a\/dev/block/bootdevice/by-name/boot /boot emmc defaults defaults' $fstab 1<> $fstab
sudo dd if=/dev/null of=$fstab bs="$num_bytes" seek=1
echo "---------------------"
num_bytes=$(sudo sed '/persist/i\/dev/block/bootdevice/by-name/cache /cache f2fs nosuid,nodev,noatime,inline_xattr,flush_merge,data_flush wait,formattable,check' $fstab | wc -c)
sudo sed '/persist/i\/dev/block/bootdevice/by-name/cache /cache f2fs nosuid,nodev,noatime,inline_xattr,flush_merge,data_flush wait,formattable,check' $fstab 1<> $fstab
sudo dd if=/dev/null of=$fstab bs="$num_bytes" seek=1
echo "---------------------"
num_bytes=$(sudo sed '/cache/a\\n/dev/block/bootdevice/by-name/cache /cache ext4 nosuid,nodev,noatime wait,formattable,check' $fstab | wc -c)
sudo sed '/cache/a\/dev/block/bootdevice/by-name/cache /cache ext4 nosuid,nodev,noatime wait,formattable,check' $fstab 1<> $fstab
sudo dd if=/dev/null of=$fstab bs="$num_bytes" seek=1
echo "---------------------"
num_bytes=$(sudo sed '/modem/d' $fstab | wc -c)
sudo sed '/modem/d' $fstab 1<> $fstab
sudo dd if=/dev/null of=$fstab bs="$num_bytes" seek=1
echo "---------------------"
num_bytes=$(sudo sed '/dsp/a\/dev/block/bootdevice/by-name/modem /vendor/firmware_mnt vfat ro,context=u:object_r:firmware_file:s0,shortname=lower,uid=1000,gid=1000,dmask=227,fmask=337 wait' $fstab | wc -c)
sudo sed '/dsp/a\/dev/block/bootdevice/by-name/modem /vendor/firmware_mnt vfat ro,context=u:object_r:firmware_file:s0,shortname=lower,uid=1000,gid=1000,dmask=227,fmask=337 wait' $fstab 1<> $fstab
sudo dd if=/dev/null of=$fstab bs="$num_bytes" seek=1
echo "---------------------"
num_bytes=$(sudo sed '$d' $fstab | wc -c)
sudo sed '$d' $fstab 1<> $fstab
sudo dd if=/dev/null of=$fstab bs="$num_bytes" seek=1
echo "---------------------"
fi
sudo chmod 644 $fstab
sudo sed -i '/firmware_mnt/{n;/cache/d;}' $fstab
sudo sed -i '/firmware_mnt/{n;/cache/d;}' $fstab
ls -al fstab.qcom
echo "**************************************"
ls -al $fstab
echo "**************************************"
fi
cat system/system/vendor/etc/fstab.qcom
sudo cp system/system/vendor/etc/fstab.qcom output/fstab.qcom
echo "fstab修补中"
echo "**************************************"
diff fstab.qcom output/fstab.qcom || true
echo "**************************************"
sudo du -sb system
sudo umount system
sudo rm -rf system
ls -al output/system.img
- name: Patching boot
run: |
echo "Patching boot"
mv output/boot.img mkbootimg/
cd mkbootimg
./mkboot boot.img boot
rm boot.img
cd boot
echo "打印出boot下所有文件"
echo "**************************************"
ls -al
echo "**************************************"
echo "img_info修补中"
cp -f img_info ../img_info
sed -i 's/veritykeyid=id:\w*//g' img_info
cp -f img_info ../../output/img_info
echo "**************************************"
diff img_info ../img_info || true
echo "**************************************"
mv kernel image.gz-dtb
../split-appended-dtb image.gz-dtb
rm image.gz-dtb
for i in `find *.dtb`; do
if [[ ! -z "$(../../fdtget $i /firmware/android/fstab -p 2>/dev/null || true)" ]]; then
echo "**************************************"
../../magiskboot dtb $i print -f
echo "**************************************"
../../fdtget $i /firmware/android/vbmeta parts 2>/dev/null || true
../../fdtput $i -r /firmware/android/vbmeta
echo "**************************************"
if [[ ! -z "$(../../fdtget $i /firmware/android/fstab/system -p 2>/dev/null || true)" ]]; then
../../fdtput $i /firmware/android/fstab/system status -d
../../fdtput $i /firmware/android/fstab/system fsmgr_flags -d
else
../../fdtput $i -cp /firmware/android/fstab/system
echo "add system node"
fi
echo "**************************************"
../../fdtput $i /firmware/android/fstab/system status ok -ts
../../fdtput $i /firmware/android/fstab/system fsmgr_flags wait -ts
../../fdtput $i /firmware/android/fstab/system mnt_flags ro,barrier=1,discard -ts
../../fdtput $i /firmware/android/fstab/system type ext4 -ts
../../fdtput $i /firmware/android/fstab/system dev /dev/block/platform/soc/7824900.sdhci/by-name/system -ts
../../fdtput $i /firmware/android/fstab/system compatible android,system -ts
../../fdtput $i /firmware/android/fstab/vendor fsmgr_flags wait -ts
../../fdtput $i /firmware/android/fstab/vendor status disable -ts
echo "列出android下的节点"
../../fdtget $i /firmware/android/vbmeta -l 2>/dev/null || true
../../fdtget $i /firmware/android/vbmeta parts 2>/dev/null || true
echo "**************************************"
../../magiskboot dtb $i print -f
echo "**************************************"
dtb=${i##* }
dts=${dtb%.*}.dts
echo "dtb $dtb"
echo "dts $dts"
../../dtc -q -I dtb -O dts -o $dts $dtb
line="$(grep -n "firmware {" $dts)"
linea="$(echo $line | cut -d ":" -f 1)"
line="$(grep -n "reserved-memory" $dts)"
lineb="$(echo $line | cut -d ":" -f 1)"
lineb="`expr $lineb - 1`""p"
echo "**************************************"
sed -n "$linea,$lineb" $dts
echo "**************************************"
mv $dts ../../output/$dts
fi
done
echo "**************************************"
ls -al
echo "**************************************"
cat kernel *.dtb > image.gz-dtb
rm -f *.dtb
rm -f kernel
mv image.gz-dtb kernel
echo "列出所有文件"
echo "**************************************"
ls -al
echo "**************************************"
cd ..
./mkboot boot boot.img
cd ..
mv mkbootimg/boot.img tmp/boot.img
cd tmp
../magiskboot unpack -h boot.img
echo "打印tmp下文件"
echo "**************************************"
ls -al
echo "**************************************"
echo "替换ramdisk.cpio"
echo "**************************************"
diff ../cpio/ramdisk-sar.cpio ramdisk.cpio || true
echo "**************************************"
cp -f ../cpio/ramdisk-sar.cpio ramdisk.cpio
../magiskboot repack boot.img
echo "boot打包"
diff new-boot.img boot.img || true
echo "**************************************"
rm -rf boot.img
echo "打印出所有文件"
echo "**************************************"
ls -al
echo "**************************************"
mv new-boot.img ../output/boot.img
cd ..
- name: Packing
run: |
cp output/boot.img template/boot.img
mv output/system.img template/system.img
cd template
echo "**************************************"
ls -al
echo "**************************************"
zip -q -r -9 ${{ steps.var.outputs.filename }} *
cd ..
mv template/${{ steps.var.outputs.filename }} ./
echo "**************************************"
ls -al
echo "**************************************"
echo "" >> boby.txt
echo "> **Downloads:**" >> boby.txt
echo "" >> boby.txt
- name: Upload ROM to Artifact
uses: actions/upload-artifact@v3
with:
name: output
path: |
output
retention-days: 7
- name: Upload ROM to Anonfile
if: github.event.inputs.anon == 'true'
continue-on-error: true
run: |
echo "Upload ROM to Anonfile"
curl -fsSL git.io/file-transfer | sh
anontrans=$(./transfer anon --no-progress ${{ steps.var.outputs.filename }})
anontrans=$(echo $anontrans | grep -o -E "https[^ ]*")
echo "Anonfile: $anontrans"
echo "- [ ] Anonfile:" >> boby.txt
echo " - $anontrans" >> boby.txt
- name: Upload ROM to WeTransfer
if: github.event.inputs.we == 'true'
continue-on-error: true
run: |
echo "Upload to WeTransfer"
curl -fsSL git.io/file-transfer | sh
wetrans=$(./transfer wet -s -p 16 --no-progress ${{ steps.var.outputs.filename }})
wetrans=$(echo $wetrans | grep -o -E "https[^ ]*")
echo "WeTransfer: $wetrans"
echo "- [ ] WeTransfer(Valid for seven days):" >> boby.txt
echo " - $wetrans" >> boby.txt
- name: Upload ROM to MuseTransfer
if: github.event.inputs.muse == 'true'
continue-on-error: true
run: |
echo "Upload to MuseTransfer"
curl -fsSL git.io/file-transfer | sh
musetrans=$(./transfer muse -s -p 12 --no-progress ${{ steps.var.outputs.filename }})
musetrans=$(echo $musetrans | grep -o -E "https[^ ]*")
echo "MuseTransfer: $musetrans"
echo "- [ ] MuseTransfer(Valid for seven days):" >> boby.txt
echo " - $musetrans" >> boby.txt
MD5SUM=$(md5sum ${{ steps.var.outputs.filename }} | cut -d' ' -f1)
SHA1SUM=$(sha1sum ${{ steps.var.outputs.filename }} | cut -d' ' -f1)
SHA256SUM=$(sha256sum ${{ steps.var.outputs.filename }} | cut -d' ' -f1)
echo "MD5SUM: $MD5SUM"
echo "SHA1SUM: $SHA1SUM"
echo "SHA256SUM: $SHA256SUM"
echo "" >> boby.txt
echo "> **Verify:**" >> boby.txt
echo "" >> boby.txt
echo "- [ ] MD5SUM:" >> boby.txt
echo "" >> boby.txt
echo " $MD5SUM" >> boby.txt
echo "- [ ] SHA1SUM:" >> boby.txt
echo "" >> boby.txt
echo " $SHA1SUM" >> boby.txt
echo "- [ ] SHA256SUM:" >> boby.txt
echo "" >> boby.txt
echo " $SHA256SUM" >> boby.txt
echo "" >> boby.txt
- name: Upload ROM to Release
if: github.event.inputs.release == 'true'
uses: softprops/action-gh-release@v1
with:
files: ${{ steps.var.outputs.filename }}
name: ${{ steps.var.outputs.name }}
tag_name: ${{ github.run_id }}
body_path: boby.txt
env:
GITHUB_TOKEN: ${{ secrets.RELEASE }}