Index arch modulemd by full NSVC

There can be multiple modules with the same name and stream. They should
all have the same version, but will have different contexts. Fus takes
only N:S as input, but should pull in all matching modules. We just need
to give it correct data in the repo.

Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
Lubomír Sedlář 2018-09-05 08:51:38 +02:00
parent fbb739ef17
commit 1350684c31
5 changed files with 36 additions and 18 deletions

View File

@ -401,13 +401,12 @@ class ModulesMetadata(object):
self.compose.log_info("Writing modules metadata: %s" % self.modules_metadata_file) self.compose.log_info("Writing modules metadata: %s" % self.modules_metadata_file)
self.productmd_modules_metadata.dump(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 Find koji tag which corresponds to the module and add record into
add record(s) into module metadata structure module metadata structure.
""" """
for uid, koji_tag in variant.module_uid_to_koji_tag.items(): koji_tag = variant.module_uid_to_koji_tag[nsvc]
uid_dict = self.productmd_modules_metadata.parse_uid(uid) self.productmd_modules_metadata.add(
if module_id == '{module_name}-{stream}'.format(**uid_dict): variant.uid, arch, nsvc, koji_tag, modulemd_path, category, module_rpms
self.productmd_modules_metadata.add(variant.uid, arch, uid, koji_tag, modulemd_path, category, module_rpms) )
break

View File

@ -57,7 +57,12 @@ class GatherSourceModule(pungi.phases.gather.source.GatherSourceBase):
# store per-architecture artifacts there later. # store per-architecture artifacts there later.
variant.arch_mmds.setdefault(arch, {}) variant.arch_mmds.setdefault(arch, {})
for mmd in variant.mmds: 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]: if mmd_id not in variant.arch_mmds[arch]:
arch_mmd = mmd.copy() arch_mmd = mmd.copy()
variant.arch_mmds[arch][mmd_id] = arch_mmd variant.arch_mmds[arch][mmd_id] = arch_mmd
@ -78,7 +83,12 @@ class GatherSourceModule(pungi.phases.gather.source.GatherSourceBase):
continue continue
for mmd in variant.mmds: 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] arch_mmd = variant.arch_mmds[arch][mmd_id]
srpm = kobo.rpmlib.parse_nvr(rpm_obj.sourcerpm)["name"] srpm = kobo.rpmlib.parse_nvr(rpm_obj.sourcerpm)["name"]

View File

@ -782,11 +782,18 @@ class TestCreateVariantRepo(PungiTestCase):
compose.has_comps = False compose.has_comps = False
variant = compose.variants['Server'] variant = compose.variants['Server']
variant.arch_mmds["x86_64"] = {} variant.arch_mmds["x86_64"] = {
variant.arch_mmds["x86_64"]["test-f27"] = variant.add_fake_module( "test:f27:2018:cafe": variant.add_fake_module(
"test:f27:1:2017", rpm_nvrs=["bash-0:4.3.30-2.fc21.x86_64"]) "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"]) "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): def mocked_modifyrepo_cmd(repodir, mmd_path, **kwargs):
modules = Modulemd.Module.new_all_from_file(mmd_path) modules = Modulemd.Module.new_all_from_file(mmd_path)

View File

@ -272,6 +272,8 @@ class TestRunSolver(HelperMixin, helpers.PungiTestCase):
"mod:master": mock.Mock( "mod:master": mock.Mock(
peek_name=mock.Mock(return_value="mod"), peek_name=mock.Mock(return_value="mod"),
peek_stream=mock.Mock(return_value="master"), 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()) po.return_value = (mock.Mock(), mock.Mock())

View File

@ -46,7 +46,7 @@ class TestGatherSourceModule(helpers.PungiTestCase):
self.assertEqual(len(groups), 0) self.assertEqual(len(groups), 0)
variant = self.compose.variants["Server"] 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()), self.assertEqual(set(arch_mmd.get_rpm_artifacts().get()),
set(["pkg-0:1.0.0-1.x86_64"])) set(["pkg-0:1.0.0-1.x86_64"]))
@ -63,7 +63,7 @@ class TestGatherSourceModule(helpers.PungiTestCase):
self.assertEqual(len(groups), 0) self.assertEqual(len(groups), 0)
variant = self.compose.variants["Server"] 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()), 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"])) 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) self.assertEqual(len(groups), 0)
variant = self.compose.variants["Server"] 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) self.assertEqual(len(arch_mmd.get_rpm_artifacts().get()), 0)