diff --git a/pungi/phases/createrepo.py b/pungi/phases/createrepo.py index 3a06a024..f33f7d4a 100644 --- a/pungi/phases/createrepo.py +++ b/pungi/phases/createrepo.py @@ -401,13 +401,12 @@ class ModulesMetadata(object): self.compose.log_info("Writing modules metadata: %s" % self.modules_metadata_file) self.productmd_modules_metadata.dump(self.modules_metadata_file) - def prepare_module_metadata(self, variant, arch, module_id, modulemd_path, category, module_rpms): + def prepare_module_metadata(self, variant, arch, nsvc, modulemd_path, category, module_rpms): """ - find uid/koji_tag which is correstponding with variant object and - add record(s) into module metadata structure + Find koji tag which corresponds to the module and add record into + module metadata structure. """ - for uid, koji_tag in variant.module_uid_to_koji_tag.items(): - uid_dict = self.productmd_modules_metadata.parse_uid(uid) - if module_id == '{module_name}-{stream}'.format(**uid_dict): - self.productmd_modules_metadata.add(variant.uid, arch, uid, koji_tag, modulemd_path, category, module_rpms) - break + koji_tag = variant.module_uid_to_koji_tag[nsvc] + self.productmd_modules_metadata.add( + variant.uid, arch, nsvc, koji_tag, modulemd_path, category, module_rpms + ) diff --git a/pungi/phases/gather/sources/source_module.py b/pungi/phases/gather/sources/source_module.py index ad58c75f..eb6008f5 100644 --- a/pungi/phases/gather/sources/source_module.py +++ b/pungi/phases/gather/sources/source_module.py @@ -57,7 +57,12 @@ class GatherSourceModule(pungi.phases.gather.source.GatherSourceBase): # store per-architecture artifacts there later. variant.arch_mmds.setdefault(arch, {}) for mmd in variant.mmds: - mmd_id = "%s-%s" % (mmd.get_name(), mmd.get_stream()) + mmd_id = "%s:%s:%s:%s" % ( + mmd.peek_name(), + mmd.peek_stream(), + mmd.peek_version(), + mmd.peek_context(), + ) if mmd_id not in variant.arch_mmds[arch]: arch_mmd = mmd.copy() variant.arch_mmds[arch][mmd_id] = arch_mmd @@ -78,7 +83,12 @@ class GatherSourceModule(pungi.phases.gather.source.GatherSourceBase): continue for mmd in variant.mmds: - mmd_id = "%s-%s" % (mmd.get_name(), mmd.get_stream()) + mmd_id = "%s:%s:%s:%s" % ( + mmd.peek_name(), + mmd.peek_stream(), + mmd.peek_version(), + mmd.peek_context(), + ) arch_mmd = variant.arch_mmds[arch][mmd_id] srpm = kobo.rpmlib.parse_nvr(rpm_obj.sourcerpm)["name"] diff --git a/tests/test_createrepophase.py b/tests/test_createrepophase.py index f1ceef4c..c9739c3c 100644 --- a/tests/test_createrepophase.py +++ b/tests/test_createrepophase.py @@ -782,11 +782,18 @@ class TestCreateVariantRepo(PungiTestCase): compose.has_comps = False variant = compose.variants['Server'] - variant.arch_mmds["x86_64"] = {} - variant.arch_mmds["x86_64"]["test-f27"] = variant.add_fake_module( - "test:f27:1:2017", rpm_nvrs=["bash-0:4.3.30-2.fc21.x86_64"]) - variant.arch_mmds["x86_64"]["test-f28"] = variant.add_fake_module( - "test:f28:1:2017", rpm_nvrs=["pkg-0:2.0.0-1.x86_64"]) + variant.arch_mmds["x86_64"] = { + "test:f27:2018:cafe": variant.add_fake_module( + "test:f27:1:2017", rpm_nvrs=["bash-0:4.3.30-2.fc21.x86_64"] + ), + "test:f28:2018:beef": variant.add_fake_module( + "test:f28:1:2017", rpm_nvrs=["pkg-0:2.0.0-1.x86_64"] + ), + } + variant.module_uid_to_koji_tag = { + "test:f28:2018:beef": "tag-1", + "test:f27:2018:cafe": "tag-2", + } def mocked_modifyrepo_cmd(repodir, mmd_path, **kwargs): modules = Modulemd.Module.new_all_from_file(mmd_path) diff --git a/tests/test_gather_method_hybrid.py b/tests/test_gather_method_hybrid.py index 88cb2bd6..66e40ce1 100644 --- a/tests/test_gather_method_hybrid.py +++ b/tests/test_gather_method_hybrid.py @@ -272,6 +272,8 @@ class TestRunSolver(HelperMixin, helpers.PungiTestCase): "mod:master": mock.Mock( peek_name=mock.Mock(return_value="mod"), peek_stream=mock.Mock(return_value="master"), + peek_version=mock.Mock(return_value="ver"), + peek_context=mock.Mock(return_value="ctx"), ) } po.return_value = (mock.Mock(), mock.Mock()) diff --git a/tests/test_gather_source_module.py b/tests/test_gather_source_module.py index 39bc27f8..e831a46a 100644 --- a/tests/test_gather_source_module.py +++ b/tests/test_gather_source_module.py @@ -46,7 +46,7 @@ class TestGatherSourceModule(helpers.PungiTestCase): self.assertEqual(len(groups), 0) variant = self.compose.variants["Server"] - arch_mmd = variant.arch_mmds["x86_64"]["testmodule-master"] + arch_mmd = variant.arch_mmds["x86_64"]["testmodule:master:1:2017"] self.assertEqual(set(arch_mmd.get_rpm_artifacts().get()), set(["pkg-0:1.0.0-1.x86_64"])) @@ -63,7 +63,7 @@ class TestGatherSourceModule(helpers.PungiTestCase): self.assertEqual(len(groups), 0) variant = self.compose.variants["Server"] - arch_mmd = variant.arch_mmds["x86_64"]["testmodule-master"] + arch_mmd = variant.arch_mmds["x86_64"]["testmodule:master:1:2017"] self.assertEqual(set(arch_mmd.get_rpm_artifacts().get()), set(["pkg-0:1.0.0-1.x86_64", "pkg-0:1.0.0-1.i686"])) @@ -78,5 +78,5 @@ class TestGatherSourceModule(helpers.PungiTestCase): self.assertEqual(len(groups), 0) variant = self.compose.variants["Server"] - arch_mmd = variant.arch_mmds["x86_64"]["testmodule-master"] + arch_mmd = variant.arch_mmds["x86_64"]["testmodule:master:1:2017"] self.assertEqual(len(arch_mmd.get_rpm_artifacts().get()), 0)