Add BASE_MODULE_KOJI_ARCHES to override default Koji arches.

This commit is contained in:
Jan Kaluza
2018-08-14 13:18:46 +02:00
parent d54422adeb
commit f0b35be067
3 changed files with 45 additions and 3 deletions

View File

@@ -171,6 +171,16 @@ class KojiModuleBuilder(GenericBuilder):
self.koji_session = self.get_session(config, owner)
self.arches = config.koji_arches
# Handle BASE_MODULE_KOJI_ARCHES. Find out the base modules in buildrequires
# section of XMD and set the Koji tag arches according to it.
if "mbs" in self.mmd.get_xmd().keys():
for req_name, req_data in self.mmd.get_xmd()["mbs"]["buildrequires"].items():
ns = ":".join([req_name, req_data["stream"]])
if ns in config.base_module_koji_arches:
self.arches = config.base_module_koji_arches[ns]
break
if not self.arches:
raise ValueError("No koji_arches specified in the config.")

View File

@@ -393,6 +393,10 @@ class Config(object):
'default': set(['platform', 'bootstrap']),
'desc': ("Set of module names which defines the product version "
"(by their stream) of modules depending on them.")},
'base_module_koji_arches': {
'type': dict,
'default': {},
'desc': 'Per base-module name:stream Koji arches list.'},
'koji_cg_build_tag_template': {
'type': str,
'default': "{}-modular-updates-candidate",
@@ -604,6 +608,16 @@ class Config(object):
.format(strategy, ', '.join(SUPPORTED_STRATEGIES)))
self._rebuild_strategy = strategy
def _setifok_base_module_koji_arches(self, data):
if not isinstance(data, dict):
raise ValueError("BASE_MODULE_KOJI_ARCHES must be a dict")
for ns, arches in data.items():
if len(ns.split(":")) != 2:
raise ValueError("BASE_MODULE_KOJI_ARCHES keys must be in 'name:stream' format")
if not isinstance(arches, list):
raise ValueError("BASE_MODULE_KOJI_ARCHES values must be lists")
self._base_module_koji_arches = data
def _setifok_rebuild_strategies_allowed(self, strategies):
if not isinstance(strategies, list):
raise ValueError('REBUILD_STRATEGIES_ALLOWED must be a list')

View File

@@ -412,10 +412,14 @@ class TestKojiBuilder:
weights = KojiModuleBuilder.get_build_weights(["httpd", "apr"])
assert weights == {"httpd": 1.5, "apr": 1.5}
@patch.object(conf, 'base_module_koji_arches',
new={"platform:xx": ["x86_64", "i686"]})
@pytest.mark.parametrize('blocklist', [False, True])
@pytest.mark.parametrize('custom_whitelist', [False, True])
@pytest.mark.parametrize('repo_include_all', [False, True])
def test_buildroot_connect(self, custom_whitelist, blocklist, repo_include_all):
@pytest.mark.parametrize('override_arches', [False, True])
def test_buildroot_connect(self, custom_whitelist, blocklist, repo_include_all,
override_arches):
if blocklist:
mmd = self.module.mmd()
xmd = glib.from_variant_dict(mmd.get_xmd())
@@ -439,6 +443,15 @@ class TestKojiBuilder:
mmd.set_xmd(glib.dict_values(xmd))
self.module.modulemd = mmd.dumps()
if override_arches:
mmd = self.module.mmd()
xmd = glib.from_variant_dict(mmd.get_xmd())
mbs_options = xmd["mbs"] if "mbs" in xmd.keys() else {}
mbs_options["buildrequires"] = {"platform": {"stream": "xx"}}
xmd["mbs"] = mbs_options
mmd.set_xmd(glib.dict_values(xmd))
self.module.modulemd = mmd.dumps()
builder = FakeKojiModuleBuilder(
owner=self.module.owner, module=self.module, config=conf, tag_name='module-foo',
components=["nginx"])
@@ -476,10 +489,15 @@ class TestKojiBuilder:
expected_calls = []
assert session.packageListBlock.mock_calls == expected_calls
expected_calls = [mock.call('module-foo', arches='i686 armv7hl x86_64',
if override_arches:
expected_arches = "x86_64 i686"
else:
expected_arches = "i686 armv7hl x86_64"
expected_calls = [mock.call('module-foo', arches=expected_arches,
extra={'mock.package_manager': 'dnf',
'repo_include_all': repo_include_all}),
mock.call('module-foo-build', arches='i686 armv7hl x86_64',
mock.call('module-foo-build', arches=expected_arches,
extra={'mock.package_manager': 'dnf',
'repo_include_all': repo_include_all})]
assert session.editTag2.mock_calls == expected_calls