Skip to content
This repository has been archived by the owner on Oct 30, 2018. It is now read-only.

Correct the handling of state=latest for yum groups. #4141

Merged
merged 2 commits into from
Nov 9, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions packaging/os/yum.py
Original file line number Diff line number Diff line change
Expand Up @@ -837,6 +837,7 @@ def latest(module, items, repoq, yum_basecmd, conf_file, en_repos, dis_repos):
# some guess work involved with groups. update @<group> will install the group if missing
if spec.startswith('@'):
pkgs['update'].append(spec)
will_update.add(spec)
continue
# dep/pkgname - find it
else:
Expand Down Expand Up @@ -909,14 +910,16 @@ def latest(module, items, repoq, yum_basecmd, conf_file, en_repos, dis_repos):
if len(pkgs['install']) > 0: # install missing
cmd = yum_basecmd + ['install'] + pkgs['install']
rc, out, err = module.run_command(cmd)
res['changed'] = True
if not out.strip().lower().endswith("no packages marked for update"):
res['changed'] = True
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When screen scraping output we have to make sure that the program returns strings in the language we expect. Some modules set the locale in one place to do that. The yum module (probably because it calls several different programs and doesn't screenscrape all of them) sets the environment on each external call. You can do that with something like the following:

         lang_env = dict(LANG='C', LC_ALL='C', LC_MESSAGES='C')
         rc, out, err = module.run_command(cmd, environ_update=lang_env)
         if not out.strip().lower().endswith("no packages marked for update"):
             res['changed'] = True

And the same for the other place we screenscrape.

else:
rc, out, err = [0, '', '']

if len(will_update) > 0: # update present
cmd = yum_basecmd + ['update'] + pkgs['update']
rc2, out2, err2 = module.run_command(cmd)
res['changed'] = True
if not out2.strip().lower().endswith("no packages marked for update"):
res['changed'] = True
else:
rc2, out2, err2 = [0, '', '']

Expand All @@ -937,7 +940,14 @@ def latest(module, items, repoq, yum_basecmd, conf_file, en_repos, dis_repos):
def ensure(module, state, pkgs, conf_file, enablerepo, disablerepo,
disable_gpg_check, exclude, repoq):

yumbin = module.get_bin_path('yum')
# fedora will redirect yum to dnf, which has incompatibilities
# with how this module expects yum to operate. If yum-deprecated
# is available, use that instead to emulate the old behaviors.
if module.get_bin_path('yum-deprecated'):
yumbin = module.get_bin_path('yum-deprecated')
else:
yumbin = module.get_bin_path('yum')

# need debug level 2 to get 'Nothing to do' for groupinstall.
yum_basecmd = [yumbin, '-d', '2', '-y']

Expand Down