From 2f5e692bfbbb6f8146f50d944f7fcc169a95a0a3 Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Sun, 18 Nov 2001 19:57:58 +0000 Subject: [PATCH] read all configs when utils is imported, allowing utils to make use ofconfig values. Also use those config values in init. Two small bugs fixedin shania and jenna. --- alyson | 6 ++---- andrea | 7 ++----- catherine | 12 ++++++------ charisma | 11 +++++------ christina | 7 ++----- cindy | 7 ++----- claire.py | 9 ++++----- denise | 7 ++----- fernanda | 10 ++++------ halle | 10 ++++------ heidi | 10 ++++------ jenna | 12 +++++------- jeri | 10 ++++------ julia | 10 ++++------ katie | 12 +++++------- madison | 10 ++++------ melanie | 15 +++++++-------- natalie.py | 19 ++++++++++--------- neve | 7 ++----- rene | 7 ++----- rhona | 7 ++----- shania | 14 +++++++------- tea | 7 ++----- utils.py | 50 ++++++++++++++++++++++++-------------------------- ziyi | 11 ++++------- 25 files changed, 119 insertions(+), 168 deletions(-) diff --git a/alyson b/alyson index 4344f790..007063f1 100755 --- a/alyson +++ b/alyson @@ -2,7 +2,7 @@ # Sync the ISC configuartion file and the SQL database # Copyright (C) 2000, 2001 James Troup -# $Id: alyson,v 1.5 2001-09-27 14:42:02 troup Exp $ +# $Id: alyson,v 1.6 2001-11-18 19:57:58 rmurray 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 @@ -40,10 +40,8 @@ def get (c, i): def main (): global Cnf, projectB; - apt_pkg.init(); + Cnf = utils.get_conf() - Cnf = apt_pkg.newConfiguration(); - apt_pkg.ReadConfigFileISC(Cnf,utils.which_conf_file()); Arguments = [('D',"debug","Alyson::Options::Debug", "IntVal"), ('h',"help","Alyson::Options::Help"), ('v',"version","Alyson::Options::Version")]; diff --git a/andrea b/andrea index b678d9de..be7e9b32 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.4 2001-09-27 01:23:41 troup Exp $ +# $Id: andrea,v 1.5 2001-11-18 19:57:58 rmurray 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 @@ -35,10 +35,7 @@ projectB = None; def main (): global Cnf, projectB; - 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); diff --git a/catherine b/catherine index 16b7ad66..f7841b12 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.12 2001-11-04 22:28:44 troup Exp $ +# $Id: catherine,v 1.13 2001-11-18 19:57:58 rmurray 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 @@ -134,17 +134,17 @@ def poolize (q, limit, verbose, no_action): def main (): global Cnf, projectB; - apt_pkg.init(); + Cnf = utils.get_conf() + + for i in ["help", "limit", "no-action", "verose" ]: + if not Cnf.has_key("Catherine::Options::%s" % (i)): + Cnf["Catherine::Options::%s" % (i)] = ""; - Cnf = apt_pkg.newConfiguration(); - apt_pkg.ReadConfigFileISC(Cnf,utils.which_conf_file()); 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") diff --git a/charisma b/charisma index 63d9a918..c88fa525 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.11 2001-09-27 01:23:41 troup Exp $ +# $Id: charisma,v 1.12 2001-11-18 19:57:58 rmurray 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 @@ -76,13 +76,12 @@ def get_maintainer_from_source (source_id): def main(): global Cnf, projectB; - apt_pkg.init(); - - Cnf = apt_pkg.newConfiguration(); - apt_pkg.ReadConfigFileISC(Cnf,utils.which_conf_file()); + Cnf = utils.get_conf() Arguments = [('h',"help","Charisma::Options::Help")]; - Cnf["Charisma::Options::Help"] = ""; + if not Cnf.has_key("Charisma::Options::Help"): + Cnf["Charisma::Options::Help"] = ""; + extra_files = apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv); Options = Cnf.SubTree("Charisma::Options"); diff --git a/christina b/christina index b6af669b..15b3a64d 100644 --- a/christina +++ b/christina @@ -2,7 +2,7 @@ # Compares Packages-Arch-Specific (from Quinn-Diff) against the archive # Copyright (C) 2000, 2001 James Troup -# $Id: christina,v 1.3 2001-11-04 22:28:44 troup Exp $ +# $Id: christina,v 1.4 2001-11-18 19:57:58 rmurray 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 @@ -97,10 +97,7 @@ def get_source (): def main (): global Cnf, projectB; - apt_pkg.init(); - - Cnf = apt_pkg.newConfiguration(); - apt_pkg.ReadConfigFileISC(Cnf,utils.which_conf_file()); + Cnf = utils.get_conf() Arguments = [('d',"debug","Christina::Options::Debug", "IntVal"), ('h',"help","Christina::Options::Help"), diff --git a/cindy b/cindy index 038a4796..9f239339 100755 --- a/cindy +++ b/cindy @@ -2,7 +2,7 @@ # Output override files for apt-ftparchive and indices/ # Copyright (C) 2000, 2001 James Troup -# $Id: cindy,v 1.5 2001-11-04 22:28:44 troup Exp $ +# $Id: cindy,v 1.6 2001-11-18 19:57:58 rmurray 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 @@ -95,10 +95,7 @@ def process(suite, component, type): def main (): global Cnf, projectB, override; - apt_pkg.init(); - - Cnf = apt_pkg.newConfiguration(); - apt_pkg.ReadConfigFileISC(Cnf,utils.which_conf_file()); + Cnf = utils.get_conf() Arguments = [('D',"debug","Denise::Options::Debug", "IntVal"), ('h',"help","Denise::Options::Help"), ('V',"version","Denise::Options::Version")]; diff --git a/claire.py b/claire.py index 1de00b68..9982d216 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.10 2001-11-04 20:41:37 troup Exp $ +# $Id: claire.py,v 1.11 2001-11-18 19:57:58 rmurray 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 @@ -166,15 +166,14 @@ UNION SELECT DISTINCT ON (f.id) null, a.arch_string, sec.section, b.package, def main (): global Cnf, projectB; - apt_pkg.init(); - - Cnf = apt_pkg.newConfiguration(); + Cnf = utils.get_conf() apt_pkg.ReadConfigFileISC(Cnf,utils.which_conf_file()); Arguments = [('h',"help","Claire::Options::Help"), ('v',"verbose","Claire::Options::Verbose")]; for i in ["help", "verbose" ]: - Cnf["Claire::Options::%s" % (i)] = ""; + if not Cnf.has_key("Claire::Options::%s" % (i)): + Cnf["Claire::Options::%s" % (i)] = ""; apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv); Options = Cnf.SubTree("Claire::Options") diff --git a/denise b/denise index 7d7ed102..b17dad05 100755 --- a/denise +++ b/denise @@ -2,7 +2,7 @@ # Output override files for apt-ftparchive and indices/ # Copyright (C) 2000, 2001 James Troup -# $Id: denise,v 1.8 2001-09-17 11:18:37 troup Exp $ +# $Id: denise,v 1.9 2001-11-18 19:57:58 rmurray 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 @@ -75,10 +75,7 @@ def list(suite, component, type): def main (): global Cnf, projectB, override; - apt_pkg.init(); - - Cnf = apt_pkg.newConfiguration(); - apt_pkg.ReadConfigFileISC(Cnf,utils.which_conf_file()); + Cnf = utils.get_conf() Arguments = [('D',"debug","Denise::Options::Debug", "IntVal"), ('h',"help","Denise::Options::Help"), ('V',"version","Denise::Options::Version")]; diff --git a/fernanda b/fernanda index b9d8f500..466f6197 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.4 2001-11-04 22:28:44 troup Exp $ +# $Id: fernanda,v 1.5 2001-11-18 19:57:58 rmurray 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 @@ -142,14 +142,12 @@ def check_changes (changes_filename): 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() Arguments = [('h',"help","Fernanda::Options::Help")]; for i in [ "help" ]: - Cnf["Fernanda::Options::%s" % (i)] = ""; + if not Cnf.has_key("Frenanda::Options::%s" % (i)): + Cnf["Fernanda::Options::%s" % (i)] = ""; args = apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv); Options = Cnf.SubTree("Fernanda::Options") diff --git a/halle b/halle index 06f42a65..86d21ddf 100755 --- a/halle +++ b/halle @@ -2,7 +2,7 @@ # Remove obsolete .changes files from proposed-updates # Copyright (C) 2001 James Troup -# $Id: halle,v 1.2 2001-11-04 22:28:44 troup Exp $ +# $Id: halle,v 1.3 2001-11-18 19:57:58 rmurray 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 @@ -144,10 +144,7 @@ ORDER BY package, version, arch_string; def main (): global Cnf, projectB, Options; - apt_pkg.init(); - - Cnf = apt_pkg.newConfiguration(); - apt_pkg.ReadConfigFileISC(Cnf,utils.which_conf_file()); + Cnf = utils.get_conf() Arguments = [('q',"quiet","Halle::Options::Quiet"), ('v',"verbose","Halle::Options::Verbose"), @@ -155,7 +152,8 @@ def main (): ('h',"help","Halle::Options::Help"), ('V',"version","Halle::Options::Version")]; for i in [ "quiet", "verbose", "help", "debug" ]: - Cnf["Halle::Options::%s" % (i)] = ""; + if not Cnf.has_key("Halle::Options::%s" % (i)): + Cnf["Halle::Options::%s" % (i)] = ""; arguments = apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv); Options = Cnf.SubTree("Halle::Options") diff --git a/heidi b/heidi index 476cc213..a523b169 100755 --- a/heidi +++ b/heidi @@ -2,7 +2,7 @@ # Manipulate suite tags # Copyright (C) 2000, 2001 James Troup -# $Id: heidi,v 1.10 2001-11-04 22:40:12 troup Exp $ +# $Id: heidi,v 1.11 2001-11-18 19:57:58 rmurray 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 @@ -232,10 +232,7 @@ def get_list (suite): def main (): global Cnf, projectB, Logger; - apt_pkg.init(); - - Cnf = apt_pkg.newConfiguration(); - apt_pkg.ReadConfigFileISC(Cnf,utils.which_conf_file()); + Cnf = utils.get_conf() Arguments = [('a',"add","Heidi::Options::Add", "HasArg"), ('h',"help","Heidi::Options::Help"), @@ -244,7 +241,8 @@ def main (): ('s',"set", "Heidi::Options::Set", "HasArg")]; for i in ["add", "help", "list", "remove", "set", "version" ]: - Cnf["Heidi::Options::%s" % (i)] = ""; + if not Cnf.has_key("Heidi::Options::%s" % (i)): + Cnf["Heidi::Options::%s" % (i)] = ""; file_list = apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv); Options = Cnf.SubTree("Heidi::Options") diff --git a/jenna b/jenna index 07e8ca79..73fdf0cf 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.14 2001-09-27 01:22:51 troup Exp $ +# $Id: jenna,v 1.15 2001-11-18 19:57:58 rmurray 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 @@ -217,10 +217,7 @@ def main(): global Cnf, projectB, Logger; dislocated_files = {}; - apt_pkg.init(); - - Cnf = apt_pkg.newConfiguration(); - apt_pkg.ReadConfigFileISC(Cnf,utils.which_conf_file()); + Cnf = utils.get_conf() Arguments = [('a',"architecture","Jenna::Options::Architecture", "HasArg"), ('c',"component","Jenna::Options::Component", "HasArg"), @@ -228,7 +225,8 @@ def main(): ('s',"suite", "Jenna::Options::Suite", "HasArg")]; for i in ["architecture", "component", "help", "suite" ]: - Cnf["Jenna::Options::%s" % (i)] = ""; + if not Cnf.has_key("Jenna::Options::%s" % (i)): + Cnf["Jenna::Options::%s" % (i)] = ""; apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv); Options = Cnf.SubTree("Jenna::Options"); @@ -274,7 +272,7 @@ def main(): output = utils.open_file("%s/%s_%s_binary-%s.list" % (Cnf["Dir::ListsDir"], suite, component, architecture), "w"); generate_bin_list(suite, component, architecture, output, "deb", dislocated_files); output.close(); - if component == "main" and (suite == "unstable" or suite == "testing"): # FIXME: must be a cleaner way to say debian-installer is main only? + if component == "main" and (suite == "unstable" or suite == "testing") and Cnf.has_key("Section::debian-installer"): # FIXME: must be a cleaner way to say debian-installer is main only? Logger.log(["Processing dists/%s/%s/debian-installer/binary-%s..." % (suite,component, architecture)]); output = utils.open_file("%s/%s_%s_debian-installer_binary-%s.list" % (Cnf["Dir::ListsDir"], suite, component, architecture), "w"); generate_bin_list(suite, component, architecture, output, "udeb", dislocated_files); diff --git a/jeri b/jeri index 616c2672..ea813541 100755 --- a/jeri +++ b/jeri @@ -2,7 +2,7 @@ # Dependency check proposed-updates # Copyright (C) 2001 James Troup -# $Id: jeri,v 1.2 2001-11-04 22:28:44 troup Exp $ +# $Id: jeri,v 1.3 2001-11-18 19:57:58 rmurray 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 @@ -268,10 +268,7 @@ def parse_packages(): def main (): global Cnf, projectB, Options; - apt_pkg.init(); - - Cnf = apt_pkg.newConfiguration(); - apt_pkg.ReadConfigFileISC(Cnf,utils.which_conf_file()); + Cnf = utils.get_conf() Arguments = [('q',"quiet","Jeri::Options::Quiet"), ('v',"verbose","Jeri::Options::Verbose"), @@ -279,7 +276,8 @@ def main (): ('h',"help","Jeri::Options::Help"), ('V',"version","Jeri::Options::Version")]; for i in [ "quiet", "verbose", "help", "debug" ]: - Cnf["Jeri::Options::%s" % (i)] = ""; + if not Cnf.has_key("Jeri::Options::%s" % (i)): + Cnf["Jeri::Options::%s" % (i)] = ""; arguments = apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv); Options = Cnf.SubTree("Jeri::Options") diff --git a/julia b/julia index f3d8ac43..a9e61730 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.3 2001-11-04 22:28:44 troup Exp $ +# $Id: julia,v 1.4 2001-11-18 19:57:58 rmurray 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 @@ -54,16 +54,14 @@ Sync PostgreSQL's pg_user with PASSWD_FILE. def main (): global Cnf, projectB; - apt_pkg.init(); - - Cnf = apt_pkg.newConfiguration(); - apt_pkg.ReadConfigFileISC(Cnf,utils.which_conf_file()); + Cnf = utils.get_conf() Arguments = [('q',"quiet","Julia::Options::Quiet"), ('v',"verbose","Julia::Options::Verbose"), ('h',"help","Julia::Options::Help")]; for i in ["quiet", "verbose", "help" ]: - Cnf["Julia::Options::%s" % (i)] = ""; + if not Cnf.has_key("Julia::Options::%s" % (i)): + Cnf["Julia::Options::%s" % (i)] = ""; arguments = apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv); Options = Cnf.SubTree("Julia::Options") diff --git a/katie b/katie index 01a83131..eb7e0d8d 100755 --- a/katie +++ b/katie @@ -2,7 +2,7 @@ # Installs Debian packages # Copyright (C) 2000, 2001 James Troup -# $Id: katie,v 1.62 2001-11-04 22:41:31 troup Exp $ +# $Id: katie,v 1.63 2001-11-18 19:57:58 rmurray 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 @@ -70,17 +70,14 @@ orig_tar_location = ""; legacy_source_untouchable = {}; Subst = {}; nmu = None; -katie_version = "$Revision: 1.62 $"; +katie_version = "$Revision: 1.63 $"; ############################################################################### def init(): global Cnf, Options; - apt_pkg.init(); - - Cnf = apt_pkg.newConfiguration(); - apt_pkg.ReadConfigFileISC(Cnf,utils.which_conf_file()); + Cnf = utils.get_conf() Arguments = [('a',"automatic","Dinstall::Options::Automatic"), ('h',"help","Dinstall::Options::Help"), @@ -94,7 +91,8 @@ def init(): for i in ["automatic", "help", "ack-new", "manual-reject", "no-action", "no-lock", "no-mail", "override-distribution", "version"]: - Cnf["Dinstall::Options::%s" % (i)] = ""; + if not Cnf.has_key("Dinstall::Options::%s" % (i)): + Cnf["Dinstall::Options::%s" % (i)] = ""; changes_files = apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv); Options = Cnf.SubTree("Dinstall::Options") diff --git a/madison b/madison index 47e33f6a..a0461513 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.12 2001-11-04 22:35:11 troup Exp $ +# $Id: madison,v 1.13 2001-11-18 19:57:58 rmurray 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 @@ -65,16 +65,14 @@ Both ARCH and SUITE can be space seperated lists, e.g. def main (): global Cnf, projectB; - apt_pkg.init(); - - Cnf = apt_pkg.newConfiguration(); - apt_pkg.ReadConfigFileISC(Cnf,utils.which_conf_file()); + Cnf = utils.get_conf() Arguments = [('a',"architecture","Madison::Options::Architecture", "HasArg"), ('s',"suite","Madison::Options::Suite", "HasArg"), ('h',"help","Madison::Options::Help")]; for i in ["architecture", "suite", "help" ]: - Cnf["Madison::Options::%s" % (i)] = ""; + if not Cnf.has_key("Madison::Options::%s" % (i)): + Cnf["Madison::Options::%s" % (i)] = ""; packages = apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv); Options = Cnf.SubTree("Madison::Options") diff --git a/melanie b/melanie index 90260fe2..0232c2c4 100755 --- a/melanie +++ b/melanie @@ -2,7 +2,7 @@ # General purpose package removal tool for ftpmaster # Copyright (C) 2000, 2001 James Troup -# $Id: melanie,v 1.18 2001-11-04 22:35:11 troup Exp $ +# $Id: melanie,v 1.19 2001-11-18 19:57:58 rmurray 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 @@ -75,10 +75,7 @@ def game_over(): def main (): global Cnf, projectB; - apt_pkg.init(); - - Cnf = apt_pkg.newConfiguration(); - apt_pkg.ReadConfigFileISC(Cnf,utils.which_conf_file()); + Cnf = utils.get_conf() Arguments = [('h',"help","Melanie::Options::Help"), ('a',"architecture","Melanie::Options::Architecture", "HasArg"), @@ -94,8 +91,10 @@ def main (): ]; 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"; + if not Cnf.has_key("Melanie::Options::%s" % (i)): + Cnf["Melanie::Options::%s" % (i)] = ""; + if not Cnf.has_key("Melanie::Options::Suite"): + Cnf["Melanie::Options::Suite"] = "unstable"; arguments = apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv); Options = Cnf.SubTree("Melanie::Options") @@ -376,7 +375,7 @@ def main (): Subst["__BCC__"] = "Bcc: " + string.join(bcc, ", "); else: Subst["__BCC__"] = "X-Filler: 42"; - Subst["__CC__"] = "X-Melanie: $Revision: 1.18 $"; + Subst["__CC__"] = "X-Melanie: $Revision: 1.19 $"; if carbon_copy: Subst["__CC__"] = Subst["__CC__"] + "\nCc: " + string.join(carbon_copy, ", "); Subst["__SUITE_LIST__"] = suites_list; diff --git a/natalie.py b/natalie.py index 8626798e..a0e5887a 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.12 2001-11-04 22:28:44 troup Exp $ +# $Id: natalie.py,v 1.13 2001-11-18 19:57:58 rmurray 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 @@ -205,10 +205,7 @@ def list(suite, component, type): def main (): global Cnf, projectB, Logger; - apt_pkg.init(); - - Cnf = apt_pkg.newConfiguration(); - apt_pkg.ReadConfigFileISC(Cnf,utils.which_conf_file()); + Cnf = utils.get_conf() Arguments = [('h',"help","Natalie::Options::Help"), ('c',"component", "Natalie::Options::Component", "HasArg"), ('l',"list", "Natalie::Options::List"), @@ -218,10 +215,14 @@ def main (): # 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"; + if not Cnf.has_key("Natalie::Options::%s" (i)): + Cnf["Natalie::Options::%s" % (i)] = ""; + if not Cnf.has_key("Natalie::Options::Component"): + Cnf["Natalie::Options::Component"] = "main"; + if not Cnf.has_key("Natalie::Options::Suite"): + Cnf["Natalie::Options::Suite"] = "unstable"; + if not Cnf.has_key("Natalie::Options::Type"): + Cnf["Natalie::Options::Type"] = "deb"; file_list = apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv); diff --git a/neve b/neve index 100de615..4b9b6249 100755 --- a/neve +++ b/neve @@ -2,7 +2,7 @@ # Populate the DB # Copyright (C) 2000, 2001 James Troup -# $Id: neve,v 1.6 2001-11-04 22:41:31 troup Exp $ +# $Id: neve,v 1.7 2001-11-18 19:57:58 rmurray 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 @@ -307,10 +307,7 @@ def do_sources(location, prefix, suite, component, server): def main (): global Cnf, projectB, query_cache, files_query_cache, source_query_cache, src_associations_query_cache, dsc_files_query_cache, bin_associations_query_cache, binaries_query_cache; - apt_pkg.init(); - - Cnf = apt_pkg.newConfiguration(); - apt_pkg.ReadConfigFileISC(Cnf,utils.which_conf_file()); + Cnf = utils.get_conf() print "Re-Creating DB..." (result, output) = commands.getstatusoutput("psql -f init_pool.sql") diff --git a/rene b/rene index b7a3eec1..25039b5d 100755 --- a/rene +++ b/rene @@ -2,7 +2,7 @@ # Check for obsolete binary packages # Copyright (C) 2000, 2001 James Troup -# $Id: rene,v 1.8 2001-11-04 22:28:44 troup Exp $ +# $Id: rene,v 1.9 2001-11-18 19:57:58 rmurray 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 @@ -38,10 +38,7 @@ projectB = None; def main (): global Cnf, projectB; - apt_pkg.init(); - - Cnf = apt_pkg.newConfiguration(); - apt_pkg.ReadConfigFileISC(Cnf,utils.which_conf_file()); + Cnf = utils.get_conf() Arguments = [('D',"debug","Catherine::Options::Debug", "IntVal"), ('h',"help","Catherine::Options::Help"), diff --git a/rhona b/rhona index f8a21fc1..f371a0a6 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.17 2001-09-27 01:23:41 troup Exp $ +# $Id: rhona,v 1.18 2001-11-18 19:57:58 rmurray 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 @@ -263,10 +263,7 @@ SELECT m.id FROM maintainer m def main(): global Cnf, Options, projectB, delete_date, now_date; - apt_pkg.init(); - - Cnf = apt_pkg.newConfiguration(); - apt_pkg.ReadConfigFileISC(Cnf,utils.which_conf_file()); + Cnf = utils.get_conf() projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"])); diff --git a/shania b/shania index 51febbb5..cab1c1f7 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.8 2001-11-16 21:35:56 rmurray Exp $ +# $Id: shania,v 1.9 2001-11-18 19:57:58 rmurray 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 @@ -131,7 +131,7 @@ def flush_orphans (): changes = utils.parse_changes(changes_filename, 0) files = utils.build_file_list(changes, ""); except: - utils.warn("error processing '%s'; skipping it. [Got %s]" % (file, sys.exc_type)); + utils.warn("error processing '%s'; skipping it. [Got %s]" % (changes_filename, sys.exc_type)); continue; dsc_files = {}; @@ -173,13 +173,13 @@ def flush_orphans (): def main (): global Cnf, Options; - apt_pkg.init(); - - Cnf = apt_pkg.newConfiguration(); + Cnf = utils.get_conf() for i in ["Help", "Incoming", "No-Action", "Verbose" ]: - Cnf["Shania::Options::%s" % (i)] = ""; - Cnf["Shania::Options::Days"] = "14"; + if not Cnf.has_key("Shania::Options::%s" % (i)): + Cnf["Shania::Options::%s" % (i)] = ""; + if not Cnf.has_key("Shania::Options::Days"): + Cnf["Shania::Options::Days"] = "14"; apt_pkg.ReadConfigFileISC(Cnf,utils.which_conf_file()); diff --git a/tea b/tea index b6ff8c6c..47107a37 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.14 2001-11-18 19:57:58 rmurray 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 @@ -186,10 +186,7 @@ def check_md5sums(): 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"])); diff --git a/utils.py b/utils.py index 97598f98..938134e8 100644 --- a/utils.py +++ b/utils.py @@ -1,6 +1,6 @@ # Utility functions # Copyright (C) 2000, 2001 James Troup -# $Id: utils.py,v 1.35 2001-11-04 22:33:22 troup Exp $ +# $Id: utils.py,v 1.36 2001-11-18 19:57:58 rmurray 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 @@ -45,19 +45,8 @@ send_mail_invalid_args_exc = "Both arguments are non-null."; sendmail_failed_exc = "Sendmail invocation failed"; tried_too_hard_exc = "Tried too hard to find a free filename."; -# Valid components; used by extract_component_from_section() because -# it doesn't know about Conf from it's caller. FIXME - -valid_components = { - "main": "", - "contrib": "", - "non-free": "" - }; - default_config = "/etc/katie/katie.conf"; default_apt_config = "/etc/katie/apt.conf"; -DefaultCnf = apt_pkg.newConfiguration(); -apt_pkg.ReadConfigFileISC(DefaultCnf,default_config); ###################################################################################### @@ -94,9 +83,6 @@ def str_isnum (s): ###################################################################################### -# Prefix and components hardcoded into this like a good'un; need to unhardcod at some -# stage. [FIXME] - def extract_component_from_section(section): component = ""; @@ -104,7 +90,7 @@ def extract_component_from_section(section): component = string.split(section, '/')[0]; if string.lower(component) == "non-us" and string.count(section, '/') > 0: s = string.split(section, '/')[1]; - if valid_components.has_key(s): # Avoid e.g. non-US/libs + if Cnf.has_key("Component::%s" % s): # Avoid e.g. non-US/libs component = string.split(section, '/')[0]+ '/' + string.split(section, '/')[1]; if string.lower(section) == "non-us": @@ -116,7 +102,7 @@ def extract_component_from_section(section): # Expand default component if component == "": - if valid_components.has_key(section): + if Cnf.has_key("Component::%s" % section): component = section; else: component = "main"; @@ -279,9 +265,6 @@ def fix_maintainer (maintainer): # sendmail wrapper, takes _either_ a message string or a file as arguments def send_mail (message, filename): - #### FIXME, how do I get this out of Cnf in katie? - sendmail_command = "/usr/sbin/sendmail -odq -oi -t"; - # Sanity check arguments if message != "" and filename != "": raise send_mail_invalid_args_exc; @@ -294,7 +277,7 @@ def send_mail (message, filename): os.close (fd); # Invoke sendmail - (result, output) = commands.getstatusoutput("%s < %s" % (sendmail_command, filename)); + (result, output) = commands.getstatusoutput("%s < %s" % (Cnf["Dinstall::SendmailCommand"], filename)); if (result != 0): raise sendmail_failed_exc, output; @@ -366,7 +349,7 @@ def copy (src, dest, overwrite = 0): def where_am_i (): res = socket.gethostbyaddr(socket.gethostname()); - database_hostname = DefaultCnf.get("Config::" + res[0] + "::DatabaseHostname"); + database_hostname = Cnf.get("Config::" + res[0] + "::DatabaseHostname"); if database_hostname: return database_hostname; else: @@ -374,15 +357,15 @@ def where_am_i (): def which_conf_file (): res = socket.gethostbyaddr(socket.gethostname()); - if DefaultCnf.get("Config::" + res[0] + "::KatieConfig"): - return DefaultCnf["Config::" + res[0] + "::KatieConfig"] + if Cnf.get("Config::" + res[0] + "::KatieConfig"): + return Cnf["Config::" + res[0] + "::KatieConfig"] else: return default_config; def which_apt_conf_file (): res = socket.gethostbyaddr(socket.gethostname()); - if DefaultCnf.get("Config::" + res[0] + "::AptConfig"): - return DefaultCnf["Config::" + res[0] + "::AptConfig"] + if Cnf.get("Config::" + res[0] + "::AptConfig"): + return Cnf["Config::" + res[0] + "::AptConfig"] else: return default_apt_config; @@ -511,3 +494,18 @@ def result_join (original, sep = '\t'): return string.join(list, sep); ################################################################################ + +def get_conf(): + return Cnf; + +################################################################################ + +apt_pkg.init() + +Cnf = apt_pkg.newConfiguration(); +apt_pkg.ReadConfigFileISC(Cnf,default_config); + +if which_conf_file() != default_config: + apt_pkg.ReadConfigFileISC(Cnf,which_conf_file()) + +################################################################################ diff --git a/ziyi b/ziyi index f9642af8..81db8cdb 100755 --- a/ziyi +++ b/ziyi @@ -3,7 +3,7 @@ # Create all the Release files # Copyright (C) 2001 Anthony Towns -# $Id: ziyi,v 1.9 2001-11-04 22:33:22 troup Exp $ +# $Id: ziyi,v 1.10 2001-11-18 19:57:58 rmurray 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 @@ -90,18 +90,15 @@ def main (): global Cnf, AptCnf, projectB, out out = sys.stdout; - - apt_pkg.init() - - Cnf = apt_pkg.newConfiguration() - apt_pkg.ReadConfigFileISC(Cnf,utils.which_conf_file()) + Cnf = utils.get_conf() AptCnf = apt_pkg.newConfiguration() apt_pkg.ReadConfigFileISC(AptCnf,utils.which_apt_conf_file()) Arguments = [('h',"help","Ziyi::Options::Help")]; for i in [ "help" ]: - Cnf["Ziyi::Options::%s" % (i)] = ""; + if not Cnf.has_key("Ziyi::Options::%s" % (i)): + Cnf["Ziyi::Options::%s" % (i)] = ""; suites = apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv) Options = Cnf.SubTree("Ziyi::Options") -- 2.39.5