Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zypper: latest version bugfix and epoch support feature #30663

Merged
merged 2 commits into from Jan 27, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 6 additions & 3 deletions salt/modules/zypper.py
Expand Up @@ -244,7 +244,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
Expand Down Expand Up @@ -313,15 +314,17 @@ 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,
output_loglevel='trace',
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)
Expand Down