Skip to content

Commit

Permalink
yum: Allow 32bit pkgs in arches other than i686
Browse files Browse the repository at this point in the history
The yum providers previously only supported 32bit packages that were for
the i686 architecture. This adds support for any iX86 arch.

Fixes saltstack#6299.
  • Loading branch information
terminalmage committed Jul 25, 2013
1 parent da46fc6 commit aae8ff2
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 24 deletions.
39 changes: 25 additions & 14 deletions salt/modules/yumpkg.py
Expand Up @@ -15,8 +15,9 @@

# Import python libs
import copy
import os
import logging
import os
import re
import yaml

# Import salt libs
Expand Down Expand Up @@ -302,8 +303,9 @@ def list_pkgs(versions_as_list=False, **kwargs):
yb = yum.YumBase()
for p in yb.rpmdb:
name = p.name
if __grains__.get('cpuarch', '') == 'x86_64' and p.arch == 'i686':
name += '.i686'
if __grains__.get('cpuarch', '') == 'x86_64' \
and re.match('i\d86', p.arch):
name += '.{0}'.format(p.arch)
pkgver = p.version
if p.release:
pkgver += '-{0}'.format(p.release)
Expand Down Expand Up @@ -433,8 +435,9 @@ def install(name=None,
software repository. To install a package file manually, use the
"sources" option.
32-bit packages can be installed on 64-bit systems by appending
``.i686`` to the end of the package name.
32-bit packages can be installed on 64-bit systems by appending the
architecture designation (``.i686``, ``.i586``, etc.) to the end of the
package name.
CLI Example::
salt '*' pkg.install <package name>
Expand Down Expand Up @@ -536,11 +539,14 @@ def install(name=None,
else:
version = pkg_params[pkgname]
if version is not None:
if __grains__.get('cpuarch', '') == 'x86_64' \
and pkgname.endswith('.i686'):
# Remove '.i686' from pkgname
pkgname = pkgname[:-5]
arch = '.i686'
if __grains__.get('cpuarch', '') == 'x86_64':
try:
arch = re.search('(\.i\d86)$', pkgname).group(1)
except AttributeError:
arch = ''
else:
# Remove arch from pkgname
pkgname = pkgname[:-len(arch)]
else:
arch = ''
target = '{0}-{1}{2}'.format(pkgname, version, arch)
Expand Down Expand Up @@ -652,10 +658,15 @@ def remove(name=None, pkgs=None, **kwargs):

# same comments as in upgrade for remove.
for target in targets:
if __grains__.get('cpuarch', '') == 'x86_64' \
and target.endswith('.i686'):
target = target[:-5]
arch = 'i686'
if __grains__.get('cpuarch', '') == 'x86_64':
try:
arch = re.search('(\.i\d86)$', target).group(1)
except AttributeError:
arch = None
else:
# Remove arch from pkgname
target = target[:-len(arch)]
arch = arch.lstrip('.')
else:
arch = None
yumbase.remove(name=target, arch=arch)
Expand Down
26 changes: 16 additions & 10 deletions salt/modules/yumpkg5.py
Expand Up @@ -3,9 +3,10 @@
'''

# Import python libs
import collections
import copy
import logging
import collections
import re

# Import salt libs
import salt.utils
Expand Down Expand Up @@ -73,8 +74,9 @@ def _parse_pkginfo(line):
return None

# Support 32-bit packages on x86_64 systems
if __grains__.get('cpuarch', '') == 'x86_64' and arch == 'i686':
name += '.i686'
if __grains__.get('cpuarch', '') == 'x86_64' \
and re.match('i\d86', arch):
name += '.{0}'.format(arch)
if rel:
pkgver += '-{0}'.format(rel)

Expand Down Expand Up @@ -282,8 +284,9 @@ def install(name=None,
software repository. To install a package file manually, use the
"sources" option.
32-bit packages can be installed on 64-bit systems by appending
``.i686`` to the end of the package name.
32-bit packages can be installed on 64-bit systems by appending the
architecture designation (``.i686``, ``.i586``, etc.) to the end of the
package name.
CLI Example::
salt '*' pkg.install <package name>
Expand Down Expand Up @@ -370,11 +373,14 @@ def install(name=None,
targets.append(pkgname)
else:
cver = old.get(pkgname, '')
if __grains__.get('cpuarch', '') == 'x86_64' \
and pkgname.endswith('.i686'):
# Remove '.i686' from pkgname
pkgname = pkgname[:-5]
arch = '.i686'
if __grains__.get('cpuarch', '') == 'x86_64':
try:
arch = re.search('(\.i\d86)$', pkgname).group(1)
except AttributeError:
arch = ''
else:
# Remove arch from pkgname
pkgname = pkgname[:-len(arch)]
else:
arch = ''
pkgstr = '"{0}-{1}{2}"'.format(pkgname, version_num, arch)
Expand Down

0 comments on commit aae8ff2

Please sign in to comment.