48 lines
1.8 KiB
Diff
48 lines
1.8 KiB
Diff
|
From 2747b83d8009fb7386986ada1640456de2fe5304 Mon Sep 17 00:00:00 2001
|
||
|
From: Bo Maryniuk <bo@suse.de>
|
||
|
Date: Wed, 27 Jan 2016 12:37:06 +0100
|
||
|
Subject: [PATCH 05/22] Fix package status filtering on latest version and
|
||
|
implement epoch support
|
||
|
|
||
|
---
|
||
|
salt/modules/zypper.py | 9 ++++++---
|
||
|
1 file changed, 6 insertions(+), 3 deletions(-)
|
||
|
|
||
|
diff --git a/salt/modules/zypper.py b/salt/modules/zypper.py
|
||
|
index 63b38af..4699904 100644
|
||
|
--- a/salt/modules/zypper.py
|
||
|
+++ b/salt/modules/zypper.py
|
||
|
@@ -245,7 +245,8 @@ def latest_version(*names, **kwargs):
|
||
|
package_info = info_available(*names)
|
||
|
for name in names:
|
||
|
pkg_info = package_info.get(name, {})
|
||
|
- if pkg_info.get('status', '').lower() in ['not installed', 'out-of-date']:
|
||
|
+ status = pkg_info.get('status', '').lower()
|
||
|
+ if status.find('not installed') > -1 or status.find('out-of-date') > -1:
|
||
|
ret[name] = pkg_info.get('version')
|
||
|
|
||
|
# Return a string if only one package name passed
|
||
|
@@ -314,7 +315,7 @@ def list_pkgs(versions_as_list=False, **kwargs):
|
||
|
__salt__['pkg_resource.stringify'](ret)
|
||
|
return ret
|
||
|
|
||
|
- cmd = ['rpm', '-qa', '--queryformat', '%{NAME}_|-%{VERSION}_|-%{RELEASE}\\n']
|
||
|
+ cmd = ['rpm', '-qa', '--queryformat', '%{NAME}_|-%{VERSION}_|-%{RELEASE}_|-%|EPOCH?{%{EPOCH}}:{}|\\n']
|
||
|
ret = {}
|
||
|
out = __salt__['cmd.run'](
|
||
|
cmd,
|
||
|
@@ -322,7 +323,9 @@ def list_pkgs(versions_as_list=False, **kwargs):
|
||
|
python_shell=False
|
||
|
)
|
||
|
for line in out.splitlines():
|
||
|
- name, pkgver, rel = line.split('_|-')
|
||
|
+ name, pkgver, rel, epoch = line.split('_|-')
|
||
|
+ if epoch:
|
||
|
+ pkgver = '{0}:{1}'.format(epoch, pkgver)
|
||
|
if rel:
|
||
|
pkgver += '-{0}'.format(rel)
|
||
|
__salt__['pkg_resource.add_pkg'](ret, name, pkgver)
|
||
|
--
|
||
|
2.1.4
|
||
|
|