build,json: fix build failure in case no data is found
authorDaniel Golle <daniel@makrotopia.org>
Fri, 3 Jul 2020 20:57:52 +0000 (21:57 +0100)
committerDaniel Golle <daniel@makrotopia.org>
Fri, 3 Jul 2020 21:09:24 +0000 (22:09 +0100)
Only collect arch_packages if actually generating any output.

Fixes: commit f09b9319 ("build,json: store arch_packages in profiles.json"(
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Signed-off-by: Paul Spooren <mail@aparcar.org>
scripts/json_overview_image_info.py

index 20b14f236b3918e825d31b9f6b75e98b1bf379b5..8f3525f890189e4203ff79678425773144413e05 100755 (executable)
@@ -32,25 +32,23 @@ for json_file in work_dir.glob("*.json"):
                 image_info["profiles"][device_id]["images"][0]
             )
 
-
-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()
-
 if output:
+    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()
     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")