gather: Try getting srpm from the same repo as rpm

When the same package is contained in the main repo for depsolving as
well as in a lookaside repo, there was a chance that we would pick a
package from main repo, but corresponding source from lookaside.
This would cause a crash when trying to link the packages into the
compose.

A solution is to try to get source rpm from the same repo as the binary
package. Only when it's not available there we get some other one.

Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
Lubomír Sedlář 2018-01-25 13:52:55 +01:00
parent 2ae056e021
commit e8fa2a13b1
1 changed files with 11 additions and 1 deletions

View File

@ -535,6 +535,16 @@ class Gather(GatherBase):
return added
def _get_matching_srpm(self, pkg, sources):
"""
Get a source rpm from the same repo that pkg comes from. If there is no
such package, get the first one.
"""
for srpm in sources:
if pkg.repo == srpm.repo:
return srpm
return sources[0]
@Profiler("Gather.add_source_packages()")
def add_source_packages(self):
"""
@ -556,7 +566,7 @@ class Gather(GatherBase):
nvra = parse_nvra(pkg.sourcerpm)
source_pkgs = self.source_pkgs_cache.get(nvra["name"], nvra["version"], nvra["release"])
if source_pkgs:
source_pkg = list(source_pkgs)[0]
source_pkg = self._get_matching_srpm(pkg, source_pkgs)
self.sourcerpm_cache[pkg.sourcerpm] = source_pkg
self.finished_add_source_packages[pkg] = source_pkg