summaryrefslogtreecommitdiffstats
path: root/py/mock.py
diff options
context:
space:
mode:
Diffstat (limited to 'py/mock.py')
-rwxr-xr-xpy/mock.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/py/mock.py b/py/mock.py
index 6702ba6..b33d247 100755
--- a/py/mock.py
+++ b/py/mock.py
@@ -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'] = '''