dnf: fix wildcard matching for state: absent (#56013)

* dnf: fix wildcard matching for state: absent

Fixes #55938

* Add changelog...

* Fix sanity check failure...
This commit is contained in:
Martin Krizek
2019-05-14 23:34:11 +02:00
committed by ansibot
parent e98e98757d
commit 826b99d4bd
3 changed files with 30 additions and 0 deletions

View File

@@ -1108,6 +1108,14 @@ class DnfModule(YumDnf):
installed = self.base.sack.query().installed()
for pkg_spec in pkg_specs:
# short-circuit installed check for wildcard matching
if '*' in pkg_spec:
try:
self.base.remove(pkg_spec)
except dnf.exceptions.MarkingError as e:
failure_response['failures'].append('{0} - {1}'.format(pkg_spec, to_native(e)))
continue
installed_pkg = list(map(str, installed.filter(name=pkg_spec).run()))
if installed_pkg:
candidate_pkg = self._packagename_dict(installed_pkg[0])