diff --git a/stages/org.osbuild.containers.storage.conf b/stages/org.osbuild.containers.storage.conf index 64524a56..f2f89ab1 100755 --- a/stages/org.osbuild.containers.storage.conf +++ b/stages/org.osbuild.containers.storage.conf @@ -87,6 +87,10 @@ SCHEMA = r""" "/usr/share/containers/storage.conf" ] }, + "filebase": { + "type": "string", + "description": "Read the base configuration from this file." + }, "comment": { "type": "array", "items": { @@ -166,14 +170,24 @@ def main(tree, options): location = options.get("filename", DEFAULT_LOCATION) config = options["config"] comment = options.get("comment", []) + filebase = options.get("filebase") path = os.path.join(tree, location.lstrip("/")) data = {} - with contextlib.suppress(FileNotFoundError): - with open(path, "r", encoding="utf8") as f: + # if a filebase was specified, we use it as base + if filebase: + with open(filebase, "r", encoding="utf8") as f: data = toml.load(f) + # if the target exists, we merge it + with contextlib.suppress(FileNotFoundError): + with open(path, "r", encoding="utf8") as f: + have = toml.load(f) + + merge_config("storage", data, have) + + # now merge our configuration into data merge_config("storage", data, config) with open(path, "w", encoding="utf8") as f: