X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=tea;h=1d4c62df85d56023959e368fd694287821b28f4f;hb=17e9953dd661c4bc6da7c3c7072fb364c2f49bf4;hp=47107a37aa9efe150a5e77ab80e815b10506594a;hpb=2f5e692bfbbb6f8146f50d944f7fcc169a95a0a3;p=dak.git diff --git a/tea b/tea index 47107a37..1d4c62df 100755 --- a/tea +++ b/tea @@ -2,7 +2,7 @@ # Sanity check the database # Copyright (C) 2000, 2001 James Troup -# $Id: tea,v 1.14 2001-11-18 19:57:58 rmurray Exp $ +# $Id: tea,v 1.16 2002-02-12 23:14:58 troup Exp $ # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -25,9 +25,9 @@ ################################################################################ -import pg, sys, os, string, stat +import pg, sys, os, string, stat, time import utils, db_access -import apt_pkg; +import apt_pkg, apt_inst; ################################################################################ @@ -36,8 +36,13 @@ projectB = None; db_files = {}; waste = 0.0; excluded = {}; +current_file = None; +future_files = {}; +current_time = time.time(); -def process_dir (arg, dirname, filenames): +################################################################################ + +def process_dir (unused, dirname, filenames): global waste, db_files, excluded; if string.find(dirname, '/disks-') != -1 or string.find(dirname, 'upgrade-') != -1: @@ -51,6 +56,7 @@ def process_dir (arg, dirname, filenames): 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 = waste + os.stat(filename)[stat.ST_SIZE]; print filename + ################################################################################ def check_files(): @@ -61,7 +67,7 @@ def check_files(): q = projectB.query("SELECT l.path, f.filename FROM files f, location l WHERE f.location = l.id") ql = q.getresult(); - db_files = {}; + db_files.clear(); for i in ql: filename = os.path.abspath(i[0] + i[1]); db_files[filename] = ""; @@ -181,6 +187,39 @@ def check_md5sums(): print "Done." +################################################################################ +# +# Check all files for timestamps in the future; common from hardware +# (e.g. alpha) which have far-future dates as their default dates. + + + +def Ent(Kind,Name,Link,Mode,UID,GID,Size,MTime,Major,Minor): + global future_files; + + if MTime > current_time: + future_files[current_file] = MTime; + print "%s: %s '%s','%s',%u,%u,%u,%u,%u,%u,%u" % (current_file, Kind,Name,Link,Mode,UID,GID,Size, MTime, Major, Minor); + +def check_timestamps(): + global current_file; + + q = projectB.query("SELECT l.path, f.filename FROM files f, location l WHERE f.location = l.id AND f.filename ~ '.deb$'") + ql = q.getresult(); + db_files.clear(); + count = 0; + for i in ql: + filename = os.path.abspath(i[0] + i[1]); + if os.access(filename, os.R_OK): + file = utils.open_file(filename); + current_file = filename; + sys.stderr.write("Processing %s.\n" % (filename)); + apt_inst.debExtract(file,Ent,"control.tar.gz"); + file.seek(0); + apt_inst.debExtract(file,Ent,"data.tar.gz"); + count = count + 1; + print "Checked %d files (out of %d)." % (count, len(db_files.keys())); + ################################################################################ def main (): @@ -193,13 +232,14 @@ def main (): db_access.init(Cnf, projectB); #check_md5sums(); - check_source_in_one_dir(); + #check_source_in_one_dir(); #check_override(); #check_dscs(); #check_files(); + check_timestamps(); ####################################################################################### if __name__ == '__main__': - main() + main();