From 732643f3c366cb76e644810677e98428b94ce3ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= Date: Tue, 23 Apr 2024 09:40:41 +0200 Subject: [PATCH] Fix preferring the lowest-cost repositories on a reinstallation --- .dnf.metadata | 1 + ...l-candidates-for-reinstall-to-solver.patch | 79 +++++++++++++++++++ dnf.spec | 6 +- 3 files changed, 85 insertions(+), 1 deletion(-) create mode 100644 .dnf.metadata create mode 100644 0015-Add-all-candidates-for-reinstall-to-solver.patch diff --git a/.dnf.metadata b/.dnf.metadata new file mode 100644 index 0000000..34138ea --- /dev/null +++ b/.dnf.metadata @@ -0,0 +1 @@ +0697aee277730c57446b5b87bdb12456cf245203 dnf-4.14.0.tar.gz diff --git a/0015-Add-all-candidates-for-reinstall-to-solver.patch b/0015-Add-all-candidates-for-reinstall-to-solver.patch new file mode 100644 index 0000000..8829239 --- /dev/null +++ b/0015-Add-all-candidates-for-reinstall-to-solver.patch @@ -0,0 +1,79 @@ +From 0592ff47bc1b9029eb9b25d59410062038fdacd3 Mon Sep 17 00:00:00 2001 +From: Jaroslav Mracek +Date: Thu, 15 Feb 2024 11:28:59 +0100 +Subject: [PATCH] Add all candidates for reinstall to solver +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Upstream commit: 96f8d79c37e119ff56f730797865121b63241a6b +Resolves: https://issues.redhat.com/browse/RHEL-25005 + +Signed-off-by: Petr Písař +--- + dnf/base.py | 9 ++++++--- + dnf/query.py | 5 ++++- + tests/test_queries.py | 7 ++++++- + 3 files changed, 16 insertions(+), 5 deletions(-) + +diff --git a/dnf/base.py b/dnf/base.py +index 50869ec4..adb5ad6f 100644 +--- a/dnf/base.py ++++ b/dnf/base.py +@@ -2333,19 +2333,22 @@ class Base(object): + + if not installed_pkgs: + raise dnf.exceptions.PackagesNotInstalledError( +- 'no package matched', pkg_spec, available_nevra2pkg.values()) ++ 'no package matched', pkg_spec, available_q.run()) + + cnt = 0 + clean_deps = self.conf.clean_requirements_on_remove ++ strict = self.conf.strict + for installed_pkg in installed_pkgs: + try: +- available_pkg = available_nevra2pkg[ucd(installed_pkg)] ++ available_pkgs = available_nevra2pkg[ucd(installed_pkg)] + except KeyError: + if not remove_na: + continue + self._goal.erase(installed_pkg, clean_deps=clean_deps) + else: +- self._goal.install(available_pkg) ++ sltr = dnf.selector.Selector(self.sack) ++ sltr.set(pkg=available_pkgs) ++ self._goal.install(select=sltr, optional=(not strict)) + cnt += 1 + + if cnt == 0: +diff --git a/dnf/query.py b/dnf/query.py +index ab4139bf..02e631a6 100644 +--- a/dnf/query.py ++++ b/dnf/query.py +@@ -43,4 +43,7 @@ def _by_provides(sack, patterns, ignore_case=False, get_query=False): + return q.run() + + def _per_nevra_dict(pkg_list): +- return {ucd(pkg):pkg for pkg in pkg_list} ++ nevra_dic = {} ++ for pkg in pkg_list: ++ nevra_dic.setdefault(ucd(pkg), []).append(pkg) ++ return nevra_dic +diff --git a/tests/test_queries.py b/tests/test_queries.py +index cdcb7ca4..e0253008 100644 +--- a/tests/test_queries.py ++++ b/tests/test_queries.py +@@ -128,4 +128,9 @@ class DictsTest(tests.support.TestCase): + dct = dnf.query._per_nevra_dict(pkgs) + self.assertCountEqual(dct.keys(), + ["lotus-3-16.x86_64", "lotus-3-16.i686"]) +- self.assertCountEqual(dct.values(), pkgs) ++ test_list = [] ++ for list_items in dct.values(): ++ for item in list_items: ++ test_list.append(item) ++ ++ self.assertCountEqual(test_list, pkgs) +-- +2.44.0 + diff --git a/dnf.spec b/dnf.spec index 3a4f109..f952772 100644 --- a/dnf.spec +++ b/dnf.spec @@ -69,7 +69,7 @@ It supports RPMs, modules and comps groups & environments. Name: dnf Version: 4.14.0 -Release: 9%{?dist} +Release: 10%{?dist} Summary: %{pkg_summary} # For a breakdown of the licensing, see PACKAGE-LICENSING License: GPLv2+ @@ -89,6 +89,7 @@ Patch11: 0011-Document-symbols-in-dnf-history-list-output.patch Patch12: 0012-RHEL-11345-Fix-japanese-translations.patch Patch13: 0013-RHEL-6396-Fix-substitution-in-kvp-in-add_new_repo.patch Patch14: 0014-RHEL-6304-base-Add-obsoleters-of-only-latest-versions.patch +Patch15: 0015-Add-all-candidates-for-reinstall-to-solver.patch BuildArch: noarch BuildRequires: cmake @@ -377,6 +378,9 @@ popd %{python3_sitelib}/%{name}/automatic/ %changelog +* Tue Apr 23 2024 Petr Pisar - 4.14.0-10 +- Fix preferring the lowest-cost repositories on a reinstallation (RHEL-25005) + * Wed Oct 25 2023 Jaroslav Rohel - 4.14.0-9 - Fix japanese translations (RHEL-11345) - Fix substitution in kay-value-pair list in add_new_repo (RHEL-6396)