mirror of
https://pagure.io/fm-orchestrator.git
synced 2026-06-14 22:17:34 +08:00
Fill in the 'filterer_rpms' in backend to not access Koji from frontend.
This commit is contained in:
@@ -29,6 +29,7 @@ import tempfile
|
||||
import os
|
||||
from multiprocessing.dummy import Pool as ThreadPool
|
||||
from datetime import datetime
|
||||
import kobo.rpmlib
|
||||
|
||||
from module_build_service import conf, db, log, models, Modulemd
|
||||
from module_build_service.errors import (
|
||||
@@ -38,6 +39,53 @@ import module_build_service.scm
|
||||
from .mse import generate_expanded_mmds
|
||||
|
||||
|
||||
def record_filtered_rpms(mmd):
|
||||
"""
|
||||
Reads the mmd["xmd"]["buildrequires"] and extends it with "filtered_rpms"
|
||||
list containing the NVRs of filtered RPMs in a buildrequired module.
|
||||
|
||||
:param Modulemd mmd: Modulemd of input module.
|
||||
:rtype: Modulemd
|
||||
:return: Modulemd extended with the "filtered_rpms" in XMD section.
|
||||
"""
|
||||
# Imported here to allow import of utils in GenericBuilder.
|
||||
from module_build_service.builder import GenericBuilder
|
||||
|
||||
new_buildrequires = {}
|
||||
resolver = module_build_service.resolver.GenericResolver.create(conf)
|
||||
for req_name, req_data in mmd.get_xmd()["mbs"]["buildrequires"].items():
|
||||
# In case this is module resubmit or local build, the filtered_rpms
|
||||
# will already be there, so there is no point in generating them again.
|
||||
if "filtered_rpms" in req_data:
|
||||
continue
|
||||
|
||||
# We can just get the first modulemd data from result right here thanks to
|
||||
# strict=True, so in case the module cannot be found, get_module_modulemds
|
||||
# raises an exception.
|
||||
req_mmd = resolver.get_module_modulemds(
|
||||
req_name, req_data["stream"], req_data["version"], req_data["context"], True)[0]
|
||||
|
||||
# Find out the particular NVR of filtered packages
|
||||
filtered_rpms = []
|
||||
rpm_filter = req_mmd.get_rpm_filter()
|
||||
if rpm_filter and rpm_filter.get():
|
||||
rpm_filter = rpm_filter.get()
|
||||
built_nvrs = GenericBuilder.backends[conf.system].get_built_rpms_in_module_build(
|
||||
req_mmd)
|
||||
for nvr in built_nvrs:
|
||||
parsed_nvr = kobo.rpmlib.parse_nvr(nvr)
|
||||
if parsed_nvr["name"] in rpm_filter:
|
||||
filtered_rpms.append(nvr)
|
||||
req_data["filtered_rpms"] = filtered_rpms
|
||||
new_buildrequires[req_name] = req_data
|
||||
|
||||
# Replace the old buildrequires with new ones.
|
||||
xmd = glib.from_variant_dict(mmd.get_xmd())
|
||||
xmd["mbs"]["buildrequires"] = new_buildrequires
|
||||
mmd.set_xmd(glib.dict_values(xmd))
|
||||
return mmd
|
||||
|
||||
|
||||
def _scm_get_latest(pkg):
|
||||
try:
|
||||
# If the modulemd specifies that the 'f25' branch is what
|
||||
|
||||
Reference in New Issue
Block a user