pungi: Fix excluding SRPMs

Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
Daniel Mach 2016-10-17 11:58:23 +02:00 committed by Lubomír Sedlář
parent e6342ede18
commit 3e7f2dfa9d

View File

@ -471,10 +471,13 @@ class Pungi(PungiBase):
def expand_excluded_list(self): def expand_excluded_list(self):
excluded_list = [] excluded_list = []
multilib_excluded_list = [] multilib_excluded_list = []
source_excluded_list = []
for pattern in self.ksparser.handler.packages.excludedList: for pattern in self.ksparser.handler.packages.excludedList:
if pattern.endswith(".+"): if pattern.endswith(".+"):
multilib_excluded_list.append(pattern[:-2]) multilib_excluded_list.append(pattern[:-2])
elif pattern.endswith(".src"):
source_excluded_list.append(pattern[:-4])
else: else:
excluded_list.append(pattern) excluded_list.append(pattern)
@ -526,14 +529,35 @@ class Pungi(PungiBase):
% (pkg.name, pkg.arch, found)) % (pkg.name, pkg.arch, found))
self.excluded_packages.add(pkg) self.excluded_packages.add(pkg)
# source packages
exactmatched, matched, unmatched = yum.packages.parsePackages(
self.all_pkgs, source_excluded_list, casematch=1, pkgdict=self.pkg_refs.copy())
for i in sorted(unmatched):
self.logger.warning("Unmatched source exclude: %s.src" % i)
for pkg in exactmatched + matched:
if pkg.arch != "src":
continue
found = None
for pattern in source_excluded_list:
if fnmatch(pkg.name, pattern):
found = pattern
break
if found:
if pkg not in self.excluded_packages:
self.logger.info("Excluding %s.%s (pattern: %s.src)"
% (pkg.name, pkg.arch, found))
self.excluded_packages.add(pkg)
def excludePackages(self, pkg_sack): def excludePackages(self, pkg_sack):
"""exclude packages according to config file""" """exclude packages according to config file"""
if not pkg_sack: if not pkg_sack:
return pkg_sack return pkg_sack
for pkg in pkg_sack[:]: for pkg in pkg_sack[:]:
if pkg.arch == "src":
continue
if pkg in self.multilib_blacklist: if pkg in self.multilib_blacklist:
pkg_sack.remove(pkg) pkg_sack.remove(pkg)
continue continue
@ -961,6 +985,7 @@ class Pungi(PungiBase):
# ... but even "nosrc" packages are stored as "src" in repodata # ... but even "nosrc" packages are stored as "src" in repodata
srpm_po_list = self.ayum.pkgSack.searchNevra(name=name, ver=ver, rel=rel, arch="src") srpm_po_list = self.ayum.pkgSack.searchNevra(name=name, ver=ver, rel=rel, arch="src")
srpm_po_list = self.excludePackages(srpm_po_list)
if not srpm_po_list: if not srpm_po_list:
raise RuntimeError("Cannot find a source rpm for %s" % po.sourcerpm) raise RuntimeError("Cannot find a source rpm for %s" % po.sourcerpm)
srpm_po = srpm_po_list[0] srpm_po = srpm_po_list[0]