From 5fc7cefdb9b600c729ca5a82fd5b3a828f4fd370 Mon Sep 17 00:00:00 2001 From: James Troup Date: Thu, 27 Sep 2001 01:22:51 +0000 Subject: [PATCH] usage() + options cleanup --- catherine | 44 +++++++++++++++++++++++++++++++------------- claire.py | 34 ++++++++++++++++++++++++---------- fernanda | 37 +++++++++++++++++++++++++++---------- heidi | 27 +++++++++++++++++++++++---- jenna | 47 +++++++++++++++++++++++++++++++++++------------ shania | 43 +++++++++++++++++++++++++++++++------------ ziyi | 22 ++++++++++++++++++---- 7 files changed, 189 insertions(+), 65 deletions(-) diff --git a/catherine b/catherine index ce4b3dff..70996a9f 100755 --- a/catherine +++ b/catherine @@ -2,7 +2,7 @@ # Poolify (move packages from "legacy" type locations to pool locations) # Copyright (C) 2000, 2001 James Troup -# $Id: catherine,v 1.10 2001-06-22 22:53:14 troup Exp $ +# $Id: catherine,v 1.11 2001-09-27 01:22:51 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 @@ -33,6 +33,21 @@ import apt_pkg, apt_inst; Cnf = None; projectB = None; +################################################################################ + +def usage (exit_code=0): + print """Usage: catherine [OPTIONS] +Migrate packages from legacy locations into the pool. + + -l, --limit=AMOUNT only migrate AMOUNT Kb of packages + -n, --no-action don't do anything + -v, --verbose explain what is being done + -h, --help show this help and exit""" + + sys.exit(exit_code) + +################################################################################ + # Q is a python-postgresql query result set and must have the # following four columns: # o files.id (as 'files_id') @@ -113,27 +128,30 @@ def poolize (q, limit, verbose, no_action): q = projectB.query("UPDATE files SET filename = '%s', location = '%s' WHERE id = '%s'" % (pool_filename, location_id, qid["files_id"])); sys.stderr.write("Poolized %s in %s files.\n" % (utils.size_type(poolized_size), poolized_count)); - + ################################################################################ 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"), + Arguments = [('h',"help","Catherine::Options::Help"), ('l',"limit", "Catherine::Options::Limit", "HasArg"), ('n',"no-action","Catherine::Options::No-Action"), ('v',"verbose","Catherine::Options::Verbose")]; + for i in ["help", "limit", "no-action", "verose" ]: + Cnf["Catherine::Options::%s" % (i)] = ""; apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv); Options = Cnf.SubTree("Catherine::Options") + if Options["Help"]: + usage(); + projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"])); db_access.init(Cnf, projectB); @@ -152,14 +170,14 @@ def main (): # Grab a list of all files not already in the pool q = projectB.query(""" -SELECT l.path, f.filename, f.id as files_id, c.name as component - FROM files f, location l, component c WHERE - NOT EXISTS (SELECT * FROM location l WHERE l.type = 'pool' AND f.location = l.id) - AND NOT (f.filename ~ '^potato') AND f.location = l.id AND l.component = c.id +SELECT l.path, f.filename, f.id as files_id, c.name as component + FROM files f, location l, component c WHERE + NOT EXISTS (SELECT * FROM location l WHERE l.type = 'pool' AND f.location = l.id) + AND NOT (f.filename ~ '^potato') AND f.location = l.id AND l.component = c.id UNION SELECT l.path, f.filename, f.id as files_id, null as component - FROM files f, location l WHERE - NOT EXISTS (SELECT * FROM location l WHERE l.type = 'pool' AND f.location = l.id) - AND NOT (f.filename ~ '^potato') AND f.location = l.id AND NOT EXISTS + FROM files f, location l WHERE + NOT EXISTS (SELECT * FROM location l WHERE l.type = 'pool' AND f.location = l.id) + AND NOT (f.filename ~ '^potato') AND f.location = l.id AND NOT EXISTS (SELECT l.path FROM location l WHERE l.component IS NOT NULL AND f.location = l.id);"""); poolize(q, limit, Options["Verbose"], Options["No-Action"]); diff --git a/claire.py b/claire.py index c78086ea..131f83ca 100755 --- a/claire.py +++ b/claire.py @@ -2,7 +2,7 @@ # 'Fix' stable to make debian-cd and dpkg -BORGiE users happy # Copyright (C) 2000, 2001 James Troup -# $Id: claire.py,v 1.7 2001-04-03 10:02:16 troup Exp $ +# $Id: claire.py,v 1.8 2001-09-27 01:22:51 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 +################################################################################ + # "Look around... leaves are brown... and the sky's a hazy shade of winter, # Look around... leaves are brown... there's a patch of snow on the ground." # -- Simon & Garfunkel / 'A Hazy Shade' @@ -37,6 +39,17 @@ projectB = None; ################################################################################ +def usage (exit_code=0): + print """Usage: claire [OPTIONS] +Create compatability symlinks from legacy locations to the pool. + + -v, --verbose explain what is being done + -h, --help show this help and exit""" + + sys.exit(exit_code) + +################################################################################ + # Relativize an absolute symlink from 'src' -> 'dest' relative to 'root'. # Returns fixed 'src' def clean_symlink (src, dest, root): @@ -99,9 +112,6 @@ UNION SELECT DISTINCT ON (f.id) null, sec.section, l.path, f.filename, f.id os.symlink(src, dest); dislocated_files[i[4]] = dest; - #return dislocated_files; - - # TODO later when there's something to test it with! # Binary q = projectB.query(""" SELECT DISTINCT ON (f.id) c.name, a.arch_string, sec.section, b.package, @@ -128,7 +138,7 @@ UNION SELECT DISTINCT ON (f.id) null, a.arch_string, sec.section, b.package, package = i[3] version = utils.re_no_epoch.sub('', i[4]); src = i[5]+i[6] - + dest = "%sdists/%s/%s/binary-%s/%s%s_%s.deb" % (Cnf["Dir::RootDir"], Cnf.get("Suite::Stable::CodeName", "stable"), component, architecture, section, package, version); src = clean_symlink(src, dest, Cnf["Dir::RootDir"]); if not os.path.exists(dest): @@ -145,16 +155,20 @@ def main (): global Cnf, projectB; apt_pkg.init(); - + Cnf = apt_pkg.newConfiguration(); apt_pkg.ReadConfigFileISC(Cnf,utils.which_conf_file()); - Arguments = [('d',"debug","Claire::Options::Debug", "IntVal"), - ('h',"help","Claire::Options::Help"), - ('v',"verbose","Claire::Options::Verbose"), - ('V',"version","Claire::Options::Version")]; + Arguments = [('h',"help","Claire::Options::Help"), + ('v',"verbose","Claire::Options::Verbose")]; + for i in ["help", "verbose" ]: + Cnf["Claire::Options::%s" % (i)] = ""; apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv); + Options = Cnf.SubTree("Claire::Options") + + if Options["Help"]: + usage(); projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"])); diff --git a/fernanda b/fernanda index d945f752..206633d5 100755 --- a/fernanda +++ b/fernanda @@ -2,7 +2,7 @@ # Script to automate some parts of checking NEW packages # Copyright (C) 2000, 2001 James Troup -# $Id: fernanda,v 1.2 2001-06-22 22:53:14 troup Exp $ +# $Id: fernanda,v 1.3 2001-09-27 01:22:51 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 @@ -47,6 +47,18 @@ re_doc_directory = re.compile(r".*/doc/([^/]*).*"); ################################################################################ +def usage (exit_code=0): + print """Usage: fernanda [PACKAGE]... +Check NEW package(s). + + -h, --help show this help and exit + +PACKAGE can be a .changes, .dsc, .deb or .udeb filename.""" + + sys.exit(exit_code) + +################################################################################ + def do_command (command, filename): o = os.popen("%s %s" % (command, filename)); print o.read(); @@ -88,7 +100,7 @@ def check_deb (deb_filename): print "---- control file for %s ----" % (filename); do_command ("dpkg -I", deb_filename); - + if is_a_udeb: print "---- skipping lintian check for µdeb ----"; print ; @@ -110,16 +122,16 @@ def check_deb (deb_filename): def check_changes (changes_filename): changes = utils.parse_changes (changes_filename, 0); - + print "---- .changes file for %s ----" % (changes_filename); file = utils.open_file (changes_filename, 'r'); for line in file.readlines(): print line[:-1] print ; file.close(); - + files = utils.build_file_list(changes, ""); - + for file in files.keys(): if file[-4:] == ".deb" or file[-5:] == ".udeb": check_deb(file); @@ -131,17 +143,22 @@ 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","Jennifer::Options::Debug", "IntVal"), - ('h',"help","Jennifer::Options::Help"), - ('v',"version","Jennifer::Options::Version")]; + Arguments = [('h',"help","Fernanda::Options::Help")]; + for i in [ "help" ]: + Cnf["Fernanda::Options::%s" % (i)] = ""; args = apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv); + Options = Cnf.SubTree("Fernanda::Options") + + if Options["Help"]: + usage(); + stdout_fd = sys.stdout; - + for file in args: try: # Pipe output for each argument through less diff --git a/heidi b/heidi index 5af7c3fd..dd04e916 100755 --- a/heidi +++ b/heidi @@ -2,7 +2,7 @@ # Manipulate suite tags # Copyright (C) 2000, 2001 James Troup -# $Id: heidi,v 1.8 2001-09-14 17:16:18 troup Exp $ +# $Id: heidi,v 1.9 2001-09-27 01:22:51 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 @@ -52,6 +52,20 @@ Cnf = None; projectB = None; Logger = None; +################################################################################ + +def usage (exit_code=0): + print """Usage: heidi [OPTIONS] [FILE] +Display or alter the contents of a suite using FILE(s), or stdin. + + -a, --add=SUITE add to SUITE + -l, --list=SUITE list the contents of SUITE + -r, --remove=SUITE remove from SUITE + -s, --set=SUITE set SUITE + -h, --help show this help and exit""" + + sys.exit(exit_code) + ####################################################################################### def get_id (package, version, architecture): @@ -221,14 +235,19 @@ def main (): apt_pkg.ReadConfigFileISC(Cnf,utils.which_conf_file()); Arguments = [('a',"add","Heidi::Options::Add", "HasArg"), - ('D',"debug","Heidi::Options::Debug", "IntVal"), ('h',"help","Heidi::Options::Help"), ('l',"list","Heidi::Options::List","HasArg"), ('r',"remove", "Heidi::Options::Remove", "HasArg"), - ('s',"set", "Heidi::Options::Set", "HasArg"), - ('V',"version","Heidi::Options::Version")]; + ('s',"set", "Heidi::Options::Set", "HasArg")]; + + for i in ["add", "help", "list", "remove", "set", "version" ]: + Cnf["Heidi::Options::%s" % (i)] = ""; file_list = apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv); + Options = Cnf.SubTree("Heidi::Options") + + if Options["Help"]: + usage(); projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"],int(Cnf["DB::Port"])); diff --git a/jenna b/jenna index 0854de6c..07e8ca79 100755 --- a/jenna +++ b/jenna @@ -2,7 +2,7 @@ # Generate file list which is then fed to apt-ftparchive to generate Packages and Sources files # Copyright (C) 2000, 2001 James Troup -# $Id: jenna,v 1.13 2001-08-21 15:47:47 troup Exp $ +# $Id: jenna,v 1.14 2001-09-27 01:22:51 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,22 +18,41 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -####################################################################################### +################################################################################ # BTAF: "GOD *DAMMIT*!! What the FUCK happened to my free will??" # # -- http://www.angryflower.com/timelo.gif -####################################################################################### +################################################################################ import pg, string, os, sys import apt_pkg import db_access, utils, claire, logging +################################################################################ + projectB = None Cnf = None Logger = None; +################################################################################ + +def usage (exit_code=0): + print """Usage: jenna [OPTION] +Write out file lists suitable for use with apt-ftparchive. + + -a, --architecture=ARCH only write file lists for this architecture + -c, --component=COMPONENT only write file lists for this component + -s, --suite=SUITE only write file lists for this suite + -h, --help show this help and exit + +ARCH, COMPONENT and SUITE can be space seperated lists, e.g. + --architecture=\"m68k i386\"""" + sys.exit(exit_code) + +################################################################################ + def generate_src_list(suite, component, output, dislocated_files): sources = {} @@ -205,21 +224,25 @@ def main(): Arguments = [('a',"architecture","Jenna::Options::Architecture", "HasArg"), ('c',"component","Jenna::Options::Component", "HasArg"), - ('d',"debug","Jenna::Options::Debug", "IntVal"), ('h',"help","Jenna::Options::Help"), - ('s',"suite", "Jenna::Options::Suite", "HasArg"), - ('v',"verbose","Jenna::Options::Verbose"), - ('V',"version","Jenna::Options::Version")]; + ('s',"suite", "Jenna::Options::Suite", "HasArg")]; + + for i in ["architecture", "component", "help", "suite" ]: + Cnf["Jenna::Options::%s" % (i)] = ""; apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv); + Options = Cnf.SubTree("Jenna::Options"); + + if Options["Help"]: + usage(); projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"])); db_access.init(Cnf, projectB); Logger = logging.Logger(Cnf, "jenna"); - if Cnf["Jenna::Options::Suite"] == "": - Cnf["Jenna::Options::Suite"] = string.join(Cnf.SubTree("Suite").List()); - for suite in string.split(Cnf["Jenna::Options::Suite"]): + if Options["Suite"] == "": + Options["Suite"] = string.join(Cnf.SubTree("Suite").List()); + for suite in string.split(Options["Suite"]): suite = string.lower(suite); if suite == 'stable': dislocated_files = claire.find_dislocated_stable(Cnf, projectB); @@ -227,14 +250,14 @@ def main(): dislocated_files = {}; clean_suite(suite); clean_duplicate_packages(suite) - components = Cnf["Jenna::Options::Component"]; + components = Options["Component"]; if not Cnf.has_key("Suite::%s::Components" % (suite)): components = "-"; if components == "": components = string.join(Cnf.SubTree("Suite::%s::Components" % (suite)).List()); for component in string.split(components): component = string.lower(component) - architectures = Cnf["Jenna::Options::Architecture"]; + architectures = Options["Architecture"]; if architectures == "": architectures = string.join(Cnf.SubTree("Suite::%s::Architectures" % (suite)).List()); for architecture in string.split(architectures): diff --git a/shania b/shania index 963748ea..83b748ae 100755 --- a/shania +++ b/shania @@ -2,7 +2,7 @@ # Clean incoming of old unused files # Copyright (C) 2000, 2001 James Troup -# $Id: shania,v 1.5 2001-06-23 00:25:52 troup Exp $ +# $Id: shania,v 1.6 2001-09-27 01:22:51 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,7 +25,7 @@ import utils import apt_pkg; ################################################################################ - + # 23:12| I will not hush! # 23:12| :> # 23:12| Where there is injustice in the world, I shall be there! @@ -49,9 +49,23 @@ del_dir = None; ################################################################################ +def usage (exit_code=0): + print """Usage: shania [OPTIONS] +Clean out incoming directories. + + -d, --days=DAYS remove anything older than DAYS old + -i, --incoming=INCOMING the incoming directory to clean + -n, --no-action don't do anything + -v, --verbose explain what is being done + -h, --help show this help and exit""" + + sys.exit(exit_code) + +################################################################################ + def init (): global delete_date, del_dir; - + delete_date = int(time.time())-(int(Options["Days"])*84600); # Ensure a directory exists to remove files to @@ -79,7 +93,7 @@ def remove (file): utils.move(file, dest_filename); else: utils.warn("skipping '%s', permission denied." % (os.path.basename(file))); - + # Removes any old files. # [Used for Incoming/REJECT] # @@ -103,7 +117,7 @@ def flush_old (): def flush_orphans (): all_files = {}; changes_files = []; - + # Build up the list of all files in the directory for i in os.listdir('.'): if os.path.isfile(i): @@ -139,7 +153,7 @@ def flush_orphans (): if Options["Verbose"]: print "Skipping, has parents, '%s'." % (key); del all_files[key]; - + # Anthing left at this stage is not referenced by a .changes (or # a .dsc) and should be deleted if old enough. for file in all_files.keys(): @@ -153,26 +167,31 @@ def flush_orphans (): else: if Options["Verbose"]: print "Skipping, too new, '%s'." % (os.path.basename(file)); - + +################################################################################ + def main (): global Cnf, Options; - + apt_pkg.init(); - + Cnf = apt_pkg.newConfiguration(); apt_pkg.ReadConfigFileISC(Cnf,utils.which_conf_file()); - Arguments = [('D',"debug","Shania::Options::Debug", "IntVal"), - ('h',"help","Shania::Options::Help"), - ('V',"version","Shania::Options::Version"), + Arguments = [('h',"help","Shania::Options::Help"), ('d',"days","Shania::Options::Days", "IntVal"), ('i',"incoming","Shania::Options::Incoming", "HasArg"), ('n',"no-action","Shania::Options::No-Action"), ('v',"verbose","Shania::Options::Verbose")]; + for i in ["help", "days", "incoming", "no-action", "verbose" ]: + Cnf["Shania::Options::%s" % (i)] = ""; apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv); Options = Cnf.SubTree("Shania::Options") + if Options["Help"]: + usage(); + init (); if Options["Verbose"]: diff --git a/ziyi b/ziyi index 97131540..cd703342 100755 --- a/ziyi +++ b/ziyi @@ -3,7 +3,7 @@ # Create all the Release files # Copyright (C) 2001 Anthony Towns -# $Id: ziyi,v 1.7 2001-08-21 15:40:10 troup Exp $ +# $Id: ziyi,v 1.8 2001-09-27 01:22:51 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 @@ -34,6 +34,16 @@ projectB = None ################################################################################ +def usage (exit_code=0): + print """Usage: ziyi [OPTION] +Generate Release files. + + -h, --help show this help and exit""" + + sys.exit(exit_code) + +################################################################################ + def compressnames (tree,type,file): compress = AptCnf.get("%s::%s::Compress" % (tree,type), AptCnf.get("Default::%s::Compress" % (type), ". gzip")) result = [] @@ -89,11 +99,15 @@ def main (): AptCnf = apt_pkg.newConfiguration() apt_pkg.ReadConfigFileISC(AptCnf,utils.which_apt_conf_file()) - Arguments = [('d',"debug","Ziyi::Options::Debug", "IntVal"), - ('h',"help","Ziyi::Options::Help"), - ('v',"version","Ziyi::Options::Version")] + Arguments = [('h',"help","Ziyi::Options::Help")]; + for i in [ "help" ]: + Cnf["Ziyi::Options::%s" % (i)] = ""; suites = apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv) + Options = Cnf.SubTree("Ziyi::Options") + + if Options["Help"]: + usage(); if suites == []: suites = Cnf.SubTree("Suite").List() -- 2.39.2