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] 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)