Return only the direct build-requires of a module in get_module_build_dependencies and remove module_depsolving_wrapper, because it is not needed anymore.

This commit is contained in:
Jan Kaluza
2017-03-23 09:26:26 +01:00
parent 1487fd01f2
commit f52249decd
2 changed files with 42 additions and 64 deletions

View File

@@ -266,51 +266,6 @@ def resolve_profiles(session, mmd, keys):
# Return the union of all rpms in all profiles of the given keys.
return results
def module_depsolving_wrapper(session, modules, strict=True):
"""
:param session : PDCClient instance
:param modules: list of module_info dicts
:return final list of the names of tags.
"""
log.debug("module_depsolving_wrapper(%r, strict=%r)" % (modules, strict))
# This is the set we're going to build up and return.
module_tags = set()
# We want to take only single
for module_dict in modules:
# Get enhanced info on this module from pdc.
info = get_module(session, module_dict, strict)
# Take note of the tag of this module, but only if it is a dep and
# not in the original list.
# XXX - But, for now go ahead and include it because that's how this
# code used to work.
module_tags.add(info['koji_tag'])
# Now, when we look for the deps of this module, use the mmd.xmd
# attributes because they contain the promise of *exactly* which
# versions of which deps we say we're going to build *this* module
# against.
if not info['modulemd']:
raise ValueError("No PDC modulemd found for %r" % info)
mmd = _extract_modulemd(info['modulemd'])
# Queue up the next tier of deps that we should look at..
for name, details in mmd.xmd['mbs']['buildrequires'].items():
modified_dep = {
'name': name,
'version': details['stream'],
'release': details['version'],
# Only return details about module builds that finished
'active': True,
}
info = get_module(session, modified_dep, strict)
module_tags.add(info['koji_tag'])
return list(module_tags)
def get_module_build_dependencies(session, module_info, strict=False):
"""
:param session : PDCClient instance
@@ -325,23 +280,38 @@ def get_module_build_dependencies(session, module_info, strict=False):
# XXX get definitive list of modules
deps = []
queried_mmd = get_module_modulemd(session, module_info, strict=strict)
queried_module = get_module(session, module_info, strict=strict)
yaml = queried_module['modulemd']
queried_mmd = _extract_modulemd(yaml, strict=strict)
if not queried_mmd or not queried_mmd.xmd.get('mbs') or not \
queried_mmd.xmd['mbs'].get('buildrequires'):
raise RuntimeError(
'The module "{0!r}" did not contain its modulemd or did not have '
'its xmd attribute filled out in PDC'.format(module_info))
# This is the set we're going to build up and return.
module_tags = set()
# Take note of the tag of this module, but only if it is a dep and
# not in the original list.
# XXX - But, for now go ahead and include it because that's how this
# code used to work.
module_tags.add(queried_module['koji_tag'])
buildrequires = queried_mmd.xmd['mbs']['buildrequires']
deps = [dict(
name=dep_name,
version=dep_info['stream'],
release=dep_info['version'],
) for dep_name, dep_info in buildrequires.items()]
# Queue up the next tier of deps that we should look at..
for name, details in buildrequires.items():
modified_dep = {
'name': name,
'version': details['stream'],
'release': details['version'],
# Only return details about module builds that finished
'active': True,
}
info = get_module(session, modified_dep, strict)
module_tags.add(info['koji_tag'])
deps = module_depsolving_wrapper(session, deps, strict=strict)
return deps
return module_tags
def get_module_commit_hash_and_version(session, module_info):
"""

View File

@@ -53,13 +53,17 @@ class TestPDCModule(unittest.TestCase):
assert result['variant_version'] == 'master'
assert 'build_deps' in result
def test_get_module_depsolving_wrapper(self):
query = [{
def test_get_module_build_dependencies(self):
"""
Tests that we return proper koji_tags with base-runtime
build-time dependencies.
"""
query = {
'name': 'base-runtime',
'version': 'master',
'release': '20170315134803',
}]
result = mbs_pdc.module_depsolving_wrapper(self.pdc, query)
}
result = mbs_pdc.get_module_build_dependencies(self.pdc, query)
expected = [
u'f26-modularity',
# Should the list of deps should not include the original tag?
@@ -68,14 +72,18 @@ class TestPDCModule(unittest.TestCase):
]
self.assertEqual(set(result), set(expected))
def test_get_module_depsolving_wrapper_recursive(self):
query = [{
def test_get_module_build_dependencies_single_level(self):
"""
Tests that we return just direct build-time dependencies of testmodule.
It means just testmodule itself and base-runtime, but no f26-modularity
(koji tag of bootstrap module which is build-require of base-runtime).
"""
query = {
'name': 'testmodule',
'version': 'master',
'release': '20170322155247',
'active': False,
}]
result = mbs_pdc.module_depsolving_wrapper(self.pdc, query)
'release': '20170322155247'
}
result = mbs_pdc.get_module_build_dependencies(self.pdc, query)
expected = [
u'module-base-runtime-master-20170315134803',
# Should the list of deps should not include the original tag?