1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

pkgng: package reinstallations count as changed

`upgrade_packages()` only looked for the string
"Number of packages to be upgraded", but the
`pkg upgrade` command also reports "Number of packages to be
reinstalled". Reinstallation occurs when package metadata other
than version changes (e.g. build options, single architecture to `*`
architecture). In any other respect, though, a required
reinstallation is the same as an upgrade.
This commit is contained in:
Ross Williams 2021-10-08 19:02:07 +00:00
parent 9de01e04f2
commit 4fe3aea3a9
2 changed files with 6 additions and 3 deletions

View file

@ -0,0 +1,2 @@
bugfixes:
- 'pkgng - `name=* state=latest` check for upgrades did not count "Number of packages to be reinstalled" as a `changed` action, giving incorrect results in both regular and check mode'

View file

@ -191,9 +191,10 @@ def upgrade_packages(module, pkgng_path, dir_arg):
cmd += " -n" cmd += " -n"
rc, out, err = module.run_command(cmd) rc, out, err = module.run_command(cmd)
match = re.search('^Number of packages to be upgraded: ([0-9]+)', out, re.MULTILINE) for action in ('upgraded', 'reinstalled',):
if match: match = re.search('^Number of packages to be %s: ([0-9]+)' % (action,), out, re.MULTILINE)
upgraded_c = int(match.group(1)) if match:
upgraded_c += int(match.group(1))
if upgraded_c > 0: if upgraded_c > 0:
return (True, "updated %s package(s)" % upgraded_c, out, err) return (True, "updated %s package(s)" % upgraded_c, out, err)