Blob Blame History Raw
From fea1f456d3d5f3015ebcff4008959916bdaaf6d6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ale=C5=A1=20Mat=C4=9Bj?= <amatej@redhat.com>
Date: Mon, 4 Jul 2022 09:46:29 +0200
Subject: [PATCH] Use `installed_all` because `installed_query` is filtered
 user input

`installed_query` could be missing packages. If we specify we want to
upgrade a specific nevra that is not yet installed, then `installed_query`
is empty because it is based on user input, but there could be other
versions of the pkg installed.

Eg: if kernel-1 and kernel-3 are installed and we specify we want to
upgrade kernel-2, nothing should be done because we already have higher
version, but now `installed_query` would be empty and kernel-2 would be
installed.

Therefore, we need to use `installed_all`.
---
 dnf/base.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/dnf/base.py b/dnf/base.py
index 82466831..e606d9fa 100644
--- a/dnf/base.py
+++ b/dnf/base.py
@@ -2152,7 +2152,7 @@ class Base(object):
             #     packages. Otherwise if for example kernel-1 and kernel-3 were installed and present in the
             #     transaction libsolv could decide to install kernel-2 because it is an upgrade for kernel-1 even
             #     though we don't want it because there already is a newer version present.
-            query = query.union(installed_query.latest().filter(name=[pkg.name for pkg in query]))
+            query = query.union(installed_all.latest().filter(name=[pkg.name for pkg in query]))
             sltr = dnf.selector.Selector(self.sack)
             sltr.set(pkg=query)
             self._goal.upgrade(select=sltr)
-- 
2.36.1