File 0034-Fix-pkg.latest_version-when-latest-already-installed.patch of Package salt.3776
From 38e62832562c8733e858676b8c97ff7974590c6d Mon Sep 17 00:00:00 2001
From: Mihai Dinca <mdinca@suse.de>
Date: Fri, 21 Oct 2016 16:25:04 +0200
Subject: [PATCH 34/38] Fix pkg.latest_version when latest already installed
---
salt/states/pkg.py | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/salt/states/pkg.py b/salt/states/pkg.py
index bc31e4b..3b02329 100644
--- a/salt/states/pkg.py
+++ b/salt/states/pkg.py
@@ -1625,16 +1625,22 @@ def latest(
targets = {}
problems = []
for pkg in desired_pkgs:
- if not avail[pkg]:
+ if not avail.get(pkg):
+ # Package either a) is up-to-date, or b) does not exist
if not cur[pkg]:
+ # Package does not exist
msg = 'No information found for \'{0}\'.'.format(pkg)
log.error(msg)
problems.append(msg)
elif watch_flags \
and __grains__.get('os') == 'Gentoo' \
and __salt__['portage_config.is_changed_uses'](pkg):
- targets[pkg] = avail[pkg]
+ # Package is up-to-date, but Gentoo USE flags are changing so
+ # we need to add it to the targets
+ targets[pkg] = cur[pkg]
else:
+ # Package either a) is not installed, or b) is installed and has an
+ # upgrade available
targets[pkg] = avail[pkg]
if problems:
--
2.10.2