diff --git a/backport-Add-all-candidates-for-reinstall-to-solver.patch b/backport-Add-all-candidates-for-reinstall-to-solver.patch new file mode 100644 index 0000000000000000000000000000000000000000..9cc326402eb4d18b7f01157430ec5e09de1da317 --- /dev/null +++ b/backport-Add-all-candidates-for-reinstall-to-solver.patch @@ -0,0 +1,73 @@ +From 96f8d79c37e119ff56f730797865121b63241a6b 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 + +Resolves: https://issues.redhat.com/browse/RHEL-25005 + +Conflict:NA +Reference:https://github.com/rpm-software-management/dnf/commit/96f8d79c37e119ff56f730797865121b63241a6b +--- + 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 9b59b9d7e5..552d53f4c7 100644 +--- a/dnf/base.py ++++ b/dnf/base.py +@@ -2336,19 +2336,22 @@ def reinstall(self, pkg_spec, old_reponame=None, new_reponame=None, + + 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 ab4139bf9a..02e631a6ec 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 cdcb7ca453..e025300879 100644 +--- a/tests/test_queries.py ++++ b/tests/test_queries.py +@@ -128,4 +128,9 @@ def test_per_nevra_dict(self): + 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) diff --git a/backport-remove-duplicates-when-no-duplicates-exit-with-0.patch b/backport-remove-duplicates-when-no-duplicates-exit-with-0.patch new file mode 100644 index 0000000000000000000000000000000000000000..10c01807a09d215e7ad8010d655ef8e58f7a8c54 --- /dev/null +++ b/backport-remove-duplicates-when-no-duplicates-exit-with-0.patch @@ -0,0 +1,32 @@ +From 720338fed8124b120b56cc99cc0b13dfe48ffe95 Mon Sep 17 00:00:00 2001 +From: Pavla Kratochvilova +Date: Fri, 5 Apr 2024 14:42:38 +0200 +Subject: [PATCH] remove --duplicates: when no duplicates, exit with 0 + (RHEL-6424) + +If no duplicates are present, then the command succesfully removed all +duplicates and should exit with 0 and write the message to stdout +instead of stderr. + +Resolves: https://issues.redhat.com/browse/RHEL-6424 + +Conflict:NA +Reference:https://github.com/rpm-software-management/dnf/commit/720338fed8124b120b56cc99cc0b13dfe48ffe95 +--- + dnf/cli/commands/remove.py | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/dnf/cli/commands/remove.py b/dnf/cli/commands/remove.py +index e455ba6e61..af9622fdef 100644 +--- a/dnf/cli/commands/remove.py ++++ b/dnf/cli/commands/remove.py +@@ -92,7 +92,8 @@ def run(self): + instonly = self.base._get_installonly_query(q.installed()) + dups = q.duplicated().difference(instonly) + if not dups: +- raise dnf.exceptions.Error(_('No duplicated packages found for removal.')) ++ logger.info(_('No duplicated packages found for removal.')) ++ return + + for (name, arch), pkgs_list in dups._na_dict().items(): + if len(pkgs_list) < 2: diff --git a/backport-remove-oldinstallonly-when-no-old-installonly-packages-exit-with-0.patch b/backport-remove-oldinstallonly-when-no-old-installonly-packages-exit-with-0.patch new file mode 100644 index 0000000000000000000000000000000000000000..111e2553c7d5734a6b31415cd0f11029fb660608 --- /dev/null +++ b/backport-remove-oldinstallonly-when-no-old-installonly-packages-exit-with-0.patch @@ -0,0 +1,30 @@ +From 87eb5a7a3561381b5ef5e70548f49288251300fc Mon Sep 17 00:00:00 2001 +From: Pavla Kratochvilova +Date: Fri, 5 Apr 2024 14:43:04 +0200 +Subject: [PATCH] remove --oldinstallonly: when no old installonly packages, + exit with 0 + +If no old installonly packages are present, then the command succesfully +removed all of them and should exit with 0 and write the message to +stdout instead of stderr. + +Conflict:NA +Reference:https://github.com/rpm-software-management/dnf/commit/87eb5a7a3561381b5ef5e70548f49288251300fc +--- + dnf/cli/commands/remove.py | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +diff --git a/dnf/cli/commands/remove.py b/dnf/cli/commands/remove.py +index af9622fdef..32e78d6d4d 100644 +--- a/dnf/cli/commands/remove.py ++++ b/dnf/cli/commands/remove.py +@@ -124,8 +124,7 @@ def run(self): + for pkg in instonly: + self.base.package_remove(pkg) + else: +- raise dnf.exceptions.Error( +- _('No old installonly packages found for removal.')) ++ logger.info(_('No old installonly packages found for removal.')) + return + + # Remove groups. diff --git a/dnf.spec b/dnf.spec index f391c4284d4221ad229fcfd88203c8ccb4a4ed43..b016c81badfab608ace7b04dc55c9f1230840c79 100644 --- a/dnf.spec +++ b/dnf.spec @@ -3,7 +3,7 @@ Name: dnf Version: 4.14.0 -Release: 18 +Release: 19 Summary: A software package manager that manages packages on Linux distributions. License: GPL-2.0-or-later AND GPL-1.0-only URL: https://github.com/rpm-software-management/dnf @@ -27,6 +27,9 @@ Patch6007: backport-cli-allow-=in-setopt-values.patch Patch6008: backport-Add-provide-exception-handling.patch Patch6009: backport-When-parsing-over-a-KVP-list-do-not-return-till-the-whole.patch Patch6010: backport-Fix-bash-completion-due-to-sqlite-changes.patch +Patch6011: backport-remove-duplicates-when-no-duplicates-exit-with-0.patch +Patch6012: backport-remove-oldinstallonly-when-no-old-installonly-packages-exit-with-0.patch +Patch6013: backport-Add-all-candidates-for-reinstall-to-solver.patch BuildArch: noarch BuildRequires: cmake gettext systemd bash-completion python3-sphinx @@ -251,6 +254,12 @@ popd %{_mandir}/man8/%{name}-automatic.8* %changelog +* Mon May 6 2024 hanhuihui - 4.14.0-19 +- Type:bugfix +- CVE:NA +- SUG:NA +- DESC:dnf:Remove --duplicates and --oldinstallonly exit with 0 when nothing to remove and Add all candidates for reinstall to solver + * Fri Dec 29 2023 chenhaixing - 4.14.0-18 - Type:bugfix - CVE:NA