]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
dnf: Always specify --best again
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Fri, 12 Sep 2025 21:28:10 +0000 (23:28 +0200)
committerLuca Boccassi <luca.boccassi@gmail.com>
Sat, 13 Sep 2025 00:39:46 +0000 (01:39 +0100)
dnf install will not upgrade packages unless --best is specified.
While this might also break downgrades, not upgrading is worse than
not downgrading, so let's specify --best unconditionally again so we
make sure we always upgrade if a newer version is available.

mkosi/installer/dnf.py

index b966dbbafa31e9323d1f84d1f97d10319fe2c6fe..8ad0f6a380e3b4484da8c7a090f8861344924594 100644 (file)
@@ -153,6 +153,7 @@ class Dnf(PackageManager):
         cmdline: list[PathString] = [
             dnf,
             "--assumeyes",
+            "--best",
             f"--releasever={context.config.release}",
             "--installroot=/buildroot",
             "--setopt=keepcache=1",
@@ -215,14 +216,13 @@ class Dnf(PackageManager):
         operation: str,
         arguments: Sequence[str] = (),
         *,
-        options: Sequence[str] = (),
         apivfs: bool = False,
         stdout: _FILE = None,
         cached_metadata: bool = True,
     ) -> CompletedProcess:
         try:
             return run(
-                cls.cmd(context, cached_metadata=cached_metadata) + [*options, operation, *arguments],
+                cls.cmd(context, cached_metadata=cached_metadata) + [operation, *arguments],
                 sandbox=cls.sandbox(context, apivfs=apivfs),
                 env=cls.finalize_environment(context),
                 stdout=stdout,
@@ -245,17 +245,13 @@ class Dnf(PackageManager):
         allow_downgrade: bool = False,
     ) -> None:
         arguments = []
-        options = []
 
-        if allow_downgrade:
-            if Dnf.executable(context.config) == "dnf5":
-                arguments += ["--allow-downgrade"]
-        else:
-            options += ["--best"]
+        if allow_downgrade and Dnf.executable(context.config) == "dnf5":
+            arguments += ["--allow-downgrade"]
 
         arguments += [*packages]
 
-        cls.invoke(context, "install", arguments, options=options, apivfs=apivfs)
+        cls.invoke(context, "install", arguments, apivfs=apivfs)
 
     @classmethod
     def remove(cls, context: Context, packages: Sequence[str]) -> None: