mirror of
https://github.com/openwrt/openwrt.git
synced 2024-12-19 13:48:06 +00:00
14cbd8fb2d
The JSON `WORK_DIR` ($(KDIR)/json_info_files) is only created if the new image generation methods from `image.mk` are used. However some targets like `armvirt` do not use it yet, so the folder is never created. The `json_overview_image_info.py` script used to raise an error if the given `WORK_DIR` isn't a folder, however it should just notify about missing JSON files. This patch removes the Python assert and exists with code 0 even if no JSON files were found, as this is not necessarily an error but simply not yet implemented. Using `glob` on an not existing `Path` results in an empty list, therefore the for loop won't run. Signed-off-by: Paul Spooren <mail@aparcar.org> CC: Petr Štetiar <ynezz@true.cz>
38 lines
1.0 KiB
Python
Executable File
38 lines
1.0 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
import json
|
|
from pathlib import Path
|
|
from os import getenv
|
|
from sys import argv
|
|
|
|
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:
|
|
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")
|