[PATCH] Add rpmdb in home directory to checksum and DNF context setup function.
authorMihai Moldovan <ionic@ionic.de>
Tue, 29 Sep 2020 16:30:16 +0000 (18:30 +0200)
committerLuca Boccassi <bluca@debian.org>
Fri, 3 Nov 2023 19:22:17 +0000 (19:22 +0000)
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

libdnf/dnf-context.cpp
libdnf/dnf-utils.cpp

index 97d1c599451c2fd058bf42dc48f39e07784c02ff..cc2822fb5801c14a64fff4fac59d791d7a6f0a63 100644 (file)
@@ -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",
index 874282cfae8be12ead020999431ec0c4bce64d30..2ae179bc952df0780685b02316ce142495b6c69a 100644 (file)
@@ -32,6 +32,8 @@
 #include <errno.h>
 #include <stdlib.h>
 #include <glib/gstdio.h>
+#include <unistd.h>
+#include <pwd.h>
 
 #include "catch-error.hpp"
 #include "dnf-types.h"