diff --git a/stages/org.osbuild.dnf.module-config b/stages/org.osbuild.dnf.module-config index 2ae4479b..b1e2d166 100755 --- a/stages/org.osbuild.dnf.module-config +++ b/stages/org.osbuild.dnf.module-config @@ -1,23 +1,26 @@ #!/usr/bin/python3 import configparser -import os +import pathlib import sys import osbuild.api def main(tree, options): - path = options["path"] conf = options["conf"] + name = conf["name"] inip = configparser.ConfigParser() - inip[conf["name"]] = conf + inip[name] = conf # we need to handle enabled profiles as a string as configparser # would normally write [a, b] - inip[conf["name"]]["profiles"] = ", ".join(conf["profiles"]) + inip[name]["profiles"] = ", ".join(conf["profiles"]) - with open(os.path.join(tree, path), "w", encoding="utf-8") as file: + path = pathlib.Path(tree) / "etc/dnf/modules.d" / f"{name}.conf" + path.parent.mkdir(parents=True, exist_ok=True) + + with open(path, "w", encoding="utf-8") as file: inip.write(file) return 0 diff --git a/stages/org.osbuild.dnf.module-config.meta.json b/stages/org.osbuild.dnf.module-config.meta.json index b59c24e6..c9ac5077 100644 --- a/stages/org.osbuild.dnf.module-config.meta.json +++ b/stages/org.osbuild.dnf.module-config.meta.json @@ -9,10 +9,6 @@ "additionalProperties": false, "description": "DNF configuration.", "properties": { - "path": { - "type": "string", - "description": "Path to write the module configuration to." - }, "conf": { "additionalProperties": false, "type": "object", diff --git a/stages/test/test_dnf_module_config.py b/stages/test/test_dnf_module_config.py index 2e2f66cb..9c9dad97 100644 --- a/stages/test/test_dnf_module_config.py +++ b/stages/test/test_dnf_module_config.py @@ -10,7 +10,6 @@ STAGE_NAME = "org.osbuild.dnf.module-config" @pytest.mark.parametrize("test_data,expected_err", [ # bad ({"conf": "must-be-object"}, "'must-be-object' is not of type 'object'"), - ({"path": {}}, "{} is not of type 'string'"), # good ({ "conf": @@ -40,13 +39,11 @@ def test_dnf_module_config_schema_validation(stage_schema, test_data, expected_e def test_dnf_module_config_writes_file(tmp_path, stage_module): treepath = tmp_path / "tree" - confpath = "etc/dnf/modules.d/module.conf" + confpath = "etc/dnf/modules.d/some-module.conf" + fullpath = treepath / confpath - fullpath.parent.mkdir(parents=True, exist_ok=True) - options = { - "path": confpath, "conf": { "name": "some-module", "stream": "some-stream",