gather: Print specific Requires which pulls a package in

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ář <lsedlar@redhat.com>
This commit is contained in:
Lubomír Sedlář 2017-04-26 09:46:35 +02:00
parent 059449e140
commit ebe25a3717
1 changed files with 27 additions and 1 deletions

View File

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