forked from luk1337/oplus_archive
-
Notifications
You must be signed in to change notification settings - Fork 3
/
dump.sh
executable file
·61 lines (54 loc) · 1.51 KB
/
dump.sh
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
#!/bin/bash
set -ex
# Extract full update
aria2c -x5 "$1" -o ota.zip
unzip ota.zip payload.bin
mv payload.bin payload_working.bin
TAG="`unzip -p ota.zip payload_properties.txt | grep ^POST_OTA_VERSION= | cut -b 18-`"
BODY="[$TAG]($1) (full)"
rm ota.zip
mkdir ota
(
./bin/ota_extractor -output_dir ota -payload payload_working.bin
rm payload_working.bin
) & # Allow subsequent downloads to be done in parallel
# Apply incrementals
for i in ${@:2}; do
aria2c -x5 "$i" -o ota.zip
unzip ota.zip payload.bin
wait
mv payload.bin payload_working.bin
TAG="`unzip -p ota.zip payload_properties.txt | grep ^POST_OTA_VERSION= | cut -b 18-`"
BODY="$BODY -> [$TAG]($i)"
rm ota.zip
(
mkdir ota_new
./bin/ota_extractor -input-dir ota -output_dir ota_new -payload payload_working.bin
rm -rf ota
mv ota_new ota
rm payload_working.bin
) & # Allow subsequent downloads to be done in parallel
done
wait
# Create a split 7z image
mkdir out
mkdir dyn
cd ota
# Calculate hash
for h in md5 sha1 sha256; do
ls * | parallel openssl dgst -$h -r | sort -k2 -V > ../out/${TAG}-hash.$h &
done
ls * | parallel xxh128sum | sort -k2 -V > ../out/${TAG}-hash.xxh128 &
wait
for f in system system_ext product vendor vendor_dlkm odm; do
mv ${f}.img ../dyn
done
7z a -mx6 ../out/${TAG}-image.7z * &
cd ../dyn
7z a -mx6 -v1g ../out/${TAG}-image-logical.7z *
wait
cd ..
rm -rf ota dyn
# Echo tag name and release body
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
echo "body=$BODY" >> "$GITHUB_OUTPUT"