diff options
author | John Morris <john@zultron.com> | 2014-04-20 17:06:54 -0500 |
---|---|---|
committer | John Morris <john@zultron.com> | 2014-04-21 11:13:26 -0500 |
commit | 2454dddb3a5a0afdcfc2f875edfdcc7b5a85d4ba (patch) | |
tree | b6991acdcdf20b381d553fcada77c914fcbbf895 /src | |
parent | d2ca484d6bd07c3d7b36a9da8b59f4c1c523445d (diff) | |
download | bcfg2-2454dddb3a5a0afdcfc2f875edfdcc7b5a85d4ba.tar.gz bcfg2-2454dddb3a5a0afdcfc2f875edfdcc7b5a85d4ba.tar.bz2 bcfg2-2454dddb3a5a0afdcfc2f875edfdcc7b5a85d4ba.zip |
Enable bcfg2-yum-helper to depsolve for arches incompatible with server
By default, the yum dependency resolver uses the host's architecture
to filter compatible packages. This prevents dependency resolution
when the bcfg2 client's architecture is incompatible with the
server's.
This workaround checks the <Arch/> element for each of the client's yum
sources, and if they are all identical, passes that architecture to
bcfg2-yum-helper to override the default.
The rpmUtils.arch module may only be configured for a single
architecture. If multiple architectures are configured in yum
sources, we don't know which one to pick, so use the default behavior
instead.
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/Bcfg2/Server/Plugins/Packages/Yum.py | 29 | ||||
-rwxr-xr-x | src/sbin/bcfg2-yum-helper | 9 |
2 files changed, 34 insertions, 4 deletions
diff --git a/src/lib/Bcfg2/Server/Plugins/Packages/Yum.py b/src/lib/Bcfg2/Server/Plugins/Packages/Yum.py index 67ff05ca1..6139a28b5 100644 --- a/src/lib/Bcfg2/Server/Plugins/Packages/Yum.py +++ b/src/lib/Bcfg2/Server/Plugins/Packages/Yum.py @@ -429,6 +429,25 @@ class YumCollection(Collection): yumconf.write(open(self.cfgfile, 'w')) + def get_arch(self): + """ If 'arch' for each source is the same, return that arch, otherwise + None. + + This helps bcfg2-yum-helper when the client arch is + incompatible with the bcfg2 server's arch. + + In case multiple arches are found, punt back to the default behavior. + """ + arches = set() + for source in self: + for url_map in source.url_map: + if url_map['arch'] in self.metadata.groups: + arches.add(url_map['arch']) + if len(arches) == 1: + return arches.pop() + else: + return None + def get_config(self, raw=False): # pylint: disable=W0221 """ Get the yum configuration for this collection. @@ -886,10 +905,12 @@ class YumCollection(Collection): if packagelist: try: - result = self.call_helper( - "complete", - dict(packages=list(packagelist), - groups=list(self.get_relevant_groups()))) + helper_dict = dict(packages=list(packagelist), + groups=list(self.get_relevant_groups())) + arch = self.get_arch() + if arch is not None: + helper_dict['arch'] = arch + result = self.call_helper("complete", helper_dict) except ValueError: # error reported by call_helper() return set(), packagelist diff --git a/src/sbin/bcfg2-yum-helper b/src/sbin/bcfg2-yum-helper index 227d977de..dc6a6cc0b 100755 --- a/src/sbin/bcfg2-yum-helper +++ b/src/sbin/bcfg2-yum-helper @@ -62,6 +62,10 @@ class YumHelper(object): # pylint: enable=E1121,W0212 self.logger = logging.getLogger(self.__class__.__name__) + def setarch(self, arch): + """ Configure an arch other than the bcfg2 server arch for dep + resolution. """ + self.yumbase.arch.setup_arch(arch=arch) class DepSolver(YumHelper): """ Yum dependency solver. This is used for operations that only @@ -326,6 +330,11 @@ def main(): sys.exc_info()[1]) rv = 2 try: + # if provided, set client arch for dependency resolution + arch = data.get('arch', None) + if arch is not None: + depsolver.setarch(arch) + depsolver.groups = data['groups'] (packages, unknown) = depsolver.complete( [pkg_to_tuple(p) for p in data['packages']]) |