Commits

htgoebel committed 79ecea8

Checking in intermediate version before dropping, since changing the
database is not possible in a filetrigger.

Comments (0)

Files changed (1)

python-compile.script

 
 import sys
 import rpm
-#rpm.addMacro("_dbPath","/usr/lib/rpmdb/i386-redhat-linux/redhat")
-transaction = rpm.TransactionSet()
-#transaction.setFlags(rpm.RPM_TRANS_FLAG_NOSCRIPTS)
-
-# We discuss transaction sets next
-#rpm.delMacro("_dbPath")
-
-def read_testlist():
-    import glob, itertools
-    for l in itertools.islice(glob.iglob('/usr/lib/python2.6/*.py'), 10):
-        yield '+', l
 
 def read_from_triggerlist():
     for l in sys.stdin.readlines():
         # action, filename
-        yield l[0], l[1:]
+        yield l[0], l[1:].rstrip('\n')
 
 def collect_headers(ts, filenames):
     for fn in filenames:
         for h in ts.dbMatch('basenames', fn):
             yield h
 
-for action, filename in read_testlist():
-    print action, filename
-    for h in collect_headers(transaction, [filename]):
+def list_packages(ts):
+    # :test:
+    for h in ts.dbMatch():
         print "%s-%s-%s" % (h['name'], h['version'], h['release'])
+        print h['filenames']
+
+# md5list, filelist, linklist, filesizes, mtimes, uids, gids, redvs, modes
+
+def main():
+    transaction = rpm.TransactionSet()
+    list_packages(transaction)
+    for action, filename in read_from_triggerlist():
+        print '-->', action, repr(filename)
+        for h in collect_headers(transaction, [filename]):
+            print "%s-%s-%s" % (h['name'], h['version'], h['release'])
+
+if __name__ == '__main__':
+    dbPath = None
+    if sys.argv[1] == '--test':
+        dbPath = sys.argv[2]
+        print "setting dbpath", dbPath
+        rpm.addMacro("_dbpath", dbPath)
+    main()
+    if dbPath:
+        rpm.delMacro("_dbpath")
 
 raise SystemExit()