pkg.list_upgrades: Ignore "downloading" lines in pacman output

It appears that Antergos distributes a modified version of pacman which
adds additional lines while updating its package databases. These are
incorrectly interpreted as available upgrades. This commit checks for
these lines in the output and skips them.
This commit is contained in:
Erik Johnson 2016-09-19 16:33:57 -05:00
parent b2365f553e
commit 0ae8dca2d0

View file

@ -155,10 +155,17 @@ def list_upgrades(refresh=False, root=None, **kwargs): # pylint: disable=W0613
out = call['stdout']
for line in salt.utils.itertools.split(out, '\n'):
comps = line.split(' ')
if len(comps) != 2:
try:
pkgname, pkgver = line.split()
except ValueError:
continue
upgrades[comps[0]] = comps[1]
if pkgname.lower() == 'downloading' and '.db' in pkgver.lower():
# Antergos (and possibly other Arch derivatives) add lines when pkg
# metadata is being downloaded. Because these lines, when split,
# contain two columns (i.e. 'downloading community.db...'), we will
# skip this line to keep it from being interpreted as an upgrade.
continue
upgrades[pkgname] = pkgver
return upgrades