X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=tea;h=3783432420eae7f4e41de64b9e1e27c0e254bcd8;hb=9e5f0d9c81c0f0ea5fea6a40cce0ca388177f5cd;hp=b6ff8c6cb151a37cfb27094a9404719d679b11d3;hpb=c1c7681bf43c58dd5cf34d1c1814a75ae594688b;p=dak.git diff --git a/tea b/tea index b6ff8c6c..37834324 100755 --- a/tea +++ b/tea @@ -2,7 +2,7 @@ # Sanity check the database # Copyright (C) 2000, 2001 James Troup -# $Id: tea,v 1.13 2001-11-04 22:28:44 troup Exp $ +# $Id: tea,v 1.17 2002-04-16 14:47:19 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,28 +187,89 @@ 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 check_missing_tar_gz_in_dsc(): + count = 0; + + q = projectB.query("SELECT l.path, f.filename FROM files f, location l WHERE f.location = l.id AND f.filename ~ '.dsc$'") + for i in q.getresult(): + filename = os.path.abspath(i[0] + i[1]); + try: + # NB: don't enforce .dsc syntax + dsc = utils.parse_changes(filename, 0); + except: + utils.fubar("error parsing .dsc file '%s'." % (filename)); + dsc_files = utils.build_file_list(dsc, 1); + has_tar = 0; + for file in dsc_files.keys(): + m = utils.re_issource.match(file); + if not m: + utils.fubar("%s not recognised as source." % (file)); + type = m.group(3); + if type == "orig.tar.gz" or type == "tar.gz": + has_tar = 1; + if not has_tar: + utils.warn("%s has no .tar.gz in the .dsc file." % (file)); + count = count + 1; + + if count: + utils.warn("Found %s invalid .dsc files." % (count)); + ################################################################################ def main (): global Cnf, projectB, db_files, waste, excluded; - apt_pkg.init(); - - Cnf = apt_pkg.newConfiguration(); - apt_pkg.ReadConfigFileISC(Cnf,utils.which_conf_file()); + Cnf = utils.get_conf() apt_pkg.ParseCommandLine(Cnf,[],sys.argv); projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"])); 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(); + check_missing_tar_gz_in_dsc(); ####################################################################################### if __name__ == '__main__': - main() + main();