summaryrefslogtreecommitdiffstats
path: root/bin/list-queue
diff options
context:
space:
mode:
authorFlorian Weimer <fw@deneb.enyo.de>2011-04-24 15:27:54 +0000
committerFlorian Weimer <fw@deneb.enyo.de>2011-04-24 15:27:54 +0000
commitc840a7ae8d26e21bf67db23b250aff805807b3f0 (patch)
tree4ec10020114adca3fb91d8917940aed330276d48 /bin/list-queue
parentd8a5b9c736033cdb429a0c949319647f2cf7db07 (diff)
bin/list-queue: annotate packages with their distributions
git-svn-id: svn+ssh://svn.debian.org/svn/secure-testing@16580 e39458fd-73e7-0310-bf30-c45bca0a0e42
Diffstat (limited to 'bin/list-queue')
-rwxr-xr-xbin/list-queue58
1 files changed, 39 insertions, 19 deletions
diff --git a/bin/list-queue b/bin/list-queue
index a0343c8224..c693ae3c9d 100755
--- a/bin/list-queue
+++ b/bin/list-queue
@@ -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 @@ def expire(db, ondisk, indb, table):
for (path,) in need_delete:
del indb[path]
-def updatepackages(db, ondisk):
- """Updates the package table from the file system.
+def stripstat(data):
+ "Removes the stat pair from the values in data."
+ for (key, value) in data.items():
+ data[key] = value[2:]
- Returns the current list of package objects, in arbitary order.
- """
+def updatepackages(db, ondisk):
+ "Updates the package table from the file system."
indb = readpackages(db)
expire(db, ondisk, indb, "package")
@@ -146,15 +148,11 @@ def updatepackages(db, ondisk):
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 @@ def updatechanges(db, ondisk):
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()

© 2014-2024 Faster IT GmbH | imprint | privacy policy