Add modulemd metadata to repo even without components
There is a valid use case for modules without any RPMs in them. This patch makes it possible to include such modules in the repodata. Merges: https://pagure.io/pungi/pull-request/856 Signed-off-by: Jan Kaluza <jkaluza@redhat.com>
This commit is contained in:
parent
a1d559fb93
commit
18d005e593
@ -47,6 +47,14 @@ 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, {})
|
||||||
|
|
||||||
|
# Generate architecture specific modulemd metadata, so we can
|
||||||
|
# store per-architecture artifacts there later.
|
||||||
|
for mmd in variant.mmds:
|
||||||
|
mmd_id = "%s-%s" % (mmd.name, mmd.stream)
|
||||||
|
if mmd_id not in variant.arch_mmds[arch]:
|
||||||
|
arch_mmd = yaml.safe_load(mmd.dumps())
|
||||||
|
variant.arch_mmds[arch][mmd_id] = arch_mmd
|
||||||
|
|
||||||
# Contains per-module RPMs added to variant.
|
# Contains per-module RPMs added to variant.
|
||||||
added_rpms = {}
|
added_rpms = {}
|
||||||
|
|
||||||
@ -64,13 +72,7 @@ class GatherSourceModule(pungi.phases.gather.source.GatherSourceBase):
|
|||||||
|
|
||||||
for mmd in variant.mmds:
|
for mmd in variant.mmds:
|
||||||
mmd_id = "%s-%s" % (mmd.name, mmd.stream)
|
mmd_id = "%s-%s" % (mmd.name, mmd.stream)
|
||||||
# Generate architecture specific modulemd metadata
|
arch_mmd = variant.arch_mmds[arch][mmd_id]
|
||||||
# with list of artifacts only for this architecture.
|
|
||||||
if mmd_id not in variant.arch_mmds[arch]:
|
|
||||||
arch_mmd = yaml.safe_load(mmd.dumps())
|
|
||||||
variant.arch_mmds[arch][mmd_id] = arch_mmd
|
|
||||||
else:
|
|
||||||
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
|
||||||
@ -92,6 +94,10 @@ class GatherSourceModule(pungi.phases.gather.source.GatherSourceBase):
|
|||||||
# list is later used in createrepo phase to generated modules.yaml.
|
# list is later used in createrepo phase to generated modules.yaml.
|
||||||
for mmd_id, rpm_nevras in added_rpms.items():
|
for mmd_id, rpm_nevras in added_rpms.items():
|
||||||
arch_mmd = variant.arch_mmds[arch][mmd_id]
|
arch_mmd = variant.arch_mmds[arch][mmd_id]
|
||||||
|
# Modules without artifacts are also valid.
|
||||||
|
if ("artifacts" not in arch_mmd["data"] or
|
||||||
|
"rpms" not in arch_mmd["data"]["artifacts"]):
|
||||||
|
continue
|
||||||
arch_mmd["data"]["artifacts"]["rpms"] = [
|
arch_mmd["data"]["artifacts"]["rpms"] = [
|
||||||
rpm_nevra for rpm_nevra in rpm_nevras
|
rpm_nevra for rpm_nevra in rpm_nevras
|
||||||
if rpm_nevra in arch_mmd["data"]["artifacts"]["rpms"]]
|
if rpm_nevra in arch_mmd["data"]["artifacts"]["rpms"]]
|
||||||
|
Loading…
Reference in New Issue
Block a user