]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Use hosts preferred dnf version in mkosi-initrd 3323/head
authorSeptatrix <24257556+Septatrix@users.noreply.github.com>
Wed, 8 Jan 2025 21:20:14 +0000 (22:20 +0100)
committerSeptatrix <24257556+Septatrix@users.noreply.github.com>
Wed, 8 Jan 2025 23:28:30 +0000 (00:28 +0100)
mkosi/initrd.py

index 8efa0142d004d02b4cedea750a501ea64ed46daf..6673605a00551fcfe1c1c8bba6edab4da31f5fe4 100644 (file)
@@ -200,13 +200,14 @@ def main() -> None:
         if Path("/etc/kernel/cmdline").exists():
             cmdline += ["--kernel-command-line", Path("/etc/kernel/cmdline").read_text()]
 
-        # Prefer dnf as dnf5 has not yet officially replaced it and there's a much bigger chance that there
-        # will be a populated dnf cache directory.
+        # Resolve dnf binary to determine which version the host uses by default
+        # (to avoid preferring dnf5 if the host uses dnf4)
+        # as there's a much bigger chance that it has a populated dnf cache directory.
         run(
             cmdline,
             stdin=sys.stdin,
             stdout=sys.stdout,
-            env={"MKOSI_DNF": dnf.name} if (dnf := find_binary("dnf", "dnf5")) else {},
+            env={"MKOSI_DNF": dnf.resolve().name} if (dnf := find_binary("dnf")) else {},
         )
 
         if args.output_dir: