From: Luke Asgill Date: Fri, 26 Aug 2022 02:39:57 +0000 (+1000) Subject: fedora: move rpmdb content before replacing with symlink X-Git-Tag: v14~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8650beb790004b816380c3bf8af5f2b781fd84af;p=thirdparty%2Fmkosi.git fedora: move rpmdb content before replacing with symlink Fixes #1113: building a Fedora 36 image using mkosi 13 on Fedora 35 results in circular symlinks between /var/lib/rpm and /usr/lib/sysimage/rpm. Co-authored-by: Zbigniew Jędrzejewski-Szmek --- diff --git a/mkosi/__init__.py b/mkosi/__init__.py index 6479d4c5f..b1d9094e4 100644 --- a/mkosi/__init__.py +++ b/mkosi/__init__.py @@ -2008,9 +2008,13 @@ def link_rpm_db(root: Path) -> None: 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) + # Move content, if any, from the old location to the new one + if rpmdb_old.exists(): + unlink_try_hard(rpmdb) + shutil.move(cast(str, rpmdb_old), rpmdb) + + # Create the symlink in exactly the same fashion that Fedora does rpmdb_old.symlink_to("../../usr/lib/sysimage/rpm")