aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorMoritz Warning <moritzwarning@web.de>2021-02-22 00:18:10 +0100
committerPaul Spooren <mail@aparcar.org>2021-06-21 09:43:21 -1000
commit8add3e139ca5b58b91098aa0615f3492d1191241 (patch)
tree06cbd9c9b2faf81a0fe837b70091303dbbeb68c4 /scripts
parentb2a3df91fa7e9a7f8b9216a99496ecc935f3e56d (diff)
downloadupstream-8add3e139ca5b58b91098aa0615f3492d1191241.tar.gz
upstream-8add3e139ca5b58b91098aa0615f3492d1191241.tar.bz2
upstream-8add3e139ca5b58b91098aa0615f3492d1191241.zip
build: preserve profiles.json between builds
Keep other profiles.json content if the data belongs to the current build version. Also useful for the ImageBuilder, which builds for a single model each time. Without this commit the profiles.json would only contain the latest build profile information. Signed-off-by: Moritz Warning <moritzwarning@web.de> [improve commit message] Signed-off-by: Paul Spooren <mail@aparcar.org> (cherry picked from commit a463b96241fbc2d142982387eaed9989e201ac7a)
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/json_overview_image_info.py32
1 files changed, 23 insertions, 9 deletions
diff --git a/scripts/json_overview_image_info.py b/scripts/json_overview_image_info.py
index 8dbd24af2d..45c05012b1 100755
--- a/scripts/json_overview_image_info.py
+++ b/scripts/json_overview_image_info.py
@@ -18,19 +18,33 @@ work_dir = Path(getenv("WORK_DIR"))
output = {}
+
+def get_initial_output(image_info):
+ # preserve existing profiles.json
+ if output_path.is_file():
+ profiles = json.loads(output_path.read_text())
+ if profiles["version_code"] == image_info["version_code"]:
+ return profiles
+ return image_info
+
+
for json_file in work_dir.glob("*.json"):
image_info = json.loads(json_file.read_text())
+
if not output:
- output.update(image_info)
+ output = get_initial_output(image_info)
+
+ # get first and only profile in json file
+ device_id, profile = next(iter(image_info["profiles"].items()))
+ if device_id not in output["profiles"]:
+ output["profiles"][device_id] = profile
else:
- # get first (and only) profile in json file
- device_id = next(iter(image_info["profiles"].keys()))
- if device_id not in output["profiles"]:
- output["profiles"].update(image_info["profiles"])
- else:
- output["profiles"][device_id]["images"].append(
- image_info["profiles"][device_id]["images"][0]
- )
+ output["profiles"][device_id]["images"].extend(profile["images"])
+
+# make image lists unique by name, keep last/latest
+for device_id, profile in output["profiles"].items():
+ profile["images"] = list({e["name"]: e for e in profile["images"]}.values())
+
if output:
default_packages, output["arch_packages"] = run(