4 from pathlib import Path
10 print("ERROR: JSON info script requires output arg")
13 json_path = Path(argv[1])
14 bin_dir = Path(getenv("BIN_DIR"))
15 image_file = bin_dir / getenv("IMAGE_NAME")
17 if not image_file.is_file():
18 print("Skip JSON creation for non existing image ", image_file)
24 for prefix in ["", "ALT0_", "ALT1_", "ALT2_"]:
26 for var in ["vendor", "model", "variant"]:
27 if getenv("DEVICE_{}{}".format(prefix, var.upper())):
28 title[var] = getenv("DEVICE_{}{}".format(prefix, var.upper()))
34 titles.append({"title": getenv("DEVICE_TITLE")})
39 device_id = getenv("DEVICE_ID")
40 image_hash = hashlib.sha256(image_file.read_bytes()).hexdigest()
43 "metadata_version": 1,
44 "target": "{}/{}".format(getenv("TARGET"), getenv("SUBTARGET")),
45 "version_code": getenv("VERSION_CODE"),
46 "version_number": getenv("VERSION_NUMBER"),
49 "image_prefix": getenv("IMAGE_PREFIX"),
52 "type": getenv("IMAGE_TYPE"),
53 "name": getenv("IMAGE_NAME"),
57 "supported_devices": getenv("SUPPORTED_DEVICES").split(),
58 "titles": get_titles(),
63 json_path.write_text(json.dumps(image_info, separators=(",", ":")))