From: Mihai Moldovan Date: Tue, 29 Sep 2020 16:30:16 +0000 (+0200) Subject: [PATCH] Add rpmdb in home directory to checksum and DNF context setup function. X-Git-Tag: archive/raspbian/0.73.1-3+rpi1^2^2~7 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=c1ad42d1ea0e044256b6d388a2e1af7a8201a310;p=libdnf.git [PATCH] Add rpmdb in home directory to checksum and DNF context setup function. The rpm package on Debian is patched to always use the RPMDB in a user's home directory. Tell the checksumming and DNF context setup function to prefer the rpmdb in the user's home directory. Gbp-Pq: Name 0006-Add-rpmdb-in-home-directory-to-checksum-and-DNF-cont.patch --- diff --git a/libdnf/dnf-context.cpp b/libdnf/dnf-context.cpp index 97d1c59..cc2822f 100644 --- a/libdnf/dnf-context.cpp +++ b/libdnf/dnf-context.cpp @@ -2271,12 +2271,33 @@ dnf_context_setup(DnfContext *context, /* setup a file monitor on the rpmdb, if we're operating on the native / */ if (g_strcmp0(priv->install_root, "/") == 0) { - rpmdb_path = g_build_filename(priv->install_root, "var/lib/rpm/Packages", NULL); - file_rpmdb = g_file_new_for_path(rpmdb_path); - priv->monitor_rpmdb = g_file_monitor_file(file_rpmdb, - G_FILE_MONITOR_NONE, - NULL, - error); + /* Try home directory first. */ + gchar *home_dir = g_strdup(g_get_home_dir()); + + priv->monitor_rpmdb = NULL; + + if (home_dir) { + rpmdb_path = g_build_filename(priv->install_root, home_dir, ".rpmdb/Packages", NULL); + + g_free(home_dir); + home_dir = NULL; + + file_rpmdb = g_file_new_for_path(rpmdb_path); + priv->monitor_rpmdb = g_file_monitor_file(file_rpmdb, + G_FILE_MONITOR_NONE, + NULL, + error); + } + + if (!priv->monitor_rpmdb) { + rpmdb_path = g_build_filename(priv->install_root, "var/lib/rpm/Packages", NULL); + file_rpmdb = g_file_new_for_path(rpmdb_path); + priv->monitor_rpmdb = g_file_monitor_file(file_rpmdb, + G_FILE_MONITOR_NONE, + NULL, + error); + } + if (priv->monitor_rpmdb == NULL) return FALSE; g_signal_connect(priv->monitor_rpmdb, "changed", diff --git a/libdnf/dnf-utils.cpp b/libdnf/dnf-utils.cpp index 874282c..2ae179b 100644 --- a/libdnf/dnf-utils.cpp +++ b/libdnf/dnf-utils.cpp @@ -32,6 +32,8 @@ #include #include #include +#include +#include #include "catch-error.hpp" #include "dnf-types.h"