X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=dak%2Fcontents.py;h=58c3aa6b668d364c23177b18b0e1b2bb9dc198ef;hb=bd1cf4c84804368e21a9695761f18396c4df3236;hp=9ac99951400e675aade746683566ebeaeaf73ce8;hpb=1c35448b880358d020e81339657e3435fdda9434;p=dak.git diff --git a/dak/contents.py b/dak/contents.py index 9ac99951..58c3aa6b 100755 --- a/dak/contents.py +++ b/dak/contents.py @@ -37,9 +37,9 @@ Create all the contents files import sys import os import logging -import math import gzip import threading +import traceback import Queue import apt_pkg from daklib import utils @@ -56,8 +56,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 @@ -231,6 +231,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 +349,7 @@ def main(): ] commands = {'generate' : Contents.generate, - 'bootstrap' : Contents.bootstrap, + 'bootstrap_bin' : Contents.bootstrap_bin, 'cruft' : Contents.cruft, }