From: Daan De Meyer Date: Wed, 5 Jun 2024 07:29:50 +0000 (+0200) Subject: dnf: Enable versionlock plugin by default X-Git-Tag: v23.1~28 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4d305e3ceef6fc5d5fdc7f62eea0767e940c9f13;p=thirdparty%2Fmkosi.git dnf: Enable versionlock plugin by default 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=. --- diff --git a/mkosi/installer/dnf.py b/mkosi/installer/dnf.py index f6338b00b..f078da367 100644 --- a/mkosi/installer/dnf.py +++ b/mkosi/installer/dnf.py @@ -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"]