build,json: fixup missing arch_packages
[openwrt/openwrt.git] / scripts / json_overview_image_info.py
index 5ed829249bd1950274cfcca42a0dd4631627cc47..e0e1ff08d598530c0a57f21cdd2e187ea6ef166a 100755 (executable)
@@ -1,9 +1,10 @@
 #!/usr/bin/env python3
 
-import json
+from os import getenv, environ
 from pathlib import Path
-from os import getenv
+from subprocess import run, PIPE
 from sys import argv
+import json
 
 if len(argv) != 2:
     print("JSON info files script requires ouput file as argument")
@@ -15,8 +16,6 @@ assert getenv("WORK_DIR"), "$WORK_DIR required"
 
 work_dir = Path(getenv("WORK_DIR"))
 
-assert work_dir.is_dir(), "$WORK_DIR not a directory"
-
 output = {}
 
 for json_file in work_dir.glob("*.json"):
@@ -34,6 +33,35 @@ for json_file in work_dir.glob("*.json"):
             )
 
 if output:
+    output["default_packages"] = run(
+        [
+            "make",
+            "--no-print-directory",
+            "-C",
+            "target/linux/{}".format(output["target"].split("/")[0]),
+            "val.DEFAULT_PACKAGES",
+            "DUMP=1",
+        ],
+        stdout=PIPE,
+        stderr=PIPE,
+        check=True,
+        env=environ.copy().update({"TOPDIR": Path().cwd()}),
+        universal_newlines=True,
+    ).stdout.split()
+
+    output["arch_packages"] = run(
+        [
+            "make",
+            "--no-print-directory",
+            "val.ARCH_PACKAGES",
+        ],
+        stdout=PIPE,
+        stderr=PIPE,
+        check=True,
+        env=environ.copy().update({"TOPDIR": Path().cwd()}),
+        universal_newlines=True,
+    ).stdout.strip()
+
     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")