]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
centos: Rebuild the rpm db in bdb format on older centos releases
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Tue, 29 Mar 2022 14:30:16 +0000 (16:30 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Tue, 29 Mar 2022 14:30:16 +0000 (16:30 +0200)
When building centos stream 8 images from Fedora, the resulting rpmdb
in the image is written in the sqlite format. The rpm version available
in centos stream 8 only supports reading the sqlite format but not writing
to it, which effectively makes installing rpm packages in the resulting
image impossible.

As a temporary workaround, we run rpm --rebuilddb inside the image to rebuild
the db in the older bdb format. Ideally we'd use the rpm from the host for this
but rpm has removed bdb support in newer versions so this isn't possible.

Luckily, we can remove this hack once we remove support for centos stream 8
and lower.

mkosi/__init__.py

index 1cc54386b54b83c0c71723bc198eefef4e37e47f..0701c84650b9ccf7ef3b82e20ba6083cbf81a183 100644 (file)
@@ -2583,6 +2583,15 @@ def install_centos(args: MkosiArgs, root: Path, do_run_build_script: bool) -> No
 
     install_packages_dnf(args, root, packages, do_run_build_script)
 
+    # Centos Stream 8 and below can't write to the sqlite db backend used by
+    # default in newer RPM releases so let's rebuild the DB to use the old bdb
+    # backend instead. Because newer RPM releases have dropped support for the
+    # bdb backend completely, we check if rpm is installed and use
+    # run_workspace_command() to rebuild the rpm db.
+    if epel_release <= 8 and root.joinpath("usr/bin/rpm").exists():
+        cmdline = ["rpm", "--rebuilddb", "--define", "_db_backend bdb"]
+        run_workspace_command(args, root, cmdline)
+
 
 @complete_step("Installing Rocky Linux…")
 def install_rocky(args: MkosiArgs, root: Path, do_run_build_script: bool) -> None: