diff --git a/README.md b/README.md index 2cc4f885..eaed52fe 100644 --- a/README.md +++ b/README.md @@ -190,6 +190,10 @@ with key suffixes as follows: * `_required`: `true` means that the key must be set * `_values`: the value, if set, must be within the space-separated list of values here + * `_type`: `path` means the value, if set, must be the path to a file which + exists + * `_type`: `paths` means the value, if set, must be a space-separated list of + path to files which exist Merged options -------------- diff --git a/config/schema.ini b/config/schema.ini index 01d4eafa..c5cd7147 100644 --- a/config/schema.ini +++ b/config/schema.ini @@ -4,6 +4,9 @@ # _required = true means that the key must be set # _values means the value, if set, must be within the space-separated list of # values here +# _type = path means the value, if set, must be the path to a file which exists +# _type = paths means the value, if set, must be a space-separated list of +# path to files which exist [image] compression_required = true diff --git a/run-build b/run-build index 4141e522..33323ea1 100755 --- a/run-build +++ b/run-build @@ -515,6 +515,27 @@ class ImageBuilder(object): raise eib.ImageBuildError( 'Configuration key [%s] %s has invalid value: %s' % (section, option, self.config[section][option])) + elif option.endswith('_type'): + real_option = option[:-len('_type')] + if real_option in self.config[section]: + real_value = self.config[section][real_option].strip() + match value: + case "path": + paths = [real_value] if real_value else [] + case "paths": + paths = real_value.split() + case other: + raise eib.ImageBuildError( + f'Schema key [{section}] {option} has invalid value: ' + f'{value}' + ) + + for path in paths: + if not os.path.exists(path): + raise eib.ImageBuildError( + f'Configuration key [{section}] {real_option} refers to ' + f'nonexistent path: {path}' + ) def check_config(self): """Check loaded configuration against schema for validity."""