From ebe25a37177a726f8e9be9a66eaf3f8da94a4cb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubom=C3=ADr=20Sedl=C3=A1=C5=99?= Date: Wed, 26 Apr 2017 09:46:35 +0200 Subject: [PATCH 1/2] gather: Print specific Requires which pulls a package in MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When dependencies are pulled in, it's useful to know not only the package that requires them, but also the specific requires. This patch only implement this for the YUM version. Signed-off-by: Lubomír Sedlář --- pungi/gather.py | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/pungi/gather.py b/pungi/gather.py index 20cc33d3..46f78732 100644 --- a/pungi/gather.py +++ b/pungi/gather.py @@ -99,6 +99,31 @@ class MyConfigParser(ConfigParser.ConfigParser): 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): """The base Pungi class. Set up config items and logging here""" @@ -636,7 +661,8 @@ class Pungi(PungiBase): for dep in deps: 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) added.add(dep) From 29c339d659b0f2863082325efc00b1c3e36ea0bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubom=C3=ADr=20Sedl=C3=A1=C5=99?= Date: Wed, 26 Apr 2017 10:04:26 +0200 Subject: [PATCH 2/2] gather-dnf: Log exact Requires pulling a package in MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is useful for debugging. Signed-off-by: Lubomír Sedlář --- pungi/gather_dnf.py | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/pungi/gather_dnf.py b/pungi/gather_dnf.py index fb11b636..dbf5491e 100644 --- a/pungi/gather_dnf.py +++ b/pungi/gather_dnf.py @@ -259,7 +259,7 @@ class Gather(GatherBase): return [i for i in multilib_pkgs if i.sourcerpm == match.sourcerpm] 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() for i in packages: assert i is not None @@ -268,6 +268,8 @@ class Gather(GatherBase): pb = "" if pulled_by: pb = " (pulled by %s, repo: %s)" % (pulled_by, pulled_by.repo.id) + if req: + pb += " (Requires: %s)" % req if reason: pb += " (%s)" % reason self.logger.debug("Added package %s%s" % (i, pb)) @@ -279,8 +281,11 @@ class Gather(GatherBase): self.result_binary_packages.update(added) 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 result = set() @@ -295,7 +300,7 @@ class Gather(GatherBase): for req in requires: deps = self.finished_get_package_deps_reqs.setdefault(str(req), set()) if deps: - result.update(deps) + result.update((dep, req) for dep in deps) continue # TODO: need query also debuginfo @@ -303,7 +308,7 @@ class Gather(GatherBase): if deps: deps = self._get_best_package(deps, req=req) self.finished_get_package_deps_reqs[str(req)].update(deps) - result.update(deps) + result.update((dep, req) for dep in deps) return result @@ -434,9 +439,9 @@ class Gather(GatherBase): if pkg not in self.finished_add_binary_package_deps: deps = self._get_package_deps(pkg) - for i in deps: + for i, req in deps: 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) self.finished_add_binary_package_deps[pkg] = deps @@ -492,10 +497,10 @@ class Gather(GatherBase): deps = self.finished_add_source_package_deps[pkg] except KeyError: deps = self._get_package_deps(pkg) - self.finished_add_source_package_deps[pkg] = deps - for i in deps: + self.finished_add_source_package_deps[pkg] = set(dep for (dep, req) in deps) + for i, req in deps: 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) self._set_flag(pkg, PkgFlag.self_hosting)