Merge #608 Add exact Requires to depsolving log

This commit is contained in:
Dennis Gilmore 2017-04-27 15:30:54 +00:00
commit b396e8273f
2 changed files with 42 additions and 11 deletions

View File

@ -99,6 +99,31 @@ class MyConfigParser(ConfigParser.ConfigParser):
return optionstr return optionstr
FLAGS = {
'EQ': '=',
'GE': '>=',
'LE': '<=',
'GT': '>',
'LT': '<',
}
class Req(object):
"""A wrapper for a tuple representing a Requires tag.
Only useful for formatting the value into a human readable string.
"""
def __init__(self, req):
self.r, self.f, self.v = req
def __str__(self):
if self.f and self.v:
flag = FLAGS.get(self.f, '??')
version = '%s:%s-%s' % self.v
return '%s %s %s' % (self.r, flag, version)
return self.r
class PungiBase(object): class PungiBase(object):
"""The base Pungi class. Set up config items and logging here""" """The base Pungi class. Set up config items and logging here"""
@ -636,7 +661,8 @@ class Pungi(PungiBase):
for dep in deps: for dep in deps:
if dep not in added: if dep not in added:
msg = 'Added %s.%s (repo: %s) for %s.%s' % (dep.name, dep.arch, dep.repoid, po.name, po.arch) msg = 'Added %s.%s (repo: %s) for %s.%s (Requires: %s)' % (
dep.name, dep.arch, dep.repoid, po.name, po.arch, Req(req))
self.add_package(dep, msg) self.add_package(dep, msg)
added.add(dep) added.add(dep)

View File

@ -259,7 +259,7 @@ class Gather(GatherBase):
return [i for i in multilib_pkgs if i.sourcerpm == match.sourcerpm] return [i for i in multilib_pkgs if i.sourcerpm == match.sourcerpm]
return [match] return [match]
def _add_packages(self, packages, pulled_by=None, reason=None): def _add_packages(self, packages, pulled_by=None, req=None, reason=None):
added = set() added = set()
for i in packages: for i in packages:
assert i is not None assert i is not None
@ -268,6 +268,8 @@ class Gather(GatherBase):
pb = "" pb = ""
if pulled_by: if pulled_by:
pb = " (pulled by %s, repo: %s)" % (pulled_by, pulled_by.repo.id) pb = " (pulled by %s, repo: %s)" % (pulled_by, pulled_by.repo.id)
if req:
pb += " (Requires: %s)" % req
if reason: if reason:
pb += " (%s)" % reason pb += " (%s)" % reason
self.logger.debug("Added package %s%s" % (i, pb)) self.logger.debug("Added package %s%s" % (i, pb))
@ -279,8 +281,11 @@ class Gather(GatherBase):
self.result_binary_packages.update(added) self.result_binary_packages.update(added)
def _get_package_deps(self, pkg): def _get_package_deps(self, pkg):
""" """Return all direct (1st level) deps for a package.
Return all direct (1st level) deps for a package.
The return value is a set of tuples (pkg, reldep). Each package is
tagged with the particular reldep that pulled it in. Requires_pre and
_post are not distinguished.
""" """
assert pkg is not None assert pkg is not None
result = set() result = set()
@ -295,7 +300,7 @@ class Gather(GatherBase):
for req in requires: for req in requires:
deps = self.finished_get_package_deps_reqs.setdefault(str(req), set()) deps = self.finished_get_package_deps_reqs.setdefault(str(req), set())
if deps: if deps:
result.update(deps) result.update((dep, req) for dep in deps)
continue continue
# TODO: need query also debuginfo # TODO: need query also debuginfo
@ -303,7 +308,7 @@ class Gather(GatherBase):
if deps: if deps:
deps = self._get_best_package(deps, req=req) deps = self._get_best_package(deps, req=req)
self.finished_get_package_deps_reqs[str(req)].update(deps) self.finished_get_package_deps_reqs[str(req)].update(deps)
result.update(deps) result.update((dep, req) for dep in deps)
return result return result
@ -434,9 +439,9 @@ class Gather(GatherBase):
if pkg not in self.finished_add_binary_package_deps: if pkg not in self.finished_add_binary_package_deps:
deps = self._get_package_deps(pkg) deps = self._get_package_deps(pkg)
for i in deps: for i, req in deps:
if i not in self.result_binary_packages: if i not in self.result_binary_packages:
self._add_packages([i], pulled_by=pkg, reason='binary-dep') self._add_packages([i], pulled_by=pkg, req=req, reason='binary-dep')
added.add(i) added.add(i)
self.finished_add_binary_package_deps[pkg] = deps self.finished_add_binary_package_deps[pkg] = deps
@ -492,10 +497,10 @@ class Gather(GatherBase):
deps = self.finished_add_source_package_deps[pkg] deps = self.finished_add_source_package_deps[pkg]
except KeyError: except KeyError:
deps = self._get_package_deps(pkg) deps = self._get_package_deps(pkg)
self.finished_add_source_package_deps[pkg] = deps self.finished_add_source_package_deps[pkg] = set(dep for (dep, req) in deps)
for i in deps: for i, req in deps:
if i not in self.result_binary_packages: if i not in self.result_binary_packages:
self._add_packages([i], pulled_by=pkg, reason='source-dep') self._add_packages([i], pulled_by=pkg, req=req, reason='source-dep')
added.add(i) added.add(i)
self._set_flag(pkg, PkgFlag.self_hosting) self._set_flag(pkg, PkgFlag.self_hosting)