Generate proper modular metadata when there are different versions of the same package in the variant
Merges: #629 Signed-off-by: Jan Kaluza <jkaluza@redhat.com>
This commit is contained in:
parent
58a6affd65
commit
118444a311
@ -38,26 +38,43 @@ class GatherSourceModule(pungi.phases.gather.source.GatherSourceBase):
|
|||||||
if variant is not None and variant.modules:
|
if variant is not None and variant.modules:
|
||||||
variant.arch_mmds.setdefault(arch, {})
|
variant.arch_mmds.setdefault(arch, {})
|
||||||
|
|
||||||
|
# Contains per-module RPMs added to variant.
|
||||||
|
added_rpms = {}
|
||||||
|
|
||||||
rpms = sum([
|
rpms = sum([
|
||||||
variant.pkgset.rpms_by_arch.get(a, [])
|
variant.pkgset.rpms_by_arch.get(a, [])
|
||||||
for a in compatible_arches
|
for a in compatible_arches
|
||||||
], [])
|
], [])
|
||||||
for rpm_obj in rpms:
|
for rpm_obj in rpms:
|
||||||
for mmd in variant.mmds:
|
for mmd in variant.mmds:
|
||||||
|
mmd_id = "%s-%s" % (mmd.name, mmd.stream)
|
||||||
# Generate architecture specific modulemd metadata
|
# Generate architecture specific modulemd metadata
|
||||||
# with list of artifacts only for this architecture.
|
# with list of artifacts only for this architecture.
|
||||||
if mmd.name not in variant.arch_mmds[arch]:
|
if mmd_id not in variant.arch_mmds[arch]:
|
||||||
arch_mmd = yaml.safe_load(mmd.dumps())
|
arch_mmd = yaml.safe_load(mmd.dumps())
|
||||||
arch_mmd["data"]["artifacts"] = {"rpms": []}
|
variant.arch_mmds[arch][mmd_id] = arch_mmd
|
||||||
variant.arch_mmds[arch][mmd.name] = arch_mmd
|
|
||||||
else:
|
else:
|
||||||
arch_mmd = variant.arch_mmds[arch][mmd.name]
|
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"]
|
||||||
if (srpm in mmd.components.rpms.keys() and
|
if (srpm in mmd.components.rpms.keys() and
|
||||||
rpm_obj.name not in mmd.filter.rpms):
|
rpm_obj.name not in mmd.filter.rpms):
|
||||||
packages.add((rpm_obj.name, None))
|
packages.add((rpm_obj.name, None))
|
||||||
arch_mmd["data"]["artifacts"]["rpms"].append(
|
added_rpms.setdefault(mmd_id, [])
|
||||||
str(rpm_obj.nevra))
|
added_rpms[mmd_id].append(str(rpm_obj.nevra))
|
||||||
|
|
||||||
|
# GatherSource returns all the packages in variant and does not
|
||||||
|
# care which package is in which module, but for modular metadata
|
||||||
|
# in the resulting compose repository, we have to know which RPM
|
||||||
|
# is part of which module.
|
||||||
|
# We therefore iterate over all the added packages grouped by
|
||||||
|
# particular module and use them to filter out the packages which
|
||||||
|
# have not been added to variant from the `arch_mmd`. This package
|
||||||
|
# list is later used in createrepo phase to generated modules.yaml.
|
||||||
|
for mmd_id, rpm_nevras in added_rpms.items():
|
||||||
|
arch_mmd = variant.arch_mmds[arch][mmd_id]
|
||||||
|
arch_mmd["data"]["artifacts"]["rpms"] = [
|
||||||
|
rpm_nevra for rpm_nevra in rpm_nevras
|
||||||
|
if rpm_nevra in arch_mmd["data"]["artifacts"]["rpms"]]
|
||||||
|
|
||||||
return packages, groups
|
return packages, groups
|
||||||
|
@ -162,6 +162,14 @@ def populate_global_pkgset(compose, koji_wrapper, path_prefix, event_id):
|
|||||||
pdc_module = get_module(session, module["name"])
|
pdc_module = get_module(session, module["name"])
|
||||||
mmd = modulemd.ModuleMetadata()
|
mmd = modulemd.ModuleMetadata()
|
||||||
mmd.loads(pdc_module["modulemd"])
|
mmd.loads(pdc_module["modulemd"])
|
||||||
|
|
||||||
|
# Add RPMs from PDC response to modulemd, so we can track
|
||||||
|
# what RPM is in which module later in gather phase.
|
||||||
|
for rpm_nevra in pdc_module["rpms"]:
|
||||||
|
if rpm_nevra.endswith(".rpm"):
|
||||||
|
rpm_nevra = rpm_nevra[:-len(".rpm")]
|
||||||
|
mmd.artifacts.add_rpm(str(rpm_nevra))
|
||||||
|
|
||||||
tag = pdc_module["koji_tag"]
|
tag = pdc_module["koji_tag"]
|
||||||
variant.mmds.append(mmd)
|
variant.mmds.append(mmd)
|
||||||
variant_tags[variant].append(tag)
|
variant_tags[variant].append(tag)
|
||||||
|
Loading…
Reference in New Issue
Block a user