From: Zbigniew Jędrzejewski-Szmek Date: Fri, 10 Jun 2022 15:38:08 +0000 (+0200) Subject: mkosi: link /var/lib/rpm to /usr/lib/sysimage/rpm for compat with old rpm X-Git-Tag: v13~5^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=65b53767fd837259fef0ac6457d2ec0949de0f8c;p=thirdparty%2Fmkosi.git mkosi: link /var/lib/rpm to /usr/lib/sysimage/rpm for compat with old rpm This (partially) fixes #993. There are two aspects of compatiblity: rpm changed the db backend from bdb to sqlite, and the location was changed. This patch resolves the second issue. It does using the same logic that e.g. Fedora uses after the move. But it doesn't do anything for the first part. But luckily, rpm in Rocky/Centos 8 is linked with support for sqlite, so things work. We need to unlink /var/lib/rpm because something creates it during installation. I wanted to just create the symlink if there's nothing there, but that doesn't work. --- diff --git a/mkosi/__init__.py b/mkosi/__init__.py index 6e6143c22..32c862b05 100644 --- a/mkosi/__init__.py +++ b/mkosi/__init__.py @@ -2129,6 +2129,17 @@ def invoke_dnf( shutil.move(cast(str, rpmdb_home), rpmdb) +def link_rpm_db(root: Path) -> None: + """Link /var/lib/rpm to /usr/lib/sysimage/rpm for compat with old rpm""" + rpmdb = root / "usr/lib/sysimage/rpm" + rpmdb_old = root / "var/lib/rpm" + if rpmdb.exists() and not rpmdb_old.is_symlink(): + # We create the symlink in exactly the same fashion that Fedora do + with complete_step("Creating compat symlink /var/lib/rpm → /usr/lib/sysimage/rpm"): + unlink_try_hard(rpmdb_old) + rpmdb_old.symlink_to("../../usr/lib/sysimage/rpm") + + def install_packages_dnf( args: MkosiArgs, root: Path, @@ -3277,6 +3288,11 @@ def install_distribution(args: MkosiArgs, root: Path, do_run_build_script: bool, with mount_cache(args, root): install[args.distribution](args, root, do_run_build_script) + # Link /var/lib/rpm→/usr/lib/sysimage/rpm for compat with old rpm. + # We do this only if the new location is used, which depends on the dnf + # version and configuration on the host. Thus we do this reactively, after the + # installation has completed. + link_rpm_db(root) def remove_packages(args: MkosiArgs, root: Path) -> None: """Remove packages listed in args.remove_packages"""