From: James Troup Date: Thu, 27 Sep 2001 01:23:41 +0000 (+0000) Subject: options cleanup X-Git-Url: https://git.decadent.org.uk/gitweb/?a=commitdiff_plain;h=a092f0aa8e82394e25a16da9e87263ee26b8de0e;p=dak.git options cleanup --- diff --git a/andrea b/andrea index 351c9374..b678d9de 100755 --- a/andrea +++ b/andrea @@ -2,7 +2,7 @@ # Check for fixable discrepancies between stable and unstable # Copyright (C) 2000, 2001 James Troup -# $Id: andrea,v 1.3 2001-03-20 00:28:11 troup Exp $ +# $Id: andrea,v 1.4 2001-09-27 01:23:41 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 @@ -36,15 +36,11 @@ def main (): global Cnf, projectB; apt_pkg.init(); - + Cnf = apt_pkg.newConfiguration(); apt_pkg.ReadConfigFileISC(Cnf,utils.which_conf_file()); - Arguments = [('D',"debug","Catherine::Options::Debug", "IntVal"), - ('h',"help","Catherine::Options::Help"), - ('V',"version","Catherine::Options::Version")] - - apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv); + apt_pkg.ParseCommandLine(Cnf,[],sys.argv); projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"])); db_access.init(Cnf, projectB); @@ -73,12 +69,12 @@ SELECT b_src.package, b_src.version, a.arch_string FROM binaries b_src, bin_associations ba, override o, architecture a WHERE ba.bin = b_src.id AND ba.suite = %s AND b_src.architecture = %s AND a.id = b_src.architecture AND o.package = b_src.package - AND o.suite = %s AND o.type != %s AND NOT EXISTS - (SELECT b_dst.id FROM bin_associations ba2, binaries b_dst - WHERE ba2.bin = b_dst.id AND b_dst.package = b_src.package - AND (b_dst.architecture = %s OR b_dst.architecture = %s) - AND ba2.suite = %s AND EXISTS - (SELECT b2.id FROM bin_associations ba3, binaries b2 + AND o.suite = %s AND o.type != %s AND NOT EXISTS + (SELECT b_dst.id FROM bin_associations ba2, binaries b_dst + WHERE ba2.bin = b_dst.id AND b_dst.package = b_src.package + AND (b_dst.architecture = %s OR b_dst.architecture = %s) + AND ba2.suite = %s AND EXISTS + (SELECT b2.id FROM bin_associations ba3, binaries b2 WHERE ba3.bin = b2.id AND ba3.suite = %s AND b2.package = b_dst.package)) ORDER BY b_src.package;""" % (src_suite_id, arch_id, dst_suite_id, dsc_type_id, arch_id, arch_all_id, dst_suite_id, dst_suite_id)); diff --git a/charisma b/charisma index 2e801dc7..63d9a918 100755 --- a/charisma +++ b/charisma @@ -2,7 +2,7 @@ # Generate Maintainers file used by e.g. the Debian Bug Tracking System # Copyright (C) 2000, 2001 James Troup -# $Id: charisma,v 1.10 2001-09-26 03:47:15 troup Exp $ +# $Id: charisma,v 1.11 2001-09-27 01:23:41 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 @@ -39,9 +39,12 @@ packages = {} fixed_maintainer_cache = {} ################################################################################ -def usage (exit_code): + +def usage (exit_code=0): print """Usage: charisma [OPTION] EXTRA_FILE[...] Generate an index of packages <=> Maintainers. + + -h, --help show this help and exit """ sys.exit(exit_code) @@ -78,9 +81,14 @@ def main(): Cnf = apt_pkg.newConfiguration(); apt_pkg.ReadConfigFileISC(Cnf,utils.which_conf_file()); - extra_files = apt_pkg.ParseCommandLine(Cnf,[],sys.argv); + Arguments = [('h',"help","Charisma::Options::Help")]; + Cnf["Charisma::Options::Help"] = ""; + extra_files = apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv); + Options = Cnf.SubTree("Charisma::Options"); + + if Options["Help"]: + usage(); - #projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"]), None, None, Cnf["DB::ROUser"]); projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"])); db_access.init(Cnf, projectB); diff --git a/julia b/julia index 0a4d2fdd..6d5ff374 100755 --- a/julia +++ b/julia @@ -2,7 +2,7 @@ # Sync PostgreSQL with (LDAP-generated) passwd file # Copyright (C) 2001 James Troup -# $Id: julia,v 1.1 2001-09-13 23:55:51 troup Exp $ +# $Id: julia,v 1.2 2001-09-27 01:23:41 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 @@ -18,6 +18,8 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +################################################################################ + # ARRRGGGHHH # what's wrong with me!?!?!? # i was just nice to some mormon doorknockers!!! @@ -38,12 +40,13 @@ Cnf = None; projectB = None; ################################################################################ -def usage (exit_code): +def usage (exit_code=0): print """Usage: julia [OPTION]... PASSWD_FILE -Sync postgres' pg_shadow with PASSWD_FILE. +Sync PostgreSQL's pg_user with PASSWD_FILE. - -v, --verbose explain what is being done - -h, --help display this help and exit""" + -q, --quiet be quiet about what is being done + -v, --verbose explain what is being done + -h, --help show this help and exit""" sys.exit(exit_code) ################################################################################ @@ -58,15 +61,15 @@ def main (): Arguments = [('q',"quiet","Julia::Options::Quiet"), ('v',"verbose","Julia::Options::Verbose"), - ('D',"debug","Julia::Options::Debug", "IntVal"), - ('h',"help","Julia::Options::Help"), - ('V',"version","Julia::Options::Version")]; + ('h',"help","Julia::Options::Help")]; + for i in ["quiet", "verbose", "help" ]: + Cnf["Julia::Options::%s" % (i)] = ""; arguments = apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv); Options = Cnf.SubTree("Julia::Options") if Options["Help"]: - usage(0); + usage(); if arguments == []: utils.warn("julia needs the name of the passwd file to sync with as an argument."); usage(1); diff --git a/madison b/madison index 1ad72e05..7496dd68 100755 --- a/madison +++ b/madison @@ -2,7 +2,7 @@ # Display information about package(s) (suite, version, etc.) # Copyright (C) 2000, 2001 James Troup -# $Id: madison,v 1.10 2001-09-13 23:57:17 troup Exp $ +# $Id: madison,v 1.11 2001-09-27 01:23:41 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 @@ -48,12 +48,13 @@ def arch_compare (a, b): ################################################################################ -def usage (exit_code): +def usage (exit_code=0): print """Usage: madison [OPTION] PACKAGE[...] Display information about PACKAGE(s). - -a, --architecture=ARCH only show information for this architecture - -s, --suite=SUITE only show information for this suite + -a, --architecture=ARCH only show information for this architecture + -s, --suite=SUITE only show information for this suite + -h, --help show this help and exit Both ARCH and SUITE can be space seperated lists, e.g. --architecture=\"m68k i386\"""" @@ -70,17 +71,16 @@ def main (): apt_pkg.ReadConfigFileISC(Cnf,utils.which_conf_file()); Arguments = [('a',"architecture","Madison::Options::Architecture", "HasArg"), - ('m',"maintainer","Madison::Options::Architecture"), ('s',"suite","Madison::Options::Suite", "HasArg"), - ('D',"debug","Madison::Options::Debug", "IntVal"), - ('h',"help","Madison::Options::Help"), - ('V',"version","Madison::Options::Version")]; + ('h',"help","Madison::Options::Help")]; + for i in ["architecture", "suite", "help" ]: + Cnf["Madison::Options::%s" % (i)] = ""; packages = apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv); Options = Cnf.SubTree("Madison::Options") if Options["Help"]: - usage(0); + usage(); if packages == []: utils.fubar("need at least one package name as an argument."); diff --git a/melanie b/melanie index 3dfae76d..b412a540 100755 --- a/melanie +++ b/melanie @@ -1,8 +1,8 @@ #!/usr/bin/env python -# General purpose archive tool for ftpmaster +# General purpose package removal tool for ftpmaster # Copyright (C) 2000, 2001 James Troup -# $Id: melanie,v 1.16 2001-09-26 03:15:16 troup Exp $ +# $Id: melanie,v 1.17 2001-09-27 01:23:41 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 @@ -37,10 +37,10 @@ projectB = None; ################################################################################ -def usage (exit_code): - print """Usage: melanie [OPTIONS] package[...] - -D, --debug=VALUE turn on debugging - -h, --help show this help and exit +def usage (exit_code=0): + print """Usage: melanie [OPTIONS] PACKAGE[...] +Remove PACKAGE(s) from suite(s). + -a, --architecture=ARCH only act on this architecture -b, --binary remove binaries only -c, --component=COMPONENT act on this component @@ -50,7 +50,12 @@ def usage (exit_code): -n, --no-action don't do anything -p, --partial don't affect override files -s, --suite=SUITE act on this suite - -S, --source-only remove source only""" + -S, --source-only remove source only + -h, --help show this help and exit + +ARCH, BUG#, COMPONENT and SUITE can be space seperated lists, e.g. + --architecture=\"m68k i386\"""" + sys.exit(exit_code) ################################################################################ @@ -75,9 +80,7 @@ def main (): Cnf = apt_pkg.newConfiguration(); apt_pkg.ReadConfigFileISC(Cnf,utils.which_conf_file()); - Arguments = [('D',"debug","Melanie::Options::Debug", "IntVal"), - ('h',"help","Melanie::Options::Help"), - ('V',"version","Melanie::Options::Version"), + Arguments = [('h',"help","Melanie::Options::Help"), ('a',"architecture","Melanie::Options::Architecture", "HasArg"), ('b',"binary", "Melanie::Options::Binary-Only"), ('c',"component", "Melanie::Options::Component", "HasArg"), @@ -90,11 +93,15 @@ def main (): ('S',"source-only", "Melanie::Options::Source-Only"), ]; + for i in ["help", "architecture", "binary", "component", "carbon-copy", "done", "reason", "no-action", "partial", "source-only" ]: + Cnf["Melanie::Options::%s" % (i)] = ""; + Cnf["Melanie::Options::Suite"] = "unstable"; + arguments = apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv); Options = Cnf.SubTree("Melanie::Options") if Options["Help"]: - usage(0) + usage(); projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"])); db_access.init(Cnf, projectB); @@ -379,7 +386,7 @@ def main (): else: bcc = "Bcc: " + bcc; Subst["__BCC__"] = bcc[:-2]; - Subst["__CC__"] = "X-Melanie: $Revision: 1.16 $\n" + carbon_copy[:-1]; + Subst["__CC__"] = "X-Melanie: $Revision: 1.17 $\n" + carbon_copy[:-1]; Subst["__SUITE_LIST__"] = suites_list; Subst["__SUMMARY__"] = summary; Subst["__ADMIN_ADDRESS__"] = Cnf["Dinstall::MyAdminAddress"]; diff --git a/natalie.py b/natalie.py index b37378ce..d5a476d5 100755 --- a/natalie.py +++ b/natalie.py @@ -2,7 +2,7 @@ # Manipulate override files # Copyright (C) 2000, 2001 James Troup -# $Id: natalie.py,v 1.10 2001-09-17 11:18:37 troup Exp $ +# $Id: natalie.py,v 1.11 2001-09-27 01:23:41 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 @@ -32,11 +32,9 @@ Logger = None; ################################################################################ -def usage (exit_code): +def usage (exit_code=0): print """Usage: natalie.py [OPTIONS] - -D, --debug=VALUE debug -h, --help this help - -V, --version retrieve version -c, --component=CMPT list/set overrides by component (contrib,*main,non-free) -s, --suite=SUITE list/set overrides by suite @@ -211,18 +209,24 @@ def main (): Cnf = apt_pkg.newConfiguration(); apt_pkg.ReadConfigFileISC(Cnf,utils.which_conf_file()); - Arguments = [('D',"debug","Natalie::Options::Debug", "IntVal"), - ('h',"help","Natalie::Options::Help"), - ('V',"version","Natalie::Options::Version"), + Arguments = [('h',"help","Natalie::Options::Help"), ('c',"component", "Natalie::Options::Component", "HasArg"), ('l',"list", "Natalie::Options::List"), ('s',"suite","Natalie::Options::Suite", "HasArg"), ('S',"set","Natalie::Options::Set"), ('t',"type","Natalie::Options::Type", "HasArg")]; + + # Default arguments + for i in ["help", "list", "set" ]: + Cnf["Natalie::Options::%s" % (i)] = ""; + Cnf["Natalie::Options::Component"] = "main"; + Cnf["Natalie::Options::Suite"] = "unstable"; + Cnf["Natalie::Options::Type"] = "deb"; + file_list = apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv); if Cnf["Natalie::Options::Help"]: - usage(0); + usage(); init(); diff --git a/rhona b/rhona index c7ee05bc..f8a21fc1 100755 --- a/rhona +++ b/rhona @@ -2,7 +2,7 @@ # rhona, cleans up unassociated binary and source packages # Copyright (C) 2000, 2001 James Troup -# $Id: rhona,v 1.16 2001-06-22 23:30:21 troup Exp $ +# $Id: rhona,v 1.17 2001-09-27 01:23:41 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 @@ -18,7 +18,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -################################################################################################### +################################################################################ # 07:05| well.. *shrug*.. no, probably not.. but to fix it, # | we're going to have to implement reference counting @@ -27,34 +27,35 @@ # # 07:05| elmo: Augh! -################################################################################################### +################################################################################ import os, pg, stat, string, sys, time import apt_pkg import utils -################################################################################################### +################################################################################ -projectB = None -Cnf = None +projectB = None; +Cnf = None; +Options = None; now_date = None; # mark newly "deleted" things as deleted "now" delete_date = None; # delete things marked "deleted" earler than this -################################################################################################### +################################################################################ -def usage (exit_code): - print """Usage: rhona [OPTION]... [CHANGES]... - -D, --debug=VALUE debug - -n, --no-action don't do anything - -v, --verbose be verbose - -V, --version display version number and exit""" +def usage (exit_code=0): + print """Usage: rhona [OPTIONS] +Clean old packages from suites. + + -n, --no-action don't do anything + -h, --help show this help and exit""" sys.exit(exit_code) -################################################################################################### - +################################################################################ + def check_binaries(): global delete_date, now_date; - + print "Checking for orphaned binary packages..." # Get the list of binary packages not in a suite and mark them for @@ -103,7 +104,7 @@ SELECT s.id, s.file FROM source s #### byebye and sources go byebye is 0 instead of StayOfExecution) ql = q.getresult(); - + projectB.query("BEGIN WORK"); for i in ql: source_id = i[0]; @@ -161,7 +162,7 @@ SELECT id FROM files f file_id = i[0]; projectB.query("UPDATE files SET last_used = '%s' WHERE id = %s" % (now_date, file_id)); projectB.query("COMMIT WORK"); - + def clean_binaries(): global delete_date, now_date; @@ -171,7 +172,7 @@ def clean_binaries(): # XXX: why doesn't this remove the files here as well? I don't think it # buys anything keeping this separate print "Cleaning binaries from the DB..." - if not Cnf["Rhona::Options::No-Action"]: + if not Options["No-Action"]: before = time.time(); sys.stdout.write("[Deleting from binaries table... "); projectB.query("DELETE FROM binaries WHERE EXISTS (SELECT id FROM files WHERE binaries.file = files.id AND files.last_used <= '%s')" % (delete_date)); @@ -188,15 +189,15 @@ def clean(): dest = Cnf["Dir::Morgue"] + '/' + Cnf["Rhona::MorgueSubDir"] + '/' + date; if not os.path.exists(dest): os.mkdir(dest); - + # Delete from source - if not Cnf["Rhona::Options::No-Action"]: + if not Options["No-Action"]: before = time.time(); sys.stdout.write("[Deleting from source table... "); projectB.query("DELETE FROM dsc_files WHERE EXISTS (SELECT df.id FROM source s, files f, dsc_files df WHERE f.last_used <= '%s' AND s.file = f.id AND s.id = df.source AND df.id = dsc_files.id)" % (delete_date)); projectB.query("DELETE FROM source WHERE EXISTS (SELECT id FROM files WHERE source.file = files.id AND files.last_used <= '%s')" % (delete_date)); sys.stdout.write("done. (%d seconds)]\n" % (int(time.time()-before))); - + # Delete files from the pool q = projectB.query("SELECT l.path, f.filename FROM location l, files f WHERE f.last_used <= '%s' AND l.id = f.location" % (delete_date)); for i in q.getresult(): @@ -207,7 +208,7 @@ def clean(): if os.path.isfile(filename): if os.path.islink(filename): count = count + 1; - if Cnf["Rhona::Options::No-Action"]: + if Options["No-Action"]: print "Removing symlink %s..." % (filename); else: os.unlink(filename); @@ -219,16 +220,16 @@ def clean(): # If the destination file exists; try to find another filename to use if os.path.exists(dest_filename): dest_filename = utils.find_next_free(dest_filename); - - if Cnf["Rhona::Options::No-Action"]: + + if Options["No-Action"]: print "Cleaning %s -> %s ..." % (filename, dest_filename); else: utils.move(filename, dest_filename); else: utils.fubar("%s is neither symlink nor file?!" % (filename)); - + # Delete from the 'files' table - if not Cnf["Rhona::Options::No-Action"]: + if not Options["No-Action"]: before = time.time(); sys.stdout.write("[Deleting from files table... "); projectB.query("DELETE FROM files WHERE last_used <= '%s'" % (delete_date)); @@ -238,7 +239,7 @@ def clean(): def clean_maintainers(): print "Cleaning out unused Maintainer entries..." - + q = projectB.query(""" SELECT m.id FROM maintainer m WHERE NOT EXISTS (SELECT id FROM binaries b WHERE b.maintainer = m.id) @@ -249,7 +250,7 @@ SELECT m.id FROM maintainer m projectB.query("BEGIN WORK"); for i in ql: maintainer_id = i[0]; - if not Cnf["Rhona::Options::No-Action"]: + if not Options["No-Action"]: projectB.query("DELETE FROM maintainer WHERE id = %s" % (maintainer_id)); count = count + 1; projectB.query("COMMIT WORK"); @@ -257,34 +258,30 @@ SELECT m.id FROM maintainer m if count > 0: sys.stderr.write("Cleared out %d maintainer entries.\n" % (count)); +################################################################################ + def main(): - global Cnf, projectB, delete_date, now_date; - + global Cnf, Options, projectB, delete_date, now_date; + apt_pkg.init(); - + Cnf = apt_pkg.newConfiguration(); apt_pkg.ReadConfigFileISC(Cnf,utils.which_conf_file()); projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"])); - Arguments = [('D',"debug","Rhona::Options::Debug", "IntVal"), - ('h',"help","Rhona::Options::Help"), - ('n',"no-action","Rhona::Options::No-Action"), - ('V',"version","Rhona::Options::Version")]; - + Arguments = [('h',"help","Rhona::Options::Help"), + ('n',"no-action","Rhona::Options::No-Action")]; + apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv); Options = Cnf.SubTree("Rhona::Options") if Options["Help"]: - usage(0); - - if Options["Version"]: - print "rhona version 0.0000000000"; - usage(0); + usage(); now_date = time.strftime("%Y-%m-%d %H:%M", time.localtime(time.time())); delete_date = time.strftime("%Y-%m-%d %H:%M", time.localtime(time.time()-int(Cnf["Rhona::StayOfExecution"]))); - + check_binaries(); clean_binaries(); check_sources(); @@ -292,6 +289,8 @@ def main(): clean(); clean_maintainers(); +################################################################################ + if __name__ == '__main__': main() diff --git a/tea b/tea index 209e63a5..bf163f18 100755 --- a/tea +++ b/tea @@ -2,7 +2,7 @@ # Sanity check the database # Copyright (C) 2000, 2001 James Troup -# $Id: tea,v 1.11 2001-06-22 22:53:14 troup Exp $ +# $Id: tea,v 1.12 2001-09-27 01:23:41 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 @@ -39,8 +39,8 @@ excluded = {}; def process_dir (arg, dirname, filenames): global waste, db_files, excluded; - - if string.find(dirname, '/disks-') != -1 or string.find(dirname, 'upgrade-') != -1: + + if string.find(dirname, '/disks-') != -1 or string.find(dirname, 'upgrade-') != -1: return; # hack; can't handle .changes files if string.find(dirname, 'proposed-updates') != -1: @@ -161,7 +161,7 @@ def check_md5sums(): print "Getting file information from database..."; q = projectB.query("SELECT l.path, f.filename, f.md5sum, f.size FROM files f, location l WHERE f.location = l.id") ql = q.getresult(); - + print "Checking file md5sums & sizes..."; for i in ql: filename = os.path.abspath(i[0] + i[1]); @@ -187,18 +187,14 @@ def main (): global Cnf, projectB, db_files, waste, excluded; apt_pkg.init(); - + Cnf = apt_pkg.newConfiguration(); apt_pkg.ReadConfigFileISC(Cnf,utils.which_conf_file()); - Arguments = [('d',"debug","Tea::Options::Debug", "IntVal"), - ('h',"help","Tea::Options::Help"), - ('v',"version","Tea::Options::Version")]; - - apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv); + 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_override();