X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=cindy;h=420f92279d586d1f2547101b9d61c2989757b6aa;hb=a29673e49824a6c0838df50ab64ac08cf32852d8;hp=367e1e57fe668a566287253e2ab13883baffd069;hpb=6ada259d555e36a1546789c280edc3f944b7de7f;p=dak.git diff --git a/cindy b/cindy index 367e1e57..420f9227 100755 --- a/cindy +++ b/cindy @@ -1,8 +1,8 @@ #!/usr/bin/env python -# Output override files for apt-ftparchive and indices/ -# Copyright (C) 2000, 2001 James Troup -# $Id: cindy,v 1.4 2001-06-22 22:53:14 troup Exp $ +# Cruft checker for overrides +# Copyright (C) 2000, 2001, 2002 James Troup +# $Id: cindy,v 1.11 2003-01-02 18:10:02 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 @@ -20,12 +20,18 @@ ################################################################################ -# X-Listening-To: Sanitarium / Master of the Puppets - Metallica +###################################################################### +# NB: cindy is not a good idea with New Incoming as she doesn't take # +# into account accepted. You can minimize the impact of this by # +# running her immediately after kelly but that's still racy because # +# lisa doesn't lock with kelly. A better long term fix is the evil # +# plan for accepted to be in the DB. # +###################################################################### ################################################################################ -import pg, sys, string -import utils, db_access, natalie +import pg, sys; +import utils, db_access; import apt_pkg; ################################################################################ @@ -36,9 +42,19 @@ override = {} ################################################################################ +def usage (exit_code=0): + print """Usage: cindy +Check for cruft in overrides. + + -h, --help show this help and exit""" + + sys.exit(exit_code) + +################################################################################ + def process(suite, component, type): global override; - + suite_id = db_access.get_suite_id(suite); if suite_id == -1: utils.fubar("Suite '%s' not recognised." % (suite)); @@ -79,7 +95,7 @@ def process(suite, component, type): #% (package, suite_id, component_id, type_id)); # Then if source doesn't already have a copy, insert it into source q = projectB.query("SELECT package FROM override WHERE package = '%s' AND suite = %s AND component = %s AND type = %s" % (package, suite_id, component_id, dsc_type_id)); - if q.getresult() == []: + if not q.getresult(): #projectB.query("INSERT INTO override (package, suite, component, priority, section, type, maintainer) VALUES ('%s', %s, %s, %s, %s, %s, '%s')" % (package, suite_id, component_id, i[1], i[2], dsc_type_id, i[3])); print "(nop)" else: # dsc @@ -88,21 +104,24 @@ def process(suite, component, type): #projectB.query("DELETE FROM override WHERE package = '%s' AND suite = %s AND component = %s AND type = %s" #% (package, suite_id, component_id, type_id)); projectB.query("COMMIT WORK"); - + ################################################################################ def main (): global Cnf, projectB, override; - apt_pkg.init(); - - Cnf = apt_pkg.newConfiguration(); - apt_pkg.ReadConfigFileISC(Cnf,utils.which_conf_file()); - Arguments = [('D',"debug","Denise::Options::Debug", "IntVal"), - ('h',"help","Denise::Options::Help"), - ('V',"version","Denise::Options::Version")]; - apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv); + Cnf = utils.get_conf() + + Arguments = [('h',"help","Cindy::Options::Help")]; + for i in [ "help" ]: + if not Cnf.has_key("Cindy::Options::%s" % (i)): + Cnf["Cindy::Options::%s" % (i)] = ""; + apt_pkg.ParseCommandLine(Cnf, Arguments, sys.argv); + Options = Cnf.SubTree("Cindy::Options") + + if Options["Help"]: + usage(); projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"])); db_access.init(Cnf, projectB); @@ -112,11 +131,11 @@ def main (): for component in Cnf.SubTree("Component").List(): if component == "mixed": continue; # Ick - for type in Cnf.SubTree("OverrideType").List(): + for type in Cnf.ValueList("OverrideType"): print "Processing %s [%s - %s]..." % (suite, component, type); process(suite, component, type); -####################################################################################### +################################################################################ if __name__ == '__main__': main()