diff options
author | Clark Williams <williams@redhat.com> | 2010-07-14 13:13:23 -0500 |
---|---|---|
committer | Clark Williams <williams@redhat.com> | 2010-07-27 13:57:11 -0500 |
commit | 036e4e84d7594a2f799501dc3ed173f2d6ddfcc4 (patch) | |
tree | 683e53e78e3355a1c7c08e13287e2e8402ab51a4 | |
parent | 46c69a9d452ef5d8d854694d1bc1bc1ebe9971e5 (diff) | |
download | mock-036e4e84d7594a2f799501dc3ed173f2d6ddfcc4.tar.gz mock-036e4e84d7594a2f799501dc3ed173f2d6ddfcc4.tar.xz mock-036e4e84d7594a2f799501dc3ed173f2d6ddfcc4.zip |
added logic to detect invalid architecture combinations (BZ# 607144)
Modified py/mock.py to dectect invalid build combinations
(e.g. trying to build x86_64 packages on an i386 host) and to throw
an InvalidArchitecture exception when detected. Added the above
exception to py/mock/execption.py
Signed-off-by: Clark Williams <williams@redhat.com>
-rwxr-xr-x | py/mock.py | 24 | ||||
-rw-r--r-- | py/mock/exception.py | 7 |
2 files changed, 31 insertions, 0 deletions
@@ -363,6 +363,27 @@ def set_config_opts_per_cmdline(config_opts, options, args): config_opts['online'] = options.online +legal_arches = { + 'i386' : ('i386'), + 'x86_64' : ('i386', 'x86_64'), + 'ppc' : ('ppc'), + 'ppc64' : ('ppc', 'ppc64'), + 'sparc' : ('sparc'), + 'sparc64': ('sparc', 'sparc64'), + 's390x' : ('s390x'), +} + +decorate(traceLog()) +def check_arch_combination(target_arch): + host_arch = os.uname()[-1] + try: + if target_arch not in legal_arches[host_arch]: + raise mock.exception.InvalidArchitecture( + "Cannot build target %d on arch %s" % (target_arch, host_arch)) + except KeyError: + raise mock.exception.InvalidArchitecture( + "Unknown target architcture: %s" % target_arch) + decorate(traceLog()) def do_rebuild(config_opts, chroot, srpms): "rebuilds a list of srpms using provided chroot" @@ -543,6 +564,9 @@ def main(ret): # cmdline options override config options set_config_opts_per_cmdline(config_opts, options, args) + # verify that we're not trying to build an arch that we can't + check_arch_combination(config_opts['rpmbuild_arch']) + # default /etc/hosts contents if not config_opts['use_host_resolv'] and not config_opts['files'].has_key('etc/hosts'): config_opts['files']['etc/hosts'] = ''' diff --git a/py/mock/exception.py b/py/mock/exception.py index 16fcbff..d28fdf2 100644 --- a/py/mock/exception.py +++ b/py/mock/exception.py @@ -78,6 +78,13 @@ class BadCmdline(Error): self.msg = msg self.resultcode = 05 +class InvalidArchitecture(Error): + "invalid host/target architecture specified." + def __init(self, msg): + Error.__init__(self, msg) + self.msg = msg + self.resultcode = 06 + class ResultDirNotAccessible(Error): """ Could not create output directory for built rpms. The directory specified was: |