From c2824138d3f32da142a3604f3ea5719b5e7e2736 Mon Sep 17 00:00:00 2001 From: mprahl Date: Thu, 5 Apr 2018 10:28:18 -0400 Subject: [PATCH] Fix a bug in MSE when a module requires a module that isn't also a buildrequire --- module_build_service/utils/mse.py | 12 ++++++++---- tests/test_utils/test_utils_mse.py | 8 ++++++++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/module_build_service/utils/mse.py b/module_build_service/utils/mse.py index b0454bb2..4e7e92b8 100644 --- a/module_build_service/utils/mse.py +++ b/module_build_service/utils/mse.py @@ -279,7 +279,7 @@ def generate_expanded_mmds(session, mmd, raise_if_stream_ambigous=False, default # Each generated MMD must be new Module object... # TODO: Use copy method once its in released libmodulemd: # https://github.com/fedora-modularity/libmodulemd/pull/20 - mmd_copy = Modulemd.Module.new_from_string(mmd.dumps()) + mmd_copy = Modulemd.Module.new_from_string(current_mmd.dumps()) xmd = glib.from_variant_dict(mmd_copy.get_xmd()) # Requires contain the NSVC representing the input mmd. @@ -319,17 +319,21 @@ def generate_expanded_mmds(session, mmd, raise_if_stream_ambigous=False, default dep_requires = dep.get_requires() dep_buildrequires = dep.get_buildrequires() for req_name, req_streams in dep_requires.items(): - if (req_name not in dep_buildrequires or - set(req_streams.get()) != set(dep_buildrequires[req_name].get())): + if req_name not in dep_buildrequires: + # This require is not a buildrequire so just copy this runtime requirement to + # new_dep and don't touch buildrequires + new_dep.add_requires(req_name, req_streams.get()) + elif set(req_streams.get()) != set(dep_buildrequires[req_name].get()): # Streams in runtime section are not the same as in buildtime section, # so just copy this runtime requirement to new_dep. new_dep.add_requires(req_name, req_streams.get()) + new_dep.add_buildrequires(req_name, [req_name_stream[req_name]]) else: # This runtime requirement has the same streams in both runtime/buildtime # requires sections, so replace streams in both sections by the one we # really used in this resolved variant. new_dep.add_requires(req_name, [req_name_stream[req_name]]) - new_dep.add_buildrequires(req_name, [req_name_stream[req_name]]) + new_dep.add_buildrequires(req_name, [req_name_stream[req_name]]) mmd_copy.set_dependencies((new_dep, )) # The Modulemd.Dependencies() stores only streams, but to really build this diff --git a/tests/test_utils/test_utils_mse.py b/tests/test_utils/test_utils_mse.py index bf3e8d21..47bc5a31 100644 --- a/tests/test_utils/test_utils_mse.py +++ b/tests/test_utils/test_utils_mse.py @@ -205,6 +205,14 @@ class TestUtilsModuleStreamExpansion: set([ frozenset(['foo:1', 'gtk:1']) ])), + + ({"gtk": ["1"], "foo": ["1"]}, {"gtk": ["1"]}, False, + set([ + frozenset(['gtk:1:0:c2', 'platform:f28:0:c10']) + ]), + set([ + frozenset(['gtk:1']) + ])), ]) def test_generate_expanded_mmds_buildrequires( self, requires, build_requires, stream_ambigous, expected_xmd,