Use libmodulemd instead of modulemd Python module
Merges: https://pagure.io/pungi/pull-request/851 Signed-off-by: Jan Kaluza <jkaluza@redhat.com>
This commit is contained in:
parent
56e00505e0
commit
340ae4d286
@ -74,7 +74,7 @@ class GatherPhase(PhaseBase):
|
||||
# Modules are not supported, check if we need them
|
||||
for variant in self.compose.variants.values():
|
||||
if variant.modules:
|
||||
errors.append('Modular compose requires pdc_client and modulemd packages.')
|
||||
errors.append('Modular compose requires pdc_client and libmodulemd packages.')
|
||||
|
||||
if errors:
|
||||
raise ValueError('\n'.join(errors))
|
||||
|
@ -50,7 +50,7 @@ class GatherSourceModule(pungi.phases.gather.source.GatherSourceBase):
|
||||
# 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)
|
||||
mmd_id = "%s-%s" % (mmd.get_name(), mmd.get_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
|
||||
@ -71,13 +71,13 @@ class GatherSourceModule(pungi.phases.gather.source.GatherSourceBase):
|
||||
continue
|
||||
|
||||
for mmd in variant.mmds:
|
||||
mmd_id = "%s-%s" % (mmd.name, mmd.stream)
|
||||
mmd_id = "%s-%s" % (mmd.get_name(), mmd.get_stream())
|
||||
arch_mmd = variant.arch_mmds[arch][mmd_id]
|
||||
|
||||
srpm = kobo.rpmlib.parse_nvr(rpm_obj.sourcerpm)["name"]
|
||||
if (srpm in mmd.components.rpms.keys() and
|
||||
rpm_obj.name not in mmd.filter.rpms and
|
||||
rpm_obj.nevra in mmd.artifacts.rpms):
|
||||
if (srpm in mmd.get_rpm_components().keys() and
|
||||
rpm_obj.name not in mmd.get_rpm_filter().get() and
|
||||
rpm_obj.nevra in mmd.get_rpm_artifacts().get()):
|
||||
packages.add((rpm_obj, None))
|
||||
added_rpms.setdefault(mmd_id, [])
|
||||
added_rpms[mmd_id].append(str(rpm_obj.nevra))
|
||||
|
@ -34,7 +34,9 @@ import pungi.phases.pkgset.source
|
||||
|
||||
try:
|
||||
from pdc_client import PDCClient
|
||||
import modulemd
|
||||
import gi
|
||||
gi.require_version('Modulemd', '1.0') # noqa
|
||||
from gi.repository import Modulemd
|
||||
WITH_MODULES = True
|
||||
except:
|
||||
WITH_MODULES = False
|
||||
@ -42,7 +44,8 @@ except:
|
||||
|
||||
def get_pdc_client_session(compose):
|
||||
if not WITH_MODULES:
|
||||
compose.log_warning("pdc_client or modulemd module is not installed, "
|
||||
compose.log_warning("pdc_client module, pygobject module or "
|
||||
"libmodulemd library is not installed, "
|
||||
"support for modules is disabled")
|
||||
return None
|
||||
try:
|
||||
@ -240,12 +243,12 @@ def populate_global_pkgset(compose, koji_wrapper, path_prefix, event_id):
|
||||
for module in variant.get_modules():
|
||||
pdc_module = get_module(compose, session, module["name"])
|
||||
pdc_modules.append(pdc_module)
|
||||
mmd = modulemd.ModuleMetadata()
|
||||
mmd.loads(pdc_module["modulemd"])
|
||||
mmd = Modulemd.Module.new_from_string(pdc_module["modulemd"])
|
||||
mmd.upgrade()
|
||||
|
||||
# Catch the issue when PDC does not contain RPMs, but
|
||||
# the module definition says there should be some.
|
||||
if not pdc_module["rpms"] and mmd.components.rpms:
|
||||
if not pdc_module["rpms"] and mmd.get_rpm_components():
|
||||
raise ValueError(
|
||||
"Module %s does not have any rpms in 'rpms' PDC field,"
|
||||
"but according to modulemd, there should be some."
|
||||
@ -253,10 +256,12 @@ def populate_global_pkgset(compose, koji_wrapper, path_prefix, event_id):
|
||||
|
||||
# Add RPMs from PDC response to 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 pdc_module["rpms"]:
|
||||
if rpm_nevra.endswith(".rpm"):
|
||||
rpm_nevra = rpm_nevra[:-len(".rpm")]
|
||||
mmd.artifacts.add_rpm(str(rpm_nevra))
|
||||
rpm_artifacts.add(str(rpm_nevra))
|
||||
mmd.set_rpm_artifacts(rpm_artifacts)
|
||||
|
||||
tag = pdc_module["koji_tag"]
|
||||
variant.mmds.append(mmd)
|
||||
|
@ -11,7 +11,9 @@ import re
|
||||
sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
|
||||
|
||||
try:
|
||||
import modulemd # noqa
|
||||
import gi # noqa
|
||||
gi.require_version('Modulemd', '1.0') # noqa
|
||||
from gi.repository import Modulemd # noqa
|
||||
import pdc_client # noqa
|
||||
HAS_MODULE_SUPPORT = True
|
||||
except ImportError:
|
||||
@ -130,7 +132,7 @@ class TestPopulateGlobalPkgset(helpers.PungiTestCase):
|
||||
@mock.patch('pungi.phases.pkgset.pkgsets.KojiPackageSet')
|
||||
@mock.patch('pungi.phases.pkgset.sources.source_koji.get_module')
|
||||
@mock.patch('pungi.phases.pkgset.sources.source_koji.get_pdc_client_session')
|
||||
@mock.patch('pungi.phases.pkgset.sources.source_koji.modulemd')
|
||||
@mock.patch('pungi.phases.pkgset.sources.source_koji.Modulemd')
|
||||
def test_pdc_log(self, modulemd, get_pdc_client_session, get_module, KojiPackageSet, pickle_dumps):
|
||||
|
||||
pickle_dumps.return_value = b'DATA'
|
||||
|
Loading…
Reference in New Issue
Block a user