From fe460068335b4cfe89197b42b1b7e30b84e8ea07 Mon Sep 17 00:00:00 2001
From: Neal Gompa <ngompa13@gmail.com>
Date: Tue, 28 Apr 2020 22:00:04 -0400
Subject: [PATCH] dnf: Load all the repos and vars directories
Historically, the backend has internally determined its setup with
static values. However, we generally want PackageKit to load all
repositories defined in all repository directories that DNF normally
searches, since it is not guaranteed to be in /etc/yum.repos.d and
DNF supports multiple repository configuration paths.
We also need the vars to be loaded so that repository definitions
that rely on more than the built-in vars will work.
This bumps our dependency for libdnf to 0.43.1, as we're using APIs
introduced in this release.
(Backport note: to avoid regenerating autofoo, the configure.ac change
has been stripped.)
(cherry picked from commit ed73aa6317595d2c2f1bda7990cbd64efb133f84)
---
backends/dnf/pk-backend-dnf.c | 27 ++++++++++++++++++++++++---
1 files changed, 24 insertions(+), 3 deletions(-)
diff --git a/backends/dnf/pk-backend-dnf.c b/backends/dnf/pk-backend-dnf.c
index 779896c2d..7fcdaddbe 100644
--- a/backends/dnf/pk-backend-dnf.c
+++ b/backends/dnf/pk-backend-dnf.c
@@ -137,11 +137,12 @@ pk_backend_context_invalidate_cb (DnfContext *context,
static gboolean
pk_backend_setup_dnf_context (DnfContext *context, GKeyFile *conf, const gchar *release_ver, GError **error)
{
+ const gchar * const *repo_dirs;
+ const gchar * const *var_dirs;
gboolean keep_cache;
g_autofree gchar *cache_dir = NULL;
g_autofree gchar *destdir = NULL;
g_autofree gchar *lock_dir = NULL;
- g_autofree gchar *repo_dir = NULL;
g_autofree gchar *solv_dir = NULL;
destdir = g_key_file_get_string (conf, "Daemon", "DestDir", NULL);
@@ -152,12 +153,32 @@ pk_backend_setup_dnf_context (DnfContext *context, GKeyFile *conf, const gchar *
dnf_context_set_cache_dir (context, cache_dir);
solv_dir = g_build_filename (destdir, "/var/cache/PackageKit", release_ver, "hawkey", NULL);
dnf_context_set_solv_dir (context, solv_dir);
- repo_dir = g_build_filename (destdir, "/etc/yum.repos.d", NULL);
- dnf_context_set_repo_dir (context, repo_dir);
lock_dir = g_build_filename (destdir, "/var/run", NULL);
dnf_context_set_lock_dir (context, lock_dir);
dnf_context_set_rpm_verbosity (context, "info");
+ /* Add prefix to repo directories */
+ repo_dirs = dnf_context_get_repos_dir (context);
+ if (repo_dirs != NULL && repo_dirs[0] != NULL) {
+ g_auto(GStrv) full_repo_dirs = NULL;
+ guint len = g_strv_length ((gchar **)repo_dirs);
+ full_repo_dirs = g_new0 (gchar*, len + 1);
+ for (guint i = 0; i < len; i++)
+ full_repo_dirs[i] = g_build_filename (destdir, repo_dirs[i], NULL);
+ dnf_context_set_repos_dir (context, (const gchar * const*)full_repo_dirs);
+ }
+
+ /* Add prefix to var directories */
+ var_dirs = dnf_context_get_vars_dir (context);
+ if (var_dirs != NULL && var_dirs[0] != NULL) {
+ g_auto(GStrv) full_var_dirs = NULL;
+ guint len = g_strv_length ((gchar **)var_dirs);
+ full_var_dirs = g_new0 (gchar*, len + 1);
+ for (guint i = 0; i < len; i++)
+ full_var_dirs[i] = g_build_filename (destdir, var_dirs[i], NULL);
+ dnf_context_set_vars_dir (context, (const gchar * const*)full_var_dirs);
+ }
+
/* use this initial data if repos are not present */
dnf_context_set_vendor_cache_dir (context, "/usr/share/PackageKit/metadata");
dnf_context_set_vendor_solv_dir (context, "/usr/share/PackageKit/hawkey");
--
2.32.0