pkgset: Stop prefilling RPM artifacts

Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
Lubomír Sedlář 2018-10-02 11:00:18 +02:00
parent 08d65bdde6
commit 06b32b5d80
4 changed files with 10 additions and 30 deletions

View File

@ -141,15 +141,9 @@ 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 nsvc, rpm_nevras in added_rpms.items(): for nsvc, rpm_nevras in added_rpms.items():
arch_mmd = variant.arch_mmds[arch][nsvc] arch_mmd = variant.arch_mmds[arch][nsvc]
artifacts = arch_mmd.get_rpm_artifacts()
# Modules without artifacts are also valid.
if not artifacts or artifacts.size() == 0:
continue
added_artifacts = Modulemd.SimpleSet() added_artifacts = Modulemd.SimpleSet()
for rpm_nevra in rpm_nevras: for rpm_nevra in rpm_nevras:
if artifacts.contains(rpm_nevra):
added_artifacts.add(rpm_nevra) added_artifacts.add(rpm_nevra)
arch_mmd.set_rpm_artifacts(added_artifacts) arch_mmd.set_rpm_artifacts(added_artifacts)
@ -159,28 +153,17 @@ class GatherSourceModule(pungi.phases.gather.source.GatherSourceBase):
def should_include(rpm_obj, arch, arch_mmd, multilib_arches): def should_include(rpm_obj, arch, arch_mmd, multilib_arches):
srpm = kobo.rpmlib.parse_nvr(rpm_obj.sourcerpm)["name"] srpm = kobo.rpmlib.parse_nvr(rpm_obj.sourcerpm)["name"]
filtered = False
buildopts = arch_mmd.get_buildopts() buildopts = arch_mmd.get_buildopts()
if buildopts: if buildopts:
whitelist = buildopts.get_rpm_whitelist() whitelist = buildopts.get_rpm_whitelist()
if whitelist: if whitelist:
# We have whitelist, no filtering against components. # We have whitelist, no filtering against components.
filtered = True
if srpm not in whitelist: if srpm not in whitelist:
# Package is not on the list, skip it. # Package is not on the list, skip it.
return False return False
if not filtered:
# Skip this mmd if this RPM does not belong to it.
if (srpm not in arch_mmd.get_rpm_components().keys() or
rpm_obj.nevra not in arch_mmd.get_rpm_artifacts().get()):
return False
# Filter out the RPM from artifacts if its filtered in MMD. # Filter out the RPM from artifacts if its filtered in MMD.
if rpm_obj.name in arch_mmd.get_rpm_filter().get(): if rpm_obj.name in arch_mmd.get_rpm_filter().get():
# No need to check if the rpm_obj is in rpm artifacts,
# the .remove() method does that anyway.
arch_mmd.get_rpm_artifacts().remove(str(rpm_obj.nevra))
return False return False
# Skip the rpm_obj if it's built for multilib arch, but multilib is not # Skip the rpm_obj if it's built for multilib arch, but multilib is not

View File

@ -254,14 +254,6 @@ def _add_module_to_variant(variant, mmd, rpms, add_to_variant_modules=False):
"but according to modulemd, there should be some." "but according to modulemd, there should be some."
% nsvc) % nsvc)
# Add RPMs from build systemto modulemd, so we can track
# what RPM is in which module later in gather phase.
rpm_artifacts = mmd.get_rpm_artifacts()
for rpm_nevra in rpms:
if rpm_nevra.endswith(".rpm"):
rpm_nevra = rpm_nevra[:-len(".rpm")]
rpm_artifacts.add(str(rpm_nevra))
mmd.set_rpm_artifacts(rpm_artifacts)
variant.mmds.append(mmd) variant.mmds.append(mmd)
if add_to_variant_modules: if add_to_variant_modules:

View File

@ -59,7 +59,7 @@ class MockVariant(mock.Mock):
def get_modular_koji_tags(self, arch=None, types=None): def get_modular_koji_tags(self, arch=None, types=None):
return [] return []
def add_fake_module(self, nsvc, rpm_nvrs=None): def add_fake_module(self, nsvc, rpm_nvrs=None, with_artifacts=False):
if not Modulemd: if not Modulemd:
# No support for modules # No support for modules
return return
@ -85,6 +85,7 @@ class MockVariant(mock.Mock):
component.set_name(rpm_name) component.set_name(rpm_name)
component.set_rationale("Needed for test") component.set_rationale("Needed for test")
mmd.add_rpm_component(component) mmd.add_rpm_component(component)
if with_artifacts:
mmd.set_rpm_artifacts(artifacts) mmd.set_rpm_artifacts(artifacts)
if self.modules is None: if self.modules is None:

View File

@ -784,10 +784,14 @@ class TestCreateVariantRepo(PungiTestCase):
variant = compose.variants['Server'] variant = compose.variants['Server']
variant.arch_mmds["x86_64"] = { variant.arch_mmds["x86_64"] = {
"test:f27:2018:cafe": 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"],
with_artifacts=True,
), ),
"test:f28:2018:beef": variant.add_fake_module( "test:f28:2018:beef": variant.add_fake_module(
"test:f28:1:2017", rpm_nvrs=["pkg-0:2.0.0-1.x86_64"] "test:f28:1:2017",
rpm_nvrs=["pkg-0:2.0.0-1.x86_64"],
with_artifacts=True,
), ),
} }
variant.module_uid_to_koji_tag = { variant.module_uid_to_koji_tag = {