Push most work of ts.addInstall() over to python
[platform/upstream/rpm.git] / python / rpm / transaction.py
index 6c64686..dcb28d4 100644 (file)
@@ -4,6 +4,9 @@ import _rpm
 
 # TODO: migrate relevant documentation from C-side
 class TransactionSet(_rpm.ts):
+    # FIXME: kludge for keeping refcounts on transaction element keys
+    _keyList = []
+
     def _wrapSetGet(self, attr, val):
         oval = getattr(self, attr)
         setattr(self, attr, val)
@@ -40,3 +43,12 @@ class TransactionSet(_rpm.ts):
             return None
         else:
             return tuple(keys)
+
+    def addInstall(self, header, key, how="u"):
+        if not how in ['u', 'i']:
+            raise ValueError, 'how argument must be "u" or "i"'
+        upgrade = (how == "u")
+
+        if not _rpm.ts.addInstall(self, header, key, upgrade):
+            raise _rpm.error, "adding package to transaction failed"
+        self._keyList.append(key)