-
Notifications
You must be signed in to change notification settings - Fork 13
/
build-zip.sh
executable file
·146 lines (125 loc) · 6.39 KB
/
build-zip.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
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
#!/bin/bash
#Philipp "3D" ten Brink
#2023-01-19
#GNU General Public License v3.0 see LICENSE
mkdir output
#tasmota_version=$(curl --silent "https://api.github.com/repos/arendst/Tasmota/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
tasmota_version="12.5.0"
curl -o build-files/tasmota32.bin http://ota.tasmota.com/tasmota32/release-12.5.0/tasmota32.bin
curl -o build-files/tasmota32solo1.bin http://ota.tasmota.com/tasmota32/release-12.5.0/tasmota32solo1.bin
curl -o build-files/tasmota32-lvgl.bin http://ota.tasmota.com/tasmota32/release-12.5.0/tasmota32-lvgl.bin
curl -o build-files/tasmota32c3.bin http://ota.tasmota.com/tasmota32/release-12.5.0/tasmota32c3.bin
generatezip () {
shelly_device=$1
app_file=$2
fs_file=$3
if [[ $4 -eq 3 ]]
then
platform="esp32c3"
boot_file="bootloader-tasmota-c3.bin"
boot_file_addr=0
partition_file="C3_8MB_partition-table.bin"
else
if [[ $4 -eq 2 ]]
then
platform="esp32c3"
boot_file="bootloader-tasmota-c3.bin"
boot_file_addr=0
partition_file="C3_4MB_partition-table.bin"
else
platform="esp32"
boot_file="bootloader.bin"
boot_file_addr=4096
partition_file="partition-table.bin"
fi
fi
#General:
otadata_file="otadata.bin"
#Generated:
build_id=$(date '+%Y%m%d-%H%M%S')
build_date=$(date '+%Y-%m-%dT%H:%M:%SZ')
boot_file_size=$(wc -c build-files/$boot_file | awk '{print $1}')
boot_file_cs1=$(shasum -a1 build-files/$boot_file | awk '{print $1}')
boot_file_cs256=$(shasum -a256 build-files/$boot_file | awk '{print $1}')
partition_file_size=$(wc -c build-files/$partition_file | awk '{print $1}')
partition_file_cs1=$(shasum -a1 build-files/$partition_file | awk '{print $1}')
partition_file_cs256=$(shasum -a256 build-files/$partition_file | awk '{print $1}')
otadata_file_size=$(wc -c build-files/$otadata_file | awk '{print $1}')
otadata_file_cs1=$(shasum -a1 build-files/$otadata_file | awk '{print $1}')
otadata_file_cs256=$(shasum -a256 build-files/$otadata_file | awk '{print $1}')
app_file_size=$(wc -c build-files/$app_file | awk '{print $1}')
app_file_cs1=$(shasum -a1 build-files/$app_file | awk '{print $1}')
app_file_cs256=$(shasum -a256 build-files/$app_file | awk '{print $1}')
fs_file_size=$(wc -c build-files/$fs_file | awk '{print $1}')
fs_file_cs1=$(shasum -a1 build-files/$fs_file | awk '{print $1}')
fs_file_cs256=$(shasum -a256 build-files/$fs_file | awk '{print $1}')
JSON_STRING=$( jq -n \
--arg name "$shelly_device" \
--arg platform "$platform" \
--arg version "$tasmota_version" \
--arg build_id "$build_id/tasmota-$tasmota_version" \
--arg build_timestamp "$build_date" \
--arg boot_file "$boot_file" \
--argjson boot_file_addr "$boot_file_addr" \
--argjson boot_file_size $boot_file_size \
--arg boot_cs_sha1 "$boot_file_cs1" \
--arg boot_cs_sha256 "$boot_file_cs256" \
--arg partition_file "$partition_file" \
--argjson partition_file_size $partition_file_size \
--arg partition_cs_sha1 "$partition_file_cs1" \
--arg partition_cs_sha256 "$partition_file_cs256" \
--arg otadata_file "$otadata_file" \
--argjson otadata_file_size $otadata_file_size \
--arg otadata_cs_sha1 "$otadata_file_cs1" \
--arg otadata_cs_sha256 "$otadata_file_cs256" \
--arg app_file "$app_file" \
--argjson app_file_size $app_file_size \
--arg app_cs_sha1 "$app_file_cs1" \
--arg app_cs_sha256 "$app_file_cs256" \
--arg fs_file "$fs_file" \
--argjson fs_file_size $fs_file_size \
--arg fs_cs_sha1 "$fs_file_cs1" \
--arg fs_cs_sha256 "$fs_file_cs256" \
'{ "name" : $name, "platform" : $platform, "version" : $version, "build_id" : $build_id, "build_timestamp" : $build_timestamp, "parts": { "boot": { "type": "boot", "src": $boot_file, "addr": $boot_file_addr, "size": $boot_file_size, "cs_sha1" : $boot_cs_sha1, "cs_sha256": $boot_cs_sha256, "encrypt": true, "min_version": "0.0.0" }, "pt": { "type": "pt", "src": $partition_file, "addr": 32768, "size": $partition_file_size, "cs_sha1": $partition_cs_sha1, "cs_sha256": $partition_cs_sha256, "encrypt": true }, "otadata": { "type": "otadata", "src": $otadata_file, "size": $otadata_file_size, "cs_sha1": $otadata_cs_sha1, "cs_sha256": $otadata_cs_sha256, "encrypt": true, "ptn": "otadata"}, "nvs": { "type": "nvs", "size": 16384, "fill": 255, "ptn": "nvs" }, "app": { "type": "app", "src": $app_file, "size": $app_file_size, "cs_sha1" : $app_cs_sha1, "cs_sha256" : $app_cs_sha256, "encrypt": true, "ptn": "app_0"}, "fs": { "type": "fs", "src": $fs_file, "size": $fs_file_size, "cs_sha1": $fs_cs_sha1, "cs_sha256": $fs_cs_sha256, "size": $fs_file_size, "encrypt": true, "ptn": "fs_0", "fs_size": $fs_file_size }}}')
printf "$JSON_STRING" > build-files/manifest.json
cd build-files
zip -0 mgos32-to-tasmota32-$shelly_device.zip manifest.json
zip -0 mgos32-to-tasmota32-$shelly_device.zip $boot_file
zip -0 mgos32-to-tasmota32-$shelly_device.zip $partition_file
zip -0 mgos32-to-tasmota32-$shelly_device.zip $otadata_file
zip -0 mgos32-to-tasmota32-$shelly_device.zip $app_file
zip -0 mgos32-to-tasmota32-$shelly_device.zip $fs_file
mv mgos32-to-tasmota32-$shelly_device.zip ../output/
cd ..
printf "\nDone mgos32-to-tasmota32-$shelly_device.zip\n\n"
}
ShellyMiniG3=( Mini1PMG3 Mini1G3 MiniPMG3 )
for i in "${ShellyMiniG3[@]}"
do
generatezip $i "tasmota32c3.bin" "fs-8MB-tasmota-C3.img" 3
done
ShellyPlusMini=( Plus1PMMini Plus1Mini PlusPMMini )
for i in "${ShellyPlusMini[@]}"
do
generatezip $i "tasmota32c3.bin" "fs-4MB-tasmota-C3.img" 2
done
ShellyPlus=( PlusHT PlusPlugS PlusPlugUK PlusPlugIT PlusPlugUS PlugUS PlusI4 PlusWallDimmer Plus1PM Plus1 Plus2PM Plus10V )
for i in "${ShellyPlus[@]}"
do
generatezip $i "tasmota32solo1.bin" "fs-4MB-tasmota.img" 1
done
ShellyPro8MB=( Pro1 Pro1PM Pro2 Pro2PM Pro3 )
for i in "${ShellyPro8MB[@]}"
do
generatezip $i "tasmota32.bin" "fs-8MB-tasmota.img" 1
done
ShellyPro8MBlvgl=( Pro4PM )
for i in "${ShellyPro8MBlvgl[@]}"
do
generatezip $i "tasmota32-lvgl.bin" "fs-8MB-tasmota.img" 1
done
ShellyPro16MB=( Pro3EM )
for i in "${ShellyPro16MB[@]}"
do
generatezip $i "tasmota32.bin" "fs-16MB-tasmota.img" 1
done