Hi Joey, hi *, Am Mon, 25 Jun 2012 12:13:10 -0400 schrieb Joey Hess <jo...@debian.org>:
> Matthias Schmitz wrote: > > arg, you are right. Is it ok to leave the old behavior (cli switch > > override configuration file setting) and add a warning to the > > --config-file switch that other cli switches will be ignored? > > The --config-file could *add* the specified file. Keep it reading > debmirror.conf before options, and then it could be used for setting > defaults that could be overridden by options and --config-file thanks for the quick reply :-). With the attached patch the default behavior is untouched (require debmirror.conf before cli switches) and the file read with --config-file is additional. But it still overrides all cli switches. Best wishes, Matthias
From e2929b2c06c47b9df0c383c5ebcd84312b47fa5b Mon Sep 17 00:00:00 2001 From: Matthias Schmitz <matth...@sigxcpu.org> Date: Mon, 25 Jun 2012 20:41:21 +0200 Subject: [PATCH] Add switch to specify an additional configuration file at command line. --- debmirror | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/debmirror b/debmirror index ccb4fbd..f8b7da2 100755 --- a/debmirror +++ b/debmirror @@ -412,6 +412,14 @@ debmirror cleanup is disabled when this flag is specified. Separate pool and snapshot cleanup utilities are available at http://code.google.com/p/debmarshal/source/browse/#svn/trunk/repository2 +=item B<--config-file> + +Specify an additional configuration file. By default debmirror reads +/etc/debmirror.conf and ~/.debmirror.conf (see section FILES). + +WARNING: All parameters set in a configuration file specified with +--config-file cannot be overridden by a command line switch. + =back =head1 USING DEBMIRROR @@ -575,6 +583,7 @@ our $debmarshal=0; our $slow_cpu=0; our $check_gpg=1; our $new_mirror=0; +our $config_file=undef; my @errlog; my $HOME; ($HOME = $ENV{'HOME'}) or die "HOME not defined in environment!\n"; @@ -674,10 +683,20 @@ GetOptions('debug' => \$debug, 'debmarshal' => \$debmarshal, 'slow-cpu' => \$slow_cpu, 'help' => \$help, + 'config-file=s' => \$config_file, ) or usage; usage if $help; usage("invalid number of arguments") if $ARGV[1]; +# Load in additional config file +if ( defined $config_file ) { + if ( -r $config_file ) { + require $config_file; + } else { + die "Cannot open config file $config_file."; + } +} + # This parameter is so important that it is the only required parameter, # unless specified in a configuration file. $mirrordir = shift if $ARGV[0]; -- 1.7.10
signature.asc
Description: PGP signature