diff --git a/Fix-listing-a-repository-without-cpeid.patch b/Fix-listing-a-repository-without-cpeid.patch new file mode 100644 index 0000000000000000000000000000000000000000..8b49095f62b03116ed9f87c6b4c8298241e5d4a7 --- /dev/null +++ b/Fix-listing-a-repository-without-cpeid.patch @@ -0,0 +1,35 @@ +From a361dabddcc342ef3c0d4023f8500b16364889a3 Mon Sep 17 00:00:00 2001 +From: Jan Kolarik +Date: Wed, 10 Aug 2022 05:21:38 +0000 +Subject: [PATCH] Fix listing a repository without cpeid (RhBug:2066334) + +Conflict:NA +Reference:https://github.com/rpm-software-management/libdnf/commit/a361dabddcc342ef3c0d4023f8500b16364889a3 + += changelog = +type: bugfix +resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2066334 +--- + libdnf/repo/Repo.cpp | 9 +++++++-- + 1 file changed, 7 insertions(+), 2 deletions(-) + +diff --git a/libdnf/repo/Repo.cpp b/libdnf/repo/Repo.cpp +index e1d5529327..557f727fdf 100644 +--- a/libdnf/repo/Repo.cpp ++++ b/libdnf/repo/Repo.cpp +@@ -1031,8 +1031,13 @@ bool Repo::Impl::loadCache(bool throwExcept, bool ignoreMissing) + for (auto elem = yum_repomd->distro_tags; elem; elem = g_slist_next(elem)) { + if (elem->data) { + auto distroTag = static_cast(elem->data); +- if (distroTag->tag) +- distro_tags.emplace_back(distroTag->cpeid, distroTag->tag); ++ if (distroTag->tag) { ++ std::string cpeid_str; ++ if (distroTag->cpeid) { ++ cpeid_str = distroTag->cpeid; ++ } ++ distro_tags.emplace_back(std::move(cpeid_str), distroTag->tag); ++ } + } + } + diff --git a/add-unittest-for-setting-up-repo-with-empty-keyfile.patch b/add-unittest-for-setting-up-repo-with-empty-keyfile.patch new file mode 100644 index 0000000000000000000000000000000000000000..6c3312d94cec681e2ef0815a3f9a27991239b71f --- /dev/null +++ b/add-unittest-for-setting-up-repo-with-empty-keyfile.patch @@ -0,0 +1,59 @@ +From e250992c0be4b555c2dd6ef3ed89ab86892027ee Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Ale=C5=A1=20Mat=C4=9Bj?= +Date: Tue, 26 Oct 2021 09:33:51 +0200 +Subject: [PATCH] Add unittest for setting up repo with empty keyfile + (RhBug:1994614) + +Reference:https://github.com/rpm-software-management/libdnf/commit/e250992c0be4b555c2dd6ef3ed89ab86892027ee +Conflict:NA + +The test ensures we don't crash when the keyfile is empty/not loaded. +Test for: https://github.com/rpm-software-management/libdnf/commit/be66d0908d939ddaf3022c5489012bd1dbdb0075 + +RHEL bug: +https://bugzilla.redhat.com/show_bug.cgi?id=1994614 +Fedora bug: +https://bugzilla.redhat.com/show_bug.cgi?id=1946024 +--- + tests/libdnf/dnf-self-test.c | 21 +++++++++++++++++++++ + 1 file changed, 21 insertions(+) + +diff --git a/tests/libdnf/dnf-self-test.c b/tests/libdnf/dnf-self-test.c +index 32a21e6628..5295837192 100644 +--- a/tests/libdnf/dnf-self-test.c ++++ b/tests/libdnf/dnf-self-test.c +@@ -199,6 +199,26 @@ ch_test_repo_func(void) + g_object_unref(context); + } + ++static void ++dnf_repo_setup_with_empty_keyfile(void) ++{ ++ DnfContext *context = dnf_context_new(); ++ dnf_context_set_release_ver(context, "33"); ++ DnfRepo *repo = dnf_repo_new(context); ++ GKeyFile *empty_key_file = g_key_file_new(); ++ ++ dnf_repo_set_keyfile(repo, empty_key_file); ++ ++ GError *error = NULL; ++ // Empty key file is not an errror, there is just no configuration to be loaded. ++ g_assert(dnf_repo_setup(repo, &error)); ++ g_assert_no_error(error); ++ ++ g_object_unref(repo); ++ g_object_unref(context); ++ g_key_file_free(empty_key_file); ++} ++ + static guint _allow_cancel_updates = 0; + static guint _action_updates = 0; + static guint _package_progress_updates = 0; +@@ -1217,6 +1237,7 @@ main(int argc, char **argv) + g_test_add_func("/libdnf/lock", dnf_lock_func); + g_test_add_func("/libdnf/lock[threads]", dnf_lock_threads_func); + g_test_add_func("/libdnf/repo", ch_test_repo_func); ++ g_test_add_func("/libdnf/repo_empty_keyfile", dnf_repo_setup_with_empty_keyfile); + g_test_add_func("/libdnf/state", dnf_state_func); + g_test_add_func("/libdnf/state[child]", dnf_state_child_func); + g_test_add_func("/libdnf/state[parent-1-step]", dnf_state_parent_one_step_proxy_func); diff --git a/gracefully-handle-failure-to-open-repo-primary-file.patch b/gracefully-handle-failure-to-open-repo-primary-file.patch new file mode 100644 index 0000000000000000000000000000000000000000..41f566d1bd703e37d15451604f26ebd0637400ee --- /dev/null +++ b/gracefully-handle-failure-to-open-repo-primary-file.patch @@ -0,0 +1,36 @@ +From eff7e688e2f1ad5d10a5ed05948c08141083f316 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Hr=C3=A1zk=C3=BD?= +Date: Mon, 20 Jun 2022 16:02:11 +0200 +Subject: [PATCH] Gracefully handle failure to open repo primary file + +Reference:https://github.com/rpm-software-management/libdnf/commit/eff7e688e2f1ad5d10a5ed05948c08141083f316 +Conflict:NA + +--- + libdnf/dnf-sack.cpp | 10 +++++++++- + 1 file changed, 9 insertions(+), 1 deletion(-) + +diff --git a/libdnf/dnf-sack.cpp b/libdnf/dnf-sack.cpp +index a88e8a1..a89fc15 100644 +--- a/libdnf/dnf-sack.cpp ++++ b/libdnf/dnf-sack.cpp +@@ -718,7 +718,15 @@ load_yum_repo(DnfSack *sack, HyRepo hrepo, GError **error) + goto out; + } + fp_primary = solv_xfopen(primary.c_str(), "r"); +- assert(fp_primary); ++ if (fp_primary == 0) { ++ g_set_error(error, ++ DNF_ERROR, ++ DNF_ERROR_INTERNAL_ERROR, ++ _("Opening repository primary data has failed: %s"), ++ strerror(errno)); ++ retval = FALSE; ++ goto out; ++ } + + g_debug("fetching %s", name); + if (repo_add_repomdxml(repo, fp_repomd, 0) || \ +-- +2.23.0 + diff --git a/libdnf.spec b/libdnf.spec index 9f5c8bb8165b231bb5a39035eb5a13d4d8fa8a6e..05afa25fc26eb71c1d16178a3e0b5e7b2c58fc7c 100644 --- a/libdnf.spec +++ b/libdnf.spec @@ -18,12 +18,16 @@ Name: libdnf Version: 0.65.0 -Release: 2 +Release: 3 Summary: Library providing simplified C and Python API to libsolv License: LGPLv2+ URL: https://github.com/rpm-software-management/libdnf Source0: %{url}/archive/%{version}/%{name}-%{version}.tar.gz +Patch6000: add-unittest-for-setting-up-repo-with-empty-keyfile.patch +Patch6001: gracefully-handle-failure-to-open-repo-primary-file.patch +Patch6002: Fix-listing-a-repository-without-cpeid.patch + BuildRequires: cmake gcc gcc-c++ libsolv-devel >= %{libsolv_version} gettext BuildRequires: pkgconfig(librepo) >= %{librepo_version} pkgconfig(check) BuildRequires: pkgconfig(gio-unix-2.0) >= 2.46.0 pkgconfig(gtk-doc) gpgme-devel @@ -118,6 +122,9 @@ popd %{python3_sitearch}/hawkey/ %changelog +* Tue Sep 20 2022 zhangrui - 0.65.0-3 +- DESC:backport patches fix listing a repository without cpeid + * Tue Dec 28 2021 hanhui - 0.65.0-2 - DESC:fix libdnf upgrade failed