summaryrefslogtreecommitdiff
path: root/python/rpm/transaction.py
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2009-10-05 14:25:43 +0300
committerPanu Matilainen <pmatilai@redhat.com>2009-10-05 14:25:43 +0300
commitfab2debfe440d677dbd072c3cd73d2c99876e7a5 (patch)
tree7ca3544a1f67f47c25466dcfd72b02c0b6f6e3dc /python/rpm/transaction.py
parent776f5b56ca51c7c5495f84d5823e5e646206e5d4 (diff)
downloadlibrpm-tizen-fab2debfe440d677dbd072c3cd73d2c99876e7a5.tar.gz
librpm-tizen-fab2debfe440d677dbd072c3cd73d2c99876e7a5.tar.bz2
librpm-tizen-fab2debfe440d677dbd072c3cd73d2c99876e7a5.zip
Push ts.check() return tuple-o-doom generation over to python side
Diffstat (limited to 'python/rpm/transaction.py')
-rw-r--r--python/rpm/transaction.py38
1 files changed, 38 insertions, 0 deletions
diff --git a/python/rpm/transaction.py b/python/rpm/transaction.py
index 4d0454c23..c852b86b2 100644
--- a/python/rpm/transaction.py
+++ b/python/rpm/transaction.py
@@ -100,3 +100,41 @@ class TransactionSet(_rpm.ts):
res.append(item)
return res
+ def check(self, *args, **kwds):
+ _rpm.ts.check(self, *args, **kwds)
+
+ probs = self.problems()
+ if not probs:
+ return None
+
+ # compatibility: munge problem strings into dependency tuples of doom
+ res = []
+ for p in probs:
+ # is it anything we need to care about?
+ if p.type == _rpm.RPMPROB_CONFLICT:
+ sense = _rpm.RPMDEP_SENSE_CONFLICTS
+ elif p.type == _rpm.RPMPROB_REQUIRES:
+ sense = _rpm.RPMDEP_SENSE_REQUIRES
+ else:
+ continue
+
+ # strip arch, split to name, version, release
+ nevr = p.pkgNEVR.rsplit('.', 1)[0]
+ n, v, r = nevr.rsplit('-', 2)
+
+ # extract the dependency information
+ needs = p.altNEVR.split()[1:]
+ needname = needs[0]
+ needflags = _rpm.RPMSENSE_ANY
+ if len(needs) == 3:
+ needop = needs[1]
+ if needop.find('<') >= 0: needflags |= _rpm.RPMSENSE_LESS
+ if needop.find('=') >= 0: needflags |= _rpm.RPMSENSE_EQUAL
+ if needop.find('>') >= 0: needflags |= _rpm.RPMSENSE_GREATER
+ needver = needs[2]
+ else:
+ needver = ""
+
+ res.append(((n, v, r),(needname,needver),needflags,sense,p.key))
+
+ return res