2020-03-12 22:55:41 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
2020-06-30 11:02:43 +00:00
|
|
|
from os import getenv, environ
|
2020-03-12 22:55:41 +00:00
|
|
|
from pathlib import Path
|
2020-06-30 11:02:43 +00:00
|
|
|
from subprocess import run
|
2020-03-12 22:55:41 +00:00
|
|
|
from sys import argv
|
2020-06-30 11:02:43 +00:00
|
|
|
import json
|
2020-03-12 22:55:41 +00:00
|
|
|
|
|
|
|
if len(argv) != 2:
|
|
|
|
print("JSON info files script requires ouput file as argument")
|
|
|
|
exit(1)
|
|
|
|
|
|
|
|
output_path = Path(argv[1])
|
|
|
|
|
|
|
|
assert getenv("WORK_DIR"), "$WORK_DIR required"
|
|
|
|
|
|
|
|
work_dir = Path(getenv("WORK_DIR"))
|
|
|
|
|
|
|
|
output = {}
|
|
|
|
|
|
|
|
for json_file in work_dir.glob("*.json"):
|
|
|
|
image_info = json.loads(json_file.read_text())
|
|
|
|
if not output:
|
|
|
|
output.update(image_info)
|
|
|
|
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]
|
|
|
|
)
|
|
|
|
|
|
|
|
if output:
|
2020-07-03 20:57:52 +00:00
|
|
|
default_packages, output["arch_packages"] = run(
|
|
|
|
[
|
|
|
|
"make",
|
|
|
|
"--no-print-directory",
|
|
|
|
"-C",
|
|
|
|
f"target/linux/{output['target'].split('/')[0]}",
|
|
|
|
"val.DEFAULT_PACKAGES",
|
|
|
|
"val.ARCH_PACKAGES",
|
|
|
|
],
|
|
|
|
capture_output=True,
|
|
|
|
check=True,
|
|
|
|
env=environ.copy().update({"TOPDIR": Path().cwd()}),
|
|
|
|
text=True,
|
|
|
|
).stdout.splitlines()
|
|
|
|
|
|
|
|
output["default_packages"] = default_packages.split()
|
2020-03-12 22:55:41 +00:00
|
|
|
output_path.write_text(json.dumps(output, sort_keys=True, separators=(",", ":")))
|
|
|
|
else:
|
|
|
|
print("JSON info file script could not find any JSON files for target")
|