mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 17:09:03 +00:00
yumpkg5: handle i686 pkgs on x86_64 (#3638)
This fixes #3638 for yumpkg5. yumpkg still needs to be updated. It also fixes a bug in _list_removed.
This commit is contained in:
parent
e8e4e3c5f3
commit
6b03cf8eef
@ -55,11 +55,6 @@ def _list_removed(old, new):
|
||||
'''
|
||||
List the packages which have been removed between the two package objects
|
||||
'''
|
||||
# Force input to be a list so below loop works
|
||||
if not isinstance(old, list):
|
||||
old = [old]
|
||||
if not isinstance(new, list):
|
||||
new = [new]
|
||||
pkgs = []
|
||||
for pkg in old:
|
||||
if pkg not in new:
|
||||
@ -142,9 +137,17 @@ def list_pkgs():
|
||||
salt '*' pkg.list_pkgs
|
||||
'''
|
||||
ret = {}
|
||||
cmd = 'rpm -qa --queryformat "%{NAME}_|-%{VERSION}_|-%{RELEASE}\n"'
|
||||
cmd = 'rpm -qa --queryformat "%{NAME}_|-%{VERSION}_|-%{RELEASE}_|-%{ARCH}\n"'
|
||||
for line in __salt__['cmd.run'](cmd).splitlines():
|
||||
name, version, rel = line.split('_|-')
|
||||
try:
|
||||
name, version, rel, arch = line.split('_|-')
|
||||
# Handle unpack errors (should never happen with the queryformat we are
|
||||
# using, but can't hurt to be careful).
|
||||
except ValueError:
|
||||
continue
|
||||
# Support 32-bit packages on x86_64 systems
|
||||
if __grains__.get('cpuarch', '') == 'x86_64' and arch == 'i686':
|
||||
name += '.i686'
|
||||
pkgver = version
|
||||
if rel:
|
||||
pkgver += '-{0}'.format(rel)
|
||||
@ -299,12 +302,19 @@ def install(name=None,
|
||||
downgrade = []
|
||||
if pkg_type == 'repository':
|
||||
targets = []
|
||||
for param, version in pkg_params.iteritems():
|
||||
for pkgname, version in pkg_params.iteritems():
|
||||
if version is None:
|
||||
targets.append(param)
|
||||
targets.append(pkgname)
|
||||
else:
|
||||
pkgstr = '"{0}-{1}"'.format(param, version)
|
||||
cver = old.get(param, '')
|
||||
cver = old.get(pkgname, '')
|
||||
if __grains__.get('cpuarch', '') == 'x86_64' \
|
||||
and pkgname.endswith('.i686'):
|
||||
# Remove '.i686' from pkgname
|
||||
pkgname = pkgname[:-5]
|
||||
arch = '.i686'
|
||||
else:
|
||||
arch = ''
|
||||
pkgstr = '"{0}-{1}{2}"'.format(pkgname, version, arch)
|
||||
if not cver or __salt__['pkg.compare'](pkg1=version,
|
||||
oper='>=',
|
||||
pkg2=cver):
|
||||
@ -382,7 +392,7 @@ def remove(pkg, **kwargs):
|
||||
salt '*' pkg.remove <package name>
|
||||
'''
|
||||
old = list_pkgs()
|
||||
cmd = 'yum -q -y remove ' + pkg
|
||||
cmd = 'yum -q -y remove "{0}"'.format(pkg)
|
||||
__salt__['cmd.retcode'](cmd)
|
||||
new = list_pkgs()
|
||||
return _list_removed(old, new)
|
||||
|
Loading…
Reference in New Issue
Block a user