]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
dnf: Enable versionlock plugin by default
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 5 Jun 2024 07:29:50 +0000 (09:29 +0200)
committerJörg Behrmann <behrmann@physik.fu-berlin.de>
Wed, 5 Jun 2024 08:15:48 +0000 (10:15 +0200)
Let's allow users to make use of the versionlock plugin by enabling
it by default. To make sure it doesn't fail, we write a noop
configuration that makes the plugin do nothing at all which users
can then override using PackageManagerTrees=.

mkosi/installer/dnf.py

index f6338b00b623d11815d388598f5eca55cb556c35..f078da367ae53d0a65fedbea882b2229d6b4bc2e 100644 (file)
@@ -60,6 +60,21 @@ class Dnf(PackageManager):
                 if cls.executable(context.config).endswith("dnf5") and filelists:
                     f.write("[main]\noptional_metadata_types=filelists\n")
 
+        # The versionlock plugin will fail if enabled without a configuration file so lets' write a noop configuration
+        # file to make it happy which can be overridden by users.
+        versionlock = context.pkgmngr / "etc/dnf/plugins/versionlock.conf"
+        if not versionlock.exists():
+            versionlock.parent.mkdir(parents=True, exist_ok=True)
+            versionlock.write_text(
+                textwrap.dedent(
+                    """\
+                    [main]
+                    enabled=0
+                    locklist=/dev/null
+                    """
+                )
+            )
+
         repofile = context.pkgmngr / "etc/yum.repos.d/mkosi.repo"
         if not repofile.exists():
             repofile.parent.mkdir(exist_ok=True, parents=True)
@@ -113,9 +128,11 @@ class Dnf(PackageManager):
             f"--setopt=install_weak_deps={int(context.config.with_recommends)}",
             "--setopt=check_config_file_age=0",
             "--disable-plugin=*" if dnf.endswith("dnf5") else "--disableplugin=*",
-            "--enable-plugin=builddep" if dnf.endswith("dnf5") else "--enableplugin=builddep",
         ]
 
+        for plugin in ("builddep", "versionlock"):
+            cmdline += ["--enable-plugin", plugin] if dnf.endswith("dnf5") else ["--enableplugin", plugin]
+
         if ARG_DEBUG.get():
             cmdline += ["--setopt=debuglevel=10"]