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>
This commit is contained in:
parent
3d026d2425
commit
a463b96241
@ -18,19 +18,33 @@ work_dir = Path(getenv("WORK_DIR"))
|
|||||||
|
|
||||||
output = {}
|
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"):
|
for json_file in work_dir.glob("*.json"):
|
||||||
image_info = json.loads(json_file.read_text())
|
image_info = json.loads(json_file.read_text())
|
||||||
|
|
||||||
if not output:
|
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:
|
else:
|
||||||
# get first (and only) profile in json file
|
output["profiles"][device_id]["images"].extend(profile["images"])
|
||||||
device_id = next(iter(image_info["profiles"].keys()))
|
|
||||||
if device_id not in output["profiles"]:
|
# make image lists unique by name, keep last/latest
|
||||||
output["profiles"].update(image_info["profiles"])
|
for device_id, profile in output["profiles"].items():
|
||||||
else:
|
profile["images"] = list({e["name"]: e for e in profile["images"]}.values())
|
||||||
output["profiles"][device_id]["images"].append(
|
|
||||||
image_info["profiles"][device_id]["images"][0]
|
|
||||||
)
|
|
||||||
|
|
||||||
if output:
|
if output:
|
||||||
default_packages, output["arch_packages"] = run(
|
default_packages, output["arch_packages"] = run(
|
||||||
|
Loading…
Reference in New Issue
Block a user