-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathrelease_hashes.py
More file actions
executable file
·63 lines (51 loc) · 2.3 KB
/
Copy pathrelease_hashes.py
File metadata and controls
executable file
·63 lines (51 loc) · 2.3 KB
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
#!/usr/bin/env python3
# Copyright (C) 2024, Mark Qvist
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
import os
import json
import hashlib
RELEASE_STABILITY = "beta"
major_version = None
minor_version = None
target_version = None
file = open("Config.h", "rb")
config_data = file.read().splitlines()
for line in config_data:
dline = line.decode("utf-8").strip()
components = dline.split()
if dline.startswith("#define MAJ_VERS"):
major_version = "%01d" % ord(bytes.fromhex(dline.split()[2].split("x")[1]))
if dline.startswith("#define MIN_VERS"):
minor_version = "%02d" % ord(bytes.fromhex(dline.split()[2].split("x")[1]))
target_version = major_version+"."+minor_version
release_hashes = {}
# Scan PlatformIO build output directories for merged firmware binaries.
# The release archive (rtnode_firmware.zip) is built from these merged files.
pio_build_dir = ".pio/build"
if os.path.isdir(pio_build_dir):
for env_name in sorted(os.listdir(pio_build_dir)):
env_dir = os.path.join(pio_build_dir, env_name)
if not os.path.isdir(env_dir):
continue
for filename in sorted(os.listdir(env_dir)):
if filename.startswith("rnode_firmware") and filename.endswith(".bin"):
filepath = os.path.join(env_dir, filename)
if not os.path.isfile(filepath):
continue
with open(filepath, "rb") as file:
release_hashes[filename] = {
"hash": hashlib.sha256(file.read()).hexdigest(),
"version": target_version,
"stability": RELEASE_STABILITY,
"env": env_name,
}
print(json.dumps(release_hashes))