Allow gather source classes to return SimpleRpmWrapper objects from pkgset phase directly.

Signed-off-by: Jan Kaluza <jkaluza@redhat.com>
This commit is contained in:
Jan Kaluza 2017-06-13 14:39:33 +02:00
parent a54b68d08b
commit f7197ddbcc
3 changed files with 15 additions and 4 deletions

View File

@ -17,6 +17,7 @@
import os import os
from kobo.shortcuts import run from kobo.shortcuts import run
from kobo.pkgset import SimpleRpmWrapper, RpmWrapper
from pungi.util import rmtree, get_arch_variant_data from pungi.util import rmtree, get_arch_variant_data
from pungi.wrappers.pungi import PungiWrapper from pungi.wrappers.pungi import PungiWrapper
@ -47,7 +48,11 @@ class GatherMethodDeps(pungi.phases.gather.method.GatherMethodBase):
def _format_packages(pkgs): def _format_packages(pkgs):
"""Sort packages and merge name with arch.""" """Sort packages and merge name with arch."""
for pkg_name, pkg_arch in sorted(pkgs): for pkg, pkg_arch in sorted(pkgs):
if type(pkg) in [SimpleRpmWrapper, RpmWrapper]:
pkg_name = pkg.name
else:
pkg_name = pkg
if pkg_arch: if pkg_arch:
yield '%s.%s' % (pkg_name, pkg_arch) yield '%s.%s' % (pkg_name, pkg_arch)
else: else:

View File

@ -18,6 +18,7 @@ import pungi.arch
from pungi.util import pkg_is_rpm, pkg_is_srpm, pkg_is_debug from pungi.util import pkg_is_rpm, pkg_is_srpm, pkg_is_debug
import pungi.phases.gather.method import pungi.phases.gather.method
from kobo.pkgset import SimpleRpmWrapper, RpmWrapper
class GatherMethodNodeps(pungi.phases.gather.method.GatherMethodBase): class GatherMethodNodeps(pungi.phases.gather.method.GatherMethodBase):
@ -43,10 +44,14 @@ class GatherMethodNodeps(pungi.phases.gather.method.GatherMethodBase):
pkg = global_pkgset[i] pkg = global_pkgset[i]
if not pkg_is_rpm(pkg): if not pkg_is_rpm(pkg):
continue continue
for pkg_name, pkg_arch in packages: for gathered_pkg, pkg_arch in packages:
if pkg.arch not in valid_arches: if pkg.arch not in valid_arches:
continue continue
if pkg.name != pkg_name: if (type(gathered_pkg) in [str, unicode]
and pkg.name != gathered_pkg):
continue
elif (type(gathered_pkg) in [SimpleRpmWrapper, RpmWrapper]
and pkg.nevra != gathered_pkg.nevra):
continue continue
if pkg_arch is not None and pkg.arch != pkg_arch: if pkg_arch is not None and pkg.arch != pkg_arch:
continue continue

View File

@ -63,7 +63,8 @@ class GatherSourceModule(pungi.phases.gather.source.GatherSourceBase):
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
rpm_obj.name not in mmd.filter.rpms): rpm_obj.name not in mmd.filter.rpms and
rpm_obj.nevra in mmd.artifacts.rpms):
packages.add((rpm_obj.name, None)) packages.add((rpm_obj.name, None))
added_rpms.setdefault(mmd_id, []) added_rpms.setdefault(mmd_id, [])
added_rpms[mmd_id].append(str(rpm_obj.nevra)) added_rpms[mmd_id].append(str(rpm_obj.nevra))