mirror of
https://pagure.io/fm-orchestrator.git
synced 2026-11-28 15:14:32 +08:00
Port to libmodulemd and support v2 modulemd without module stream expansion
This commit is contained in:
@@ -84,12 +84,16 @@ class CoprModuleBuilder(GenericBuilder):
|
||||
self._create_module_safe()
|
||||
mmd = self.module.mmd()
|
||||
|
||||
# Even though get_buildrequires returns a dictionary with the values as lists, there will
|
||||
# always be a single item in the list after MBS processes it
|
||||
buildrequires_d = {name: dep.get()[0]
|
||||
for name, dep in mmd.get_dependencies()[0].get_buildrequires().items()}
|
||||
buildrequires = ["@{}:{}/{}".format(n, s, "buildroot")
|
||||
for n, s in mmd.buildrequires.items()]
|
||||
for n, s in buildrequires_d.items()]
|
||||
|
||||
buildroot_profile = mmd.profiles.get("buildroot")
|
||||
buildroot_profile = mmd.get_profiles().get("buildroot")
|
||||
if buildroot_profile:
|
||||
buildrequires.extend(buildroot_profile.rpms)
|
||||
buildrequires.extend(buildroot_profile.get_rpms())
|
||||
|
||||
self._update_chroot(packages=buildrequires)
|
||||
|
||||
@@ -150,9 +154,9 @@ class CoprModuleBuilder(GenericBuilder):
|
||||
# Write module's name, stream and version into the modulemd file
|
||||
# so Copr can parse it from there
|
||||
mmd = self.module.mmd()
|
||||
mmd.name = str(self.module.name)
|
||||
mmd.stream = str(self.module.stream)
|
||||
mmd.version = int(self.module.version)
|
||||
mmd.set_name(str(self.module.name))
|
||||
mmd.set_stream(str(self.module.stream))
|
||||
mmd.set_version(int(self.module.version))
|
||||
|
||||
modulemd = tempfile.mktemp()
|
||||
mmd.dump(modulemd)
|
||||
|
||||
@@ -238,7 +238,7 @@ class KojiModuleBuilder(GenericBuilder):
|
||||
# module-build-macros to conflict with these filtered RPMs to ensure
|
||||
# they won't be installed to buildroot.
|
||||
filter_conflicts = ""
|
||||
for req_name, req_data in mmd.xmd["mbs"]["buildrequires"].items():
|
||||
for req_name, req_data in mmd.get_xmd()["mbs"]["buildrequires"].items():
|
||||
if req_data["filtered_rpms"]:
|
||||
filter_conflicts += "# Filtered rpms from %s module:\n" % (
|
||||
req_name)
|
||||
@@ -300,8 +300,9 @@ chmod 644 %buildroot/%_sysconfdir/rpm/macros.zz-modules
|
||||
filter_conflicts=filter_conflicts)
|
||||
|
||||
modulemd_macros = ""
|
||||
if mmd.buildopts and mmd.buildopts.rpms:
|
||||
modulemd_macros = mmd.buildopts.rpms.macros
|
||||
rpm_buildopts = mmd.get_rpm_buildopts()
|
||||
if rpm_buildopts:
|
||||
modulemd_macros = rpm_buildopts.get('macros')
|
||||
|
||||
macros_content = """
|
||||
|
||||
|
||||
@@ -26,12 +26,14 @@ import logging
|
||||
import os
|
||||
import koji
|
||||
import kobo.rpmlib
|
||||
import modulemd
|
||||
import pipes
|
||||
import platform
|
||||
import re
|
||||
import threading
|
||||
|
||||
import gi
|
||||
gi.require_version('Modulemd', '1.0') # noqa
|
||||
from gi.repository import Modulemd
|
||||
from module_build_service import conf, log
|
||||
import module_build_service.scm
|
||||
import module_build_service.utils
|
||||
@@ -182,17 +184,20 @@ class MockModuleBuilder(GenericBuilder):
|
||||
if m1.last_batch_id() == m1.batch:
|
||||
# If RPM is filtered-out, do not add it to artifacts list.
|
||||
nvr = kobo.rpmlib.parse_nvr(rpm)
|
||||
if nvr["name"] in m1_mmd.filter.rpms:
|
||||
if nvr["name"] in m1_mmd.get_rpm_filter().get():
|
||||
continue
|
||||
|
||||
pkglist_f.write(rpm + '\n')
|
||||
rpm = rpm[:-len(".rpm")]
|
||||
m1_mmd.artifacts.add_rpm(str(rpm))
|
||||
component = Modulemd.ComponentRpm()
|
||||
component.set_name(str(rpm))
|
||||
component.set_rationale('none')
|
||||
m1_mmd.add_rpm_component(component)
|
||||
|
||||
pkglist_f.close()
|
||||
|
||||
mmd_path = os.path.join(path, "modules.yaml")
|
||||
modulemd.dump_all(mmd_path, [m1_mmd])
|
||||
m1_mmd.dump(mmd_path)
|
||||
|
||||
# Generate repo and inject modules.yaml there.
|
||||
execute_cmd(['/usr/bin/createrepo_c', '--pkglist', pkglist, path])
|
||||
|
||||
Reference in New Issue
Block a user