summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeal Gompa <ngompa13@gmail.com>2020-04-28 22:00:04 -0400
committerNeal Gompa (ニール・ゴンパ) <ngompa13@gmail.com>2020-04-28 22:00:48 -0400
commited73aa6317595d2c2f1bda7990cbd64efb133f84 (patch)
tree5304286480d396868abd085f7a9703a164e838ae
parent0487f26a55a7db0bcaca46cf4c1a022de90ca07d (diff)
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. This required bumping the CI environment to Fedora 31.
-rw-r--r--backends/dnf/meson.build2
-rw-r--r--backends/dnf/pk-backend-dnf.c27
-rw-r--r--tests/ci/Dockerfile-fedora2
3 files changed, 26 insertions, 5 deletions
diff --git a/backends/dnf/meson.build b/backends/dnf/meson.build
index bf390fdc5..d24c1b493 100644
--- a/backends/dnf/meson.build
+++ b/backends/dnf/meson.build
@@ -1,5 +1,5 @@
appstream_dep = dependency('appstream-glib')
-dnf_dep = dependency('libdnf', version: '>=0.22.0')
+dnf_dep = dependency('libdnf', version: '>=0.43.1')
rpm_dep = dependency('rpm')
shared_module(
diff --git a/backends/dnf/pk-backend-dnf.c b/backends/dnf/pk-backend-dnf.c
index 842a8827c..74d35c34c 100644
--- a/backends/dnf/pk-backend-dnf.c
+++ b/backends/dnf/pk-backend-dnf.c
@@ -135,11 +135,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);
@@ -150,12 +151,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");
diff --git a/tests/ci/Dockerfile-fedora b/tests/ci/Dockerfile-fedora
index 28747b3dd..d2d626d74 100644
--- a/tests/ci/Dockerfile-fedora
+++ b/tests/ci/Dockerfile-fedora
@@ -1,4 +1,4 @@
-FROM fedora:29
+FROM fedora:31
RUN dnf -y update
RUN dnf -y install dnf-plugins-core libdnf-devel redhat-rpm-config meson gcc ninja-build