From a4d815e4df87f5afbae9d37c7faf6a9871d50b53 Mon Sep 17 00:00:00 2001 From: Jaroslav Mracek Date: Mon, 11 Mar 2024 12:36:48 +0100 Subject: [PATCH] Fix handling installonly packages reasons The original code took the first item from all remaining packages. It means a random reason and use it to keep installonly package reason. Related: https://issues.redhat.com/browse/RHEL-15902 Closes: https://github.com/rpm-software-management/dnf/issues/2061 --- dnf/base.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/dnf/base.py b/dnf/base.py index 552d53f4c7..a6b3574686 100644 --- a/dnf/base.py +++ b/dnf/base.py @@ -818,9 +818,11 @@ def _goal2transaction(self, goal): if erasures: remaining_installed_query = self.sack.query(flags=hawkey.IGNORE_EXCLUDES).installed() remaining_installed_query.filterm(pkg__neq=erasures) + remaining_installed_query.apply() for pkg in erasures: - if remaining_installed_query.filter(name=pkg.name): - remaining = remaining_installed_query[0] + tmp_remaining_installed_query = remaining_installed_query.filter(name=pkg.name, arch=pkg.arch) + if tmp_remaining_installed_query: + remaining = tmp_remaining_installed_query[0] ts.get_reason(remaining) self.history.set_reason(remaining, ts.get_reason(remaining)) self._ds_callback.pkg_added(pkg, 'e')