Fix for state=latest with wildcard or virtual provide package names
This commit is contained in:
parent
961082620c
commit
2c378cc78a
1 changed files with 20 additions and 8 deletions
|
@ -755,7 +755,11 @@ def latest(module, items, repoq, yum_basecmd, conf_file, en_repos, dis_repos):
|
|||
|
||||
if update_all:
|
||||
cmd = yum_basecmd + ['update']
|
||||
will_update = set(updates.keys())
|
||||
will_update_from_other_package = dict()
|
||||
else:
|
||||
will_update = set()
|
||||
will_update_from_other_package = dict()
|
||||
for spec in items:
|
||||
# some guess work involved with groups. update @<group> will install the group if missing
|
||||
if spec.startswith('@'):
|
||||
|
@ -779,8 +783,19 @@ def latest(module, items, repoq, yum_basecmd, conf_file, en_repos, dis_repos):
|
|||
nothing_to_do = False
|
||||
break
|
||||
|
||||
if spec in pkgs['update'] and spec in updates.keys():
|
||||
nothing_to_do = False
|
||||
# this contains the full NVR and spec could contain wildcards
|
||||
# or virtual provides (like "python-*" or "smtp-daemon") while
|
||||
# updates contains name only.
|
||||
this_name_only = '-'.join(this.split('-')[:-2])
|
||||
if spec in pkgs['update'] and this_name_only in updates.keys():
|
||||
nothing_to_do = False
|
||||
will_update.add(spec)
|
||||
# Massage the updates list
|
||||
if spec != this_name_only:
|
||||
# For reporting what packages would be updated more
|
||||
# succinctly
|
||||
will_update_from_other_package[spec] = this_name_only
|
||||
break
|
||||
|
||||
if nothing_to_do:
|
||||
res['results'].append("All packages providing %s are up to date" % spec)
|
||||
|
@ -793,12 +808,6 @@ def latest(module, items, repoq, yum_basecmd, conf_file, en_repos, dis_repos):
|
|||
res['msg'] += "The following packages have pending transactions: %s" % ", ".join(conflicts)
|
||||
module.fail_json(**res)
|
||||
|
||||
# list of package updates
|
||||
if update_all:
|
||||
will_update = updates.keys()
|
||||
else:
|
||||
will_update = [u for u in pkgs['update'] if u in updates.keys() or u.startswith('@')]
|
||||
|
||||
# check_mode output
|
||||
if module.check_mode:
|
||||
to_update = []
|
||||
|
@ -806,6 +815,9 @@ def latest(module, items, repoq, yum_basecmd, conf_file, en_repos, dis_repos):
|
|||
if w.startswith('@'):
|
||||
to_update.append((w, None))
|
||||
msg = '%s will be updated' % w
|
||||
elif w not in updates:
|
||||
other_pkg = will_update_from_other_package[w]
|
||||
to_update.append((w, 'because of (at least) %s-%s.%s from %s' % (other_pkg, updates[other_pkg]['version'], updates[other_pkg]['dist'], updates[other_pkg]['repo'])))
|
||||
else:
|
||||
to_update.append((w, '%s.%s from %s' % (updates[w]['version'], updates[w]['dist'], updates[w]['repo'])))
|
||||
|
||||
|
|
Loading…
Reference in a new issue