Merge pull request #623 from AdmiralNemo/portage-fixes

Portage fixes for check mode
reviewable/pr18780/r1
Greg DeKoenigsberg 10 years ago
commit 44eb758dc7

@ -254,6 +254,8 @@ def emerge_packages(module, packages):
break break
else: else:
module.exit_json(changed=False, msg='Packages already present.') module.exit_json(changed=False, msg='Packages already present.')
if module.check_mode:
module.exit_json(changed=True, msg='Packages would be installed.')
args = [] args = []
emerge_flags = { emerge_flags = {
@ -298,13 +300,18 @@ def emerge_packages(module, packages):
changed = True changed = True
for line in out.splitlines(): for line in out.splitlines():
if re.match(r'(?:>+) Emerging (?:binary )?\(1 of', line): if re.match(r'(?:>+) Emerging (?:binary )?\(1 of', line):
msg = 'Packages installed.'
break
elif module.check_mode and re.match(r'\[(binary|ebuild)', line):
msg = 'Packages would be installed.'
break break
else: else:
changed = False changed = False
msg = 'No packages installed.'
module.exit_json( module.exit_json(
changed=changed, cmd=cmd, rc=rc, stdout=out, stderr=err, changed=changed, cmd=cmd, rc=rc, stdout=out, stderr=err,
msg='Packages installed.', msg=msg,
) )

Loading…
Cancel
Save