]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
fedora: move rpmdb content before replacing with symlink
authorLuke Asgill <luke.asgill@gmail.com>
Fri, 26 Aug 2022 02:39:57 +0000 (12:39 +1000)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 26 Oct 2022 20:35:15 +0000 (22:35 +0200)
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 <zbyszek@in.waw.pl>
mkosi/__init__.py

index 6479d4c5f8fd5cf6777505ccf700b0c14b384afd..b1d9094e494c5c4f40cba0d048d340dc2ee6edd8 100644 (file)
@@ -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")