diff --git a/conf/config.py b/conf/config.py index fbb97078..498397b9 100644 --- a/conf/config.py +++ b/conf/config.py @@ -173,3 +173,6 @@ class ProdConfiguration(BaseConfiguration): class LocalBuildConfiguration(BaseConfiguration): LOG_LEVEL = 'debug' MESSAGING = 'in_memory' + + ARCH_AUTODETECT = True + ARCH_FALLBACK = 'x86_64' diff --git a/module_build_service/builder/MockModuleBuilder.py b/module_build_service/builder/MockModuleBuilder.py index 4510d944..b1b4c87e 100644 --- a/module_build_service/builder/MockModuleBuilder.py +++ b/module_build_service/builder/MockModuleBuilder.py @@ -28,6 +28,7 @@ import koji import kobo.rpmlib import modulemd import pipes +import platform import re import threading @@ -91,9 +92,21 @@ class MockModuleBuilder(GenericBuilder): self.tag_name = tag_name self.config = config self.groups = [] - self.arch = "x86_64" # TODO: We may need to change that in the future self.yum_conf = MockModuleBuilder.yum_config_template + # Auto-detect arch (if possible) or fallback to the configured one + if conf.arch_autodetect: + arch_detected = platform.machine() + if arch_detected: + self.arch = arch_detected + else: + log.warning("Couldn't determine machine arch. Falling back " + "to configured arch.") + self.arch = conf.arch_fallback + else: + self.arch = conf.arch_fallback + log.info("Machine arch setting: {}".format(self.arch)) + # Create main directory for this tag self.tag_dir = os.path.join(self.config.mock_resultsdir, tag_name) if not os.path.exists(self.tag_dir): diff --git a/module_build_service/config.py b/module_build_service/config.py index 38c2b6cd..65314dc8 100644 --- a/module_build_service/config.py +++ b/module_build_service/config.py @@ -326,6 +326,14 @@ class Config(object): 'type': bool, 'default': True, 'desc': 'Remove empty or otherwise useless log files.'}, + 'arch_autodetect': { + 'type': bool, + 'default': True, + 'desc': 'Auto-detect machine arch when configuring builder.'}, + 'arch_fallback': { + 'type': str, + 'default': 'x86_64', + 'desc': 'Fallback arch if auto-detection is off or unable to determine it.'}, 'scmurls': { 'type': list, 'default': [],