From 9c603a27ec724ca1f9bad54d59de8e461dec116d Mon Sep 17 00:00:00 2001 From: Matt Prahl Date: Apr 05 2018 15:29:39 +0000 Subject: Merge #908 `Fix a bug in MSE when a module requires a module that isn't also a buildrequire` --- diff --git a/Dockerfile-tests b/Dockerfile-tests index 69a9f61..d7b83e2 100644 --- a/Dockerfile-tests +++ b/Dockerfile-tests @@ -3,7 +3,7 @@ FROM centos:7 WORKDIR /build RUN yum -y update RUN yum -y install epel-release yum-utils -RUN yum-config-manager --add-repo https://kojipkgs.fedoraproject.org/repos-dist/epel7Server-infra-stg/latest/x86_64/ +RUN yum-config-manager --add-repo https://kojipkgs.fedoraproject.org/repos-dist/epel7Server-infra/latest/x86_64/ RUN yum -y install \ --nogpgcheck \ --setopt=deltarpm=0 \ @@ -31,7 +31,7 @@ RUN yum -y install \ python-mock \ python-pip \ python-six \ - python2-solv \ + python-solv \ python-sqlalchemy \ python-tabulate \ # Test-only dependencies diff --git a/module_build_service/utils/mse.py b/module_build_service/utils/mse.py index b0454bb..4e7e92b 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 bf3e8d2..47bc5a3 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,