3 from os
import getenv
, environ
4 from pathlib
import Path
5 from subprocess
import run
, PIPE
10 print("JSON info files script requires ouput file as argument")
13 output_path
= Path(argv
[1])
15 assert getenv("WORK_DIR"), "$WORK_DIR required"
17 work_dir
= Path(getenv("WORK_DIR"))
21 for json_file
in work_dir
.glob("*.json"):
22 image_info
= json
.loads(json_file
.read_text())
24 output
.update(image_info
)
26 # get first (and only) profile in json file
27 device_id
= next(iter(image_info
["profiles"].keys()))
28 if device_id
not in output
["profiles"]:
29 output
["profiles"].update(image_info
["profiles"])
31 output
["profiles"][device_id
]["images"].append(
32 image_info
["profiles"][device_id
]["images"][0]
36 default_packages
, output
["arch_packages"] = run(
39 "--no-print-directory",
41 "target/linux/{}".format(output
['target'].split('/')[0]),
42 "val.DEFAULT_PACKAGES",
48 env
=environ
.copy().update({"TOPDIR": Path().cwd()}),
49 universal_newlines
=True,
52 output
["default_packages"] = default_packages
.split()
53 output_path
.write_text(json
.dumps(output
, sort_keys
=True, separators
=(",", ":")))
55 print("JSON info file script could not find any JSON files for target")