X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=dak%2Fcheck_archive.py;h=ba208dd7e795cb2497621485521d14647866de77;hb=0d765d5cbf58ca3d9d7621d9fc9e6cc6dc94f244;hp=52f0428040cd81c589fc8733a1a8fed0588f18ce;hpb=e2ae71066cbb134753d7bfceb16e87d0b76dfd6e;p=dak.git diff --git a/dak/check_archive.py b/dak/check_archive.py old mode 100755 new mode 100644 index 52f04280..ba208dd7 --- a/dak/check_archive.py +++ b/dak/check_archive.py @@ -26,7 +26,7 @@ ################################################################################ -import commands, os, pg, stat, string, sys, time +import commands, os, pg, stat, sys, time import apt_pkg, apt_inst import daklib.database import daklib.utils @@ -80,7 +80,7 @@ def process_dir (unused, dirname, filenames): filename = filename.replace('potato-proposed-updates', 'proposed-updates') if os.path.isfile(filename) and not os.path.islink(filename) and not db_files.has_key(filename) and not excluded.has_key(filename): waste += os.stat(filename)[stat.ST_SIZE] - print filename + print "%s" % (filename) ################################################################################ @@ -88,15 +88,20 @@ def check_files(): global db_files print "Building list of database files..." - q = projectB.query("SELECT l.path, f.filename FROM files f, location l WHERE f.location = l.id") + q = projectB.query("SELECT l.path, f.filename, f.last_used FROM files f, location l WHERE f.location = l.id ORDER BY l.path, f.filename") ql = q.getresult() + print "Missing files:" db_files.clear() for i in ql: - filename = os.path.abspath(i[0] + i[1]) + filename = os.path.abspath(i[0] + i[1]) db_files[filename] = "" if os.access(filename, os.R_OK) == 0: - daklib.utils.warn("'%s' doesn't exist." % (filename)) + if i[2]: + print "(last used: %s) %s" % (i[2], filename) + else: + print "%s" % (filename) + filename = Cnf["Dir::Override"]+'override.unreferenced' if os.path.exists(filename): @@ -105,7 +110,7 @@ def check_files(): filename = filename[:-1] excluded[filename] = "" - print "Checking against existent files..." + print "Existent files not in db:" os.path.walk(Cnf["Dir::Root"]+'pool/', process_dir, None) @@ -196,7 +201,7 @@ def check_md5sums(): print "Checking file md5sums & sizes..." for i in ql: - filename = os.path.abspath(i[0] + i[1]) + filename = os.path.abspath(i[0] + i[1]) db_md5sum = i[2] db_size = int(i[3]) try: @@ -233,7 +238,7 @@ def check_timestamps(): db_files.clear() count = 0 for i in ql: - filename = os.path.abspath(i[0] + i[1]) + filename = os.path.abspath(i[0] + i[1]) if os.access(filename, os.R_OK): file = daklib.utils.open_file(filename) current_file = filename @@ -345,7 +350,7 @@ def check_indices_files_exist(): for suite in [ "stable", "testing", "unstable" ]: for component in Cnf.ValueList("Suite::%s::Components" % (suite)): architectures = Cnf.ValueList("Suite::%s::Architectures" % (suite)) - for arch in map(string.lower, architectures): + for arch in [ i.lower() for i in architectures ]: if arch == "source": validate_sources(suite, component) elif arch == "all": @@ -370,7 +375,7 @@ def check_files_not_symlinks(): # q = projectB.query("BEGIN WORK") for i in q_files: - filename = os.path.normpath(i[0] + i[1]) + filename = os.path.normpath(i[0] + i[1]) # file_id = i[2] if os.access(filename, os.R_OK) == 0: daklib.utils.warn("%s: doesn't exist." % (filename)) @@ -426,14 +431,14 @@ def main (): Cnf = daklib.utils.get_conf() Arguments = [('h',"help","Check-Archive::Options::Help")] for i in [ "help" ]: - if not Cnf.has_key("Check-Archive::Options::%s" % (i)): - Cnf["Check-Archive::Options::%s" % (i)] = "" + if not Cnf.has_key("Check-Archive::Options::%s" % (i)): + Cnf["Check-Archive::Options::%s" % (i)] = "" args = apt_pkg.ParseCommandLine(Cnf, Arguments, sys.argv) Options = Cnf.SubTree("Check-Archive::Options") if Options["Help"]: - usage() + usage() if len(args) < 1: daklib.utils.warn("dak check-archive requires at least one argument")