From 4337cd9595fe4b126e6a68761b9d603d2aa7b267 Mon Sep 17 00:00:00 2001 From: Simon de Vlieger Date: Thu, 16 Jan 2025 11:32:06 +0100 Subject: [PATCH] solver/dnf4: structured data Instead of returning the string contents of the module configuration file let's return some more structured data so the resulting file can be written with a stage. Note that we don't do the same for the fallback file as we are only provided this as a YAML blob and unparsing it to then immediately reparse it again is counterproductive. Signed-off-by: Simon de Vlieger --- osbuild/solver/dnf.py | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/osbuild/solver/dnf.py b/osbuild/solver/dnf.py index bda015ce..9ac56ca7 100755 --- a/osbuild/solver/dnf.py +++ b/osbuild/solver/dnf.py @@ -5,7 +5,6 @@ import itertools import os import os.path import tempfile -import textwrap from datetime import datetime from typing import Dict, List @@ -403,18 +402,15 @@ class DNF(SolverBase): # repository is disabled or disappears that non-modular content can't be installed # see: https://dnf.readthedocs.io/en/latest/modularity.html#fail-safe-mechanisms for module_ns, (module, profiles) in modules.items(): - profiles = ",".join(profiles) if profiles else "" - response["modules"][module.getName()] = { "module-file": { - "data": textwrap.dedent(f"""\ - [{module.getName()}] - name={module.getName()} - stream={module.getStream()} - profiles={profiles} - state=enabled - """), "path": f"/etc/dnf/modules.d/{module.getName()}.conf", + "data": { + "name": module.getName(), + "stream": module.getStream(), + "profiles": list(profiles), + "state": "enabled", + } }, "failsafe-file": { "data": module.getYaml(),