X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=dak%2Fcontents.py;h=834cbccf0cc5027f99ec98433403fab8895392ee;hb=274fdac9a30c88bd6df70bd4e30b6a684775415a;hp=b94aa0de7ca7a99ba5d6f621aaba5b72336f450e;hpb=10c964315953c1da8a3f388c4fd9c11c94fa8af4;p=dak.git diff --git a/dak/contents.py b/dak/contents.py index b94aa0de..834cbccf 100755 --- a/dak/contents.py +++ b/dak/contents.py @@ -37,7 +37,6 @@ Create all the contents files import sys import os import logging -import math import gzip import threading import Queue @@ -56,8 +55,8 @@ COMMANDS generate generate Contents-$arch.gz files - bootstrap - scan the debs in the existing pool and load contents in the the database + bootstrap_bin + scan the debs in the existing pool and load contents into the bin_contents table cruft remove files/paths which are no longer referenced by a binary @@ -104,7 +103,7 @@ class GzippedContentWriter(object): def __init__(self, filename): """ - @ptype filename: string + @type filename: string @param filename: the name of the file to write to """ self.queue = Queue.Queue() @@ -231,6 +230,34 @@ class Contents(object): s.commit() + def bootstrap_bin(self): + """ + scan the existing debs in the pool to populate the bin_contents table + """ + pooldir = Config()[ 'Dir::Pool' ] + + s = DBConn().session() + + # for binary in s.query(DBBinary).all() ): + binary = s.query(DBBinary).first() + if binary: + filename = binary.poolfile.filename + # Check for existing contents + existingq = s.execute( "select 1 from bin_contents where binary_id=:id", {'id':binary.binary_id} ); + if existingq.fetchone(): + log.debug( "already imported: %s" % (filename)) + else: + # We don't have existing contents so import them + log.debug( "scanning: %s" % (filename) ) + + debfile = os.path.join(pooldir, filename) + if os.path.exists(debfile): + Binary(debfile, self.reject).scan_package(binary.binary_id, True) + else: + log.error("missing .deb: %s" % filename) + + + def bootstrap(self): """ scan the existing debs in the pool to populate the contents database tables @@ -321,7 +348,7 @@ def main(): ] commands = {'generate' : Contents.generate, - 'bootstrap' : Contents.bootstrap, + 'bootstrap_bin' : Contents.bootstrap_bin, 'cruft' : Contents.cruft, }