Take the list of arches for -build Koji tag from buildrequired modules.

Currently, we are using just `conf.arches` and `conf.base_module_arches`
to define the list of arches for which the RPMs in a submitted module are
built. This is not enough, because RCM needs to generate modules based
on the base modules which should use different arches.

This commit changes the MBS to take the list of arches from the buildrequired
module build. It checks the buildrequires for "privileged" module or base
module and if it finds such module, it queries the Koji to find out the list
of arches to set for the module.

The "privileged" module is a module which can override base module arches
or disttag. Previously, these modules have been defined by
`allowed_disttag_marking_module_names` config option. In this commit,
this has been renamed to `allowed_privileged_module_names`.

The list of arches are stored per module build in new table represented
by ModuleArch class and are m:n mapped to ModuleBuild.
This commit is contained in:
Jan Kaluza
2019-06-03 13:34:51 +02:00
parent 222f0417cf
commit bf0bcaff57
16 changed files with 328 additions and 50 deletions

View File

@@ -52,6 +52,20 @@ from module_build_service import models
logging.basicConfig(level=logging.DEBUG)
def detect_arch():
"""
Helper method to detect the local host architecture. Fallbacks to `conf.arch_fallback`.
"""
if conf.arch_autodetect:
arch_detected = platform.machine()
if arch_detected:
return arch_detected
log.warning("Couldn't determine machine arch. Falling back to configured arch.")
return conf.arch_fallback
class MockModuleBuilder(GenericBuilder):
backend = "mock"
# Global build_id/task_id we increment when new build is executed.
@@ -94,15 +108,7 @@ class MockModuleBuilder(GenericBuilder):
self.koji_session = None
# 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
self.arch = detect_arch()
log.info("Machine arch setting: {}".format(self.arch))
# Create main directory for this tag
@@ -149,6 +155,17 @@ class MockModuleBuilder(GenericBuilder):
# Workaround koji specific code in modules.py
return {"name": self.tag_name}
@classmethod
def get_module_build_arches(cls, module):
"""
:param ModuleBuild module: Get the list of architectures associated with
the module build in the build system.
:return: list of architectures
"""
# Return local architecture, because all the modules built locally are built
# just against this architecture.
return [detect_arch()]
def _createrepo(self, include_module_yaml=False):
"""
Creates the repository using "createrepo_c" command in the resultsdir.