mirror of
https://pagure.io/fm-orchestrator.git
synced 2026-04-26 19:51:49 +08:00
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:
@@ -52,7 +52,6 @@ from module_build_service.errors import ProgrammingError
|
||||
from module_build_service.builder.base import GenericBuilder
|
||||
from module_build_service.builder.KojiContentGenerator import KojiContentGenerator
|
||||
from module_build_service.utils import get_reusable_components, get_reusable_module
|
||||
from module_build_service.utils import get_build_arches
|
||||
|
||||
logging.basicConfig(level=logging.DEBUG)
|
||||
|
||||
@@ -180,10 +179,10 @@ class KojiModuleBuilder(GenericBuilder):
|
||||
log.debug("Using koji_config: %s" % config.koji_config)
|
||||
|
||||
self.koji_session = self.get_session(config)
|
||||
self.arches = get_build_arches(self.mmd, self.config)
|
||||
self.arches = [arch.name for arch in self.module.arches]
|
||||
|
||||
if not self.arches:
|
||||
raise ValueError("No arches specified in the config.")
|
||||
raise ValueError("No arches specified in module build.")
|
||||
|
||||
# These eventually get populated by calling _connect and __prep is set to True
|
||||
self.module_tag = None # string
|
||||
@@ -1307,3 +1306,16 @@ class KojiModuleBuilder(GenericBuilder):
|
||||
tags.append(t["name"])
|
||||
|
||||
return tags
|
||||
|
||||
@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
|
||||
"""
|
||||
koji_session = KojiModuleBuilder.get_session(conf, login=False)
|
||||
tag = koji_session.getTag(module.koji_tag)
|
||||
if not tag:
|
||||
raise ValueError("Unknown Koji tag %r." % module.koji_tag)
|
||||
return tag["arches"].split(" ")
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -346,6 +346,15 @@ class GenericBuilder(six.with_metaclass(ABCMeta)):
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
@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 GenericBuilder.backends[conf.system].get_module_build_arches(module)
|
||||
|
||||
@classmethod
|
||||
def recover_orphaned_artifact(cls, component_build):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user