From e8c53640e35220ce35817c067efb788295bbc73c Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Mon, 3 Nov 2014 15:47:57 -0500 Subject: [PATCH] postprocess: Clean up rpmdb detritus These lock and dbenv files are created by RPM when it accesses the database read-write, but we only want read-only. Sadly that turns out to be very, very hard to plumb through all the layers in hawkey/libsolv etc. So let's just forcibily remove them after postprocessing. --- src/rpmostree-postprocess.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/rpmostree-postprocess.c b/src/rpmostree-postprocess.c index 6933c495..9be8a2f8 100644 --- a/src/rpmostree-postprocess.c +++ b/src/rpmostree-postprocess.c @@ -742,6 +742,38 @@ migrate_rpm_and_yumdb (GFile *targetroot, g_file_resolve_relative_path (targetroot, "usr/share/yumdb"); gs_unref_object GFile *yumroot_yumlib = g_file_get_child (yumroot, "var/lib/yum"); + gs_unref_object GFileEnumerator *direnum = NULL; + + direnum = g_file_enumerate_children (legacyrpm_path, "standard::name", + G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, + cancellable, error); + if (!direnum) + goto out; + + while (TRUE) + { + const char *name; + GFileInfo *file_info; + GFile *child; + + if (!gs_file_enumerator_iterate (direnum, &file_info, &child, + cancellable, error)) + goto out; + if (!file_info) + break; + + name = g_file_info_get_name (file_info); + + if (g_str_has_prefix (name, "__db.") || + strcmp (name, ".dbenv.lock") == 0 || + strcmp (name, ".rpm.lock") == 0) + { + if (!gs_file_unlink (child, cancellable, error)) + goto out; + } + } + + (void) g_file_enumerator_close (direnum, cancellable, error); g_print ("Placing RPM db in /usr/share/rpm\n"); if (!gs_file_rename (legacyrpm_path, newrpm_path, cancellable, error))