summaryrefslogtreecommitdiffstats
path: root/lib/ansible/modules/dnf5.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-08-07 13:26:56 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-08-07 13:26:56 +0000
commit21940e0b536ba8185603b213a105982b3100e059 (patch)
tree737dfe96501a17e6992c762e215409c060fb5f67 /lib/ansible/modules/dnf5.py
parentAdding upstream version 2.17.1. (diff)
downloadansible-core-21940e0b536ba8185603b213a105982b3100e059.tar.xz
ansible-core-21940e0b536ba8185603b213a105982b3100e059.zip
Adding upstream version 2.17.2.upstream/2.17.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'lib/ansible/modules/dnf5.py')
-rw-r--r--lib/ansible/modules/dnf5.py21
1 files changed, 17 insertions, 4 deletions
diff --git a/lib/ansible/modules/dnf5.py b/lib/ansible/modules/dnf5.py
index 7af1f4a..3a4fdfc 100644
--- a/lib/ansible/modules/dnf5.py
+++ b/lib/ansible/modules/dnf5.py
@@ -357,10 +357,23 @@ libdnf5 = None
def is_installed(base, spec):
settings = libdnf5.base.ResolveSpecSettings()
- query = libdnf5.rpm.PackageQuery(base)
- query.filter_installed()
- match, nevra = query.resolve_pkg_spec(spec, settings, True)
- return match
+ installed_query = libdnf5.rpm.PackageQuery(base)
+ installed_query.filter_installed()
+ match, nevra = installed_query.resolve_pkg_spec(spec, settings, True)
+
+ # FIXME use `is_glob_pattern` function when available:
+ # https://github.com/rpm-software-management/dnf5/issues/1563
+ glob_patterns = set("*[?")
+ if any(set(char) & glob_patterns for char in spec):
+ available_query = libdnf5.rpm.PackageQuery(base)
+ available_query.filter_available()
+ available_query.resolve_pkg_spec(spec, settings, True)
+
+ return not (
+ {p.get_name() for p in available_query} - {p.get_name() for p in installed_query}
+ )
+ else:
+ return match
def is_newer_version_installed(base, spec):