summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@vyos.io>2024-04-13 20:06:53 +0000
committerChristian Breunig <christian@breunig.cc>2024-05-05 15:10:09 +0200
commit0d3031ab9942005c74e61c5a742fda8e2796ea40 (patch)
tree3d374b69dbaebeccd0ee30f8c359e40c8619283b
parentf257039bdfdd7258e964ee49ee296055c716e98c (diff)
downloadvyos-build-0d3031ab9942005c74e61c5a742fda8e2796ea40.tar.gz
vyos-build-0d3031ab9942005c74e61c5a742fda8e2796ea40.zip
build: T3664: add a sanity check for image_format
and normalize it to a list if only one format is specified (cherry picked from commit 72c7c7ff99b86bb3c65b44f69e05cf40cb8367c0)
-rwxr-xr-xscripts/image-build/build-vyos-image11
1 files changed, 11 insertions, 0 deletions
diff --git a/scripts/image-build/build-vyos-image b/scripts/image-build/build-vyos-image
index f213767c..c852694d 100755
--- a/scripts/image-build/build-vyos-image
+++ b/scripts/image-build/build-vyos-image
@@ -287,12 +287,23 @@ if __name__ == "__main__":
if has_nonempty_key(build_config["architectures"], "packages"):
build_config["packages"] += build_config["architectures"][arch]["packages"]
+ ## Check if image format is specified,
+ ## else we have no idea what we are actually supposed to build.
+ if not has_nonempty_key(build_config, "image_format"):
+ print("E: image format is not specified in the build flavor file")
+ sys.exit(1)
+
## Add default boot settings if needed
if "boot_settings" not in build_config:
build_config["boot_settings"] = defaults.boot_settings
else:
build_config["boot_settings"] = merge_dicts(defaults.default_consolede, build_config["boot_settings"])
+ ## Convert the image_format field to a single-item list if it's a scalar
+ ## (like `image_format = "iso"`)
+ if type(build_config["image_format"]) != list:
+ build_config["image_format"] = [ build_config["image_format"] ]
+
## Dump the complete config if the user enabled debug mode
if debug:
import json