diff options
author | Daniil Baturin <daniil@baturin.org> | 2024-03-21 13:58:48 +0000 |
---|---|---|
committer | Daniil Baturin <daniil@baturin.org> | 2024-03-21 13:58:48 +0000 |
commit | 65b0321a8b92a4fcbb211caeec31aaa82a3a490c (patch) | |
tree | 5ee783e49e637be3b7f6c85b95c0dedf467fde95 /scripts | |
parent | afd04be6c611c38c08103c11660d8c901d0ae217 (diff) | |
download | vyos-build-65b0321a8b92a4fcbb211caeec31aaa82a3a490c.tar.gz vyos-build-65b0321a8b92a4fcbb211caeec31aaa82a3a490c.zip |
build script: T3664: fix handling of missing or malformed flavor files
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/build-vyos-image | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/scripts/build-vyos-image b/scripts/build-vyos-image index fb7eb540..3d287406 100755 --- a/scripts/build-vyos-image +++ b/scripts/build-vyos-image @@ -193,9 +193,17 @@ if __name__ == "__main__": pre_build_config = merge_dicts({}, build_defaults) flavor_config = {} - 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) + 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) |