]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Fix bootstrapping RPM distro on Debian
authorLuca Boccassi <bluca@debian.org>
Tue, 29 Mar 2022 00:43:40 +0000 (01:43 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 4 Apr 2022 19:33:26 +0000 (21:33 +0200)
The Debian rpm/dnf packages store the db in the home directory, so
the bootstrapped image has a broken rpm database.
Move it to the right place if it happens.

See: https://bugs.debian.org/1004863

Fixes https://github.com/systemd/mkosi/issues/934

mkosi/__init__.py

index 47f1b1ff93a6e51b12a1a31b7489d5185db6702f..d529c081b4130525eb076f5d6879aee9b528324d 100644 (file)
@@ -2015,6 +2015,22 @@ def invoke_dnf(
     with mount_api_vfs(args, root):
         run(cmdline)
 
+    distribution, release = detect_distribution()
+    if distribution not in (Distribution.debian, Distribution.ubuntu):
+        return
+
+    # On Debian, rpm/dnf ship with a patch to store the rpmdb under ~/
+    # so it needs to be copied back in the right location, otherwise
+    # the rpmdb will be broken. See: https://bugs.debian.org/1004863
+    rpmdb_home = root / "root/.rpmdb"
+    if rpmdb_home.exists():
+        # Take into account the new location in F36
+        rpmdb = root / "usr/lib/sysimage/rpm"
+        if not rpmdb.exists():
+            rpmdb = root / "var/lib/rpm"
+        unlink_try_hard(rpmdb)
+        shutil.move(cast(str, rpmdb_home), rpmdb)
+
 
 def install_packages_dnf(
     args: MkosiArgs,