From 062feda60ac560bee9f0437f96459c08597d463f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Hozza?= Date: Tue, 19 Nov 2024 13:37:37 +0100 Subject: [PATCH] Stages/dnf-automatic.config: don't fail on non-existent config file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On Fedora 41 with DNF5, the dnf-automatic plugin by default does not install any configuration file. This means that the stage would fail in such case. Previously, the full config file was placed in /etc and its purpose was also to document all possible options. The example config file is now installed only in /usr/share/dnf5/dnf5-plugins/automatic.conf. Relax the stage implementation to not fail when the configuration file does not exist. Just log a warning and create the configuration file. Signed-off-by: Tomáš Hozza --- stages/org.osbuild.dnf-automatic.config | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/stages/org.osbuild.dnf-automatic.config b/stages/org.osbuild.dnf-automatic.config index f5a4e960..7f75ee33 100755 --- a/stages/org.osbuild.dnf-automatic.config +++ b/stages/org.osbuild.dnf-automatic.config @@ -25,10 +25,13 @@ def main(tree, options): with open(dnf_automatic_config_path, "r", encoding="utf8") as f: dnf_automatic_conf.readfp(f) except FileNotFoundError: - print(f"Error: DNF automatic configuration file '{dnf_automatic_config_path}' does not exist.") - return 1 + print(f"Warning: DNF automatic configuration file '{dnf_automatic_config_path}'" + + " does not exist, will create a new one.") for config_section, config_options in config.items(): + if not dnf_automatic_conf.has_section(config_section): + dnf_automatic_conf.add_section(config_section) + for option, value in config_options.items(): if isinstance(value, bool): value = bool_to_yes_no(value)