From 6f1ba75d60fbab85eab4738a56d1619630dbc42f Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Tue, 25 Feb 2025 18:46:16 +0100 Subject: [PATCH] Enable Hyperscale rpm COW plugin The CentOS Hyperscale SIG provides rpm/dnf plugins to enable rpm COW which drastically speeds up image builds so let's ship the necessary logic to make use of it when building images with the Hyperscale experimental repositories. --- mkosi/installer/dnf.py | 16 +++++++++++++++- .../20-hyperscale-experimental-packages.conf | 9 +++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 mkosi/resources/mkosi-tools/mkosi.conf.d/centos/mkosi.conf.d/20-hyperscale-experimental-packages.conf diff --git a/mkosi/installer/dnf.py b/mkosi/installer/dnf.py index af5de1452..13b97edff 100644 --- a/mkosi/installer/dnf.py +++ b/mkosi/installer/dnf.py @@ -62,6 +62,20 @@ class Dnf(PackageManager): if cls.executable(context.config) == "dnf5" and filelists: f.write("[main]\noptional_metadata_types=filelists\n") + # The CentOS Hyperscale ships a COW plugin for dnf that's disabled by default. Let's enable it so we + # can take advantage of faster rpm package installations. + reflink = context.sandbox_tree / "etc/dnf/plugins/reflink.conf" + if not reflink.exists(): + reflink.parent.mkdir(parents=True, exist_ok=True) + reflink.write_text( + textwrap.dedent( + """\ + [main] + enabled=1 + """ + ) + ) + # 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.sandbox_tree / "etc/dnf/plugins/versionlock.conf" @@ -140,7 +154,7 @@ class Dnf(PackageManager): "--disable-plugin=*" if dnf == "dnf5" else "--disableplugin=*", ] # fmt: skip - for plugin in ("builddep", "versionlock"): + for plugin in ("builddep", "versionlock", "reflink"): cmdline += ["--enable-plugin", plugin] if dnf == "dnf5" else ["--enableplugin", plugin] if ARG_DEBUG.get(): diff --git a/mkosi/resources/mkosi-tools/mkosi.conf.d/centos/mkosi.conf.d/20-hyperscale-experimental-packages.conf b/mkosi/resources/mkosi-tools/mkosi.conf.d/centos/mkosi.conf.d/20-hyperscale-experimental-packages.conf new file mode 100644 index 000000000..4ddeff6f9 --- /dev/null +++ b/mkosi/resources/mkosi-tools/mkosi.conf.d/centos/mkosi.conf.d/20-hyperscale-experimental-packages.conf @@ -0,0 +1,9 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later + +[Match] +Repositories=hyperscale-packages-experimental + +[Content] +Packages= + rpm-plugin-reflink + python3-dnf-plugin-cow -- 2.47.2