diff options
author | Florian Weimer <fw@deneb.enyo.de> | 2011-04-24 15:27:54 +0000 |
---|---|---|
committer | Florian Weimer <fw@deneb.enyo.de> | 2011-04-24 15:27:54 +0000 |
commit | e5403c82df5c7ba635e155532524c37554a8349c (patch) | |
tree | ff5c6af36208160bd97cd73a38b91131e2bb69a2 /bin/list-queue | |
parent | 73ed815672f9d387386c044e7800eeb65afd9aee (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-x | bin/list-queue | 58 |
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() |