diff --git a/SOURCES/0001-dnf-Load-all-the-repos-and-vars-directories.patch b/SOURCES/0001-dnf-Load-all-the-repos-and-vars-directories.patch new file mode 100644 index 0000000..8c890de --- /dev/null +++ b/SOURCES/0001-dnf-Load-all-the-repos-and-vars-directories.patch @@ -0,0 +1,104 @@ +From 4cef9aa4fb40f39b2b3a0d4a1f3ee87aaef9e10c Mon Sep 17 00:00:00 2001 +From: Neal Gompa +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. This required bumping the CI environment +to Fedora 31. + +(cherry picked from commit ed73aa6317595d2c2f1bda7990cbd64efb133f84) +--- + backends/dnf/pk-backend-dnf.c | 27 ++++++++++++++++++++++++--- + configure.ac | 2 +- + tests/ci/Dockerfile-fedora | 2 +- + 3 files changed, 26 insertions(+), 5 deletions(-) + +diff --git a/backends/dnf/pk-backend-dnf.c b/backends/dnf/pk-backend-dnf.c +index 503a6eb0a..6ce204c24 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"); +diff --git a/configure.ac b/configure.ac +index 3da547561..f0696864a 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -424,7 +424,7 @@ AC_SUBST(DBUS_SYS_DIR) + AC_SUBST(DBUS_SERVICES_DIR) + + if test x$enable_dnf = xyes; then +- PKG_CHECK_MODULES(DNF, appstream-glib libdnf >= 0.22.0 rpm) ++ PKG_CHECK_MODULES(DNF, appstream-glib libdnf >= 0.43.1 rpm) + AC_ARG_WITH(dnf-vendor, + [AS_HELP_STRING([--with-dnf-vendor=],[select a vendor configuration (fedora, mageia, openmandriva, rosa; default is fedora)])]) + if test "$with_dnf_vendor" = "fedora" -o "$with_dnf_vendor" = "mageia" -o "$with_dnf_vendor" = "openmandriva" -o "$with_dnf_vendor" = "rosa"; then +diff --git a/tests/ci/Dockerfile-fedora b/tests/ci/Dockerfile-fedora +index c45a11217..112790e58 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 autoconf-archive gcc make +-- +2.26.2 + diff --git a/SPECS/PackageKit.spec b/SPECS/PackageKit.spec index c37d59c..2d0c168 100644 --- a/SPECS/PackageKit.spec +++ b/SPECS/PackageKit.spec @@ -38,6 +38,13 @@ Patch3: 0001-command-not-found-Don-t-use-a-bash-regex-to-fix-othe.patch # https://bugzilla.redhat.com/show_bug.cgi?id=1814820 Patch4: revert-shutdown-on-idle.patch +# https://bugzilla.redhat.com/show_bug.cgi?id=1847124 +Patch5: 0001-dnf-Load-all-the-repos-and-vars-directories.patch + +# For Patch 5 +BuildRequires: autoconf +BuildRequires: automake + BuildRequires: glib2-devel >= %{glib2_version} BuildRequires: xmlto BuildRequires: gtk-doc @@ -208,6 +215,8 @@ popd export DNF_CFLAGS="-I`pwd`/libdnf-%{commit1} `pkg-config --cflags appstream-glib`" export DNF_LIBS="-L`pwd`/libdnf-%{commit1}/build/libdnf -ldnf -Wl,-rpath=%{_libdir}/PackageKit `pkg-config --libs appstream-glib`" %endif +# Regenerate configure for Patch 5 +autoreconf -fiv %configure \ --disable-static \ --enable-dnf \