[Secure-testing-commits] r16580 - bin

Florian Weimer fw at alioth.debian.org
Sun Apr 24 15:27:58 UTC 2011


Author: fw
Date: 2011-04-24 15:27:54 +0000 (Sun, 24 Apr 2011)
New Revision: 16580

Modified:
   bin/list-queue
Log:
bin/list-queue: annotate packages with their distributions


Modified: bin/list-queue
===================================================================
--- bin/list-queue	2011-04-24 15:09:25 UTC (rev 16579)
+++ bin/list-queue	2011-04-24 15:27:54 UTC (rev 16580)
@@ -20,8 +20,8 @@
 # unprocessed dump of the contents of the embargoed and unembargoed
 # queues.
 #
-# The script reads .deb files.  A caching database is written to
-# ~/.cache.
+# The script reads .deb and .changes files.  A caching database is
+# written to ~/.cache.
 
 
 ######################################################################
@@ -126,11 +126,13 @@
     for (path,) in need_delete:
         del indb[path]
 
+def stripstat(data):
+    "Removes the stat pair from the values in data."
+    for (key, value) in data.items():
+        data[key] = value[2:]
+
 def updatepackages(db, ondisk):
-    """Updates the package table from the file system.
-
-    Returns the current list of package objects, in arbitary order.
-    """
+    "Updates the package table from the file system."
     indb = readpackages(db)
     expire(db, ondisk, indb, "package")
     
@@ -146,15 +148,11 @@
     db.executemany("INSERT INTO package VALUES (?, ?, ?, ?, ?, ?, ?, ?)",
                    do_update())
 
-    # Return a list of BinaryPackage objects
-    return [item[2] for item in indb.values()]
+    stripstat(indb)
+    return indb
 
 def updatechanges(db, ondisk):
-    """Updates the package table from the file system.
-
-    Returns the current list of changes objects, in arbitary order.
-    Change objects are pairs (DISTRIBUTION, SET-OF-DEBS)
-    """
+    "Updates the changes table from the file system."
     indb = readchanges(db)
     expire(db, ondisk, indb, "changes")
 
@@ -173,20 +171,42 @@
             yield (path,) + stat + (dist, " ".join(sorted(debs)),)
     db.executemany("INSERT INTO changes VALUES (?, ?, ?, ?, ?)", do_update())
 
-    return [tuple(row[2:]) for row in indb.values()]
+    stripstat(indb)
+    return indb
 
+def distdict(changes):
+    "Computes a dict from .deb files to sets of distributions"
+    result = {}
+    for path, (dist, debs) in changes.items():
+        base = os.path.dirname(path)
+        distset = set((dist,))
+        for deb in debs:
+            name = os.path.join(base, deb)
+            if name in result:
+                result[name].add(dist)
+            else:
+                result[name] = set(distset)
+    return result
+
+def pkgwithdist(debs, dists):
+    """Merge packages and distribution information.
+
+    Returns a list of tuples (PACKAGE-NAME, VERSION, ARCHITECTURE,
+    SOURCE-NAME, SOURCE-VERSION, TUPLE-OF-DISTRIBUTIONS).
+    """
+    return [pkg.astuple() + (sorted(dists.get(path, ())),)
+            for (path, (pkg,)) in debs.items()]
+
 def main():
     db = createdb()
     debs, changes = readdirs()
     debs = updatepackages(db, debs)
     changes = updatechanges(db, changes)
-    for c in changes:
-        print repr(c)
+    dists = distdict(changes)
+    db.commit()
     result = {
         "version" : 1,
-        "binary" : [pkg.astuple() for pkg in debs],
-        "changes" : [[dist, sorted(debs)] for dist, debs in changes],
+        "binary" : pkgwithdist(debs, dists),
         }
-    db.commit()
     print json.dumps(result)
 main()




More information about the Secure-testing-commits mailing list