summaryrefslogtreecommitdiff
path: root/scripts/build-vyos-image
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@baturin.org>2024-03-21 13:58:48 +0000
committerChristian Breunig <christian@breunig.cc>2024-05-05 15:06:54 +0200
commit75c8f627a896455952abd8944f77f8fc443a3211 (patch)
treeb2ecc85510b58ee27cfbb8918c158a587b167441 /scripts/build-vyos-image
parent64d4406cb22d61bda1e826075f3052462b59289e (diff)
downloadvyos-build-75c8f627a896455952abd8944f77f8fc443a3211.tar.gz
vyos-build-75c8f627a896455952abd8944f77f8fc443a3211.zip
build script: T3664: fix handling of missing or malformed flavor files
(cherry picked from commit 65b0321a8b92a4fcbb211caeec31aaa82a3a490c)
Diffstat (limited to 'scripts/build-vyos-image')
-rwxr-xr-xscripts/build-vyos-image19
1 files changed, 19 insertions, 0 deletions
diff --git a/scripts/build-vyos-image b/scripts/build-vyos-image
index 5ee0b3ed..aa0a6aad 100755
--- a/scripts/build-vyos-image
+++ b/scripts/build-vyos-image
@@ -191,6 +191,25 @@ if __name__ == "__main__":
print("\n".join(build_flavors))
sys.exit(1)
+ ## Try to get correct architecture and build type from build flavor and CLI arguments
+ pre_build_config = merge_dicts({}, build_defaults)
+
+ flavor_config = {}
+ build_flavor = args["build_flavor"]
+ try:
+ with open(make_toml_path(defaults.BUILD_FLAVORS_DIR, args["build_flavor"]), 'rb') as f:
+ flavor_config = tomli.load(f)
+ pre_build_config = merge_dicts(flavor_config, pre_build_config)
+ except FileNotFoundError:
+ print(f"E: Flavor '{build_flavor}' does not exist")
+ sys.exit(1)
+ except tomli.TOMLDecodeError as e:
+ print(f"E: Failed to parse TOML file for flavor '{build_flavor}': {e}")
+ sys.exit(1)
+
+ ## Combine configs args > flavor > defaults
+ pre_build_config = merge_dicts(args, pre_build_config, skip_none=True)
+
# Some fixup for mirror settings.
# The idea is: if --debian-mirror is specified but --pbuilder-debian-mirror is not,
# use the --debian-mirror value for both lb and pbuilder bootstrap