pf-tools commit: r537 [ccaillet-guest] - in /trunk: debian/changelog lib/PFTools/Update.pm sbin/update-config
parmelan-guest at users.alioth.debian.org
parmelan-guest at users.alioth.debian.org
Mon Jun 18 13:21:57 UTC 2007
Author: ccaillet-guest
Date: Mon Jun 18 13:21:56 2007
New Revision: 537
URL: http://svn.debian.org/wsvn/pf-tools/?sc=1&rev=537
Log:
CHANGES:
* handling command line options for update-config on the script and not
on library Update.pm
CHANGELOG:
* adding entry
Modified:
trunk/debian/changelog
trunk/lib/PFTools/Update.pm
trunk/sbin/update-config
Modified: trunk/debian/changelog
URL: http://svn.debian.org/wsvn/pf-tools/trunk/debian/changelog?rev=537&op=diff
==============================================================================
--- trunk/debian/changelog (original)
+++ trunk/debian/changelog Mon Jun 18 13:21:56 2007
@@ -5,6 +5,8 @@
* Adding use strict and other devel tricks
* Some code cleaning
* adding pf-tools.links file for compatibility with previous version
+ * modifying update-config by moving Get_options, Do_help function on
+ Update.pm to update-config script (right place)
[ Thomas Parmelan ]
* lib-net: if no comment is specified in a zone, network or server
Modified: trunk/lib/PFTools/Update.pm
URL: http://svn.debian.org/wsvn/pf-tools/trunk/lib/PFTools/Update.pm?rev=537&op=diff
==============================================================================
--- trunk/lib/PFTools/Update.pm (original)
+++ trunk/lib/PFTools/Update.pm Mon Jun 18 13:21:56 2007
@@ -27,6 +27,8 @@
our @ISA = ( 'Exporter' ) ;
our @EXPORT = qw(
+ $ERR_OPEN
+
Get_source
Do_update
@@ -46,7 +48,7 @@
use Debconf::ConfModule;
# Error code
-my $ERR_OPEN = 1 ;
+our $ERR_OPEN = 1 ;
my $ERR_SYNTAX = 2 ;
$ENV{'PATH'} = $ENV{'PATH'} . ":/usr/local/sbin:/usr/local/bin";
@@ -1645,102 +1647,98 @@
}
sub Do_update {
- my (@options) = @_;
+ my ( $ref_options ) = @_;
my $C;
my $s;
- my $options;
+# my $options;
my @sortedkeys;
my $errorcount = 0;
-
-
-
- $options = Get_options(@options);
-
- if ( $options->{'help'} ) {
- Do_help();
- exit;
- }
+
+# if ( $ref_options->{'help'} ) {
+# Do_help();
+# exit;
+# }
my $branchecvs ;
# Si le demande a ma machine une branche precise
- $branchecvs = ($options->{"branche-cvs"})?$options->{"branche-cvs"}:GetBrancheFromCmdLine();
+ $branchecvs = ($ref_options->{"branche-cvs"})?$ref_options->{"branche-cvs"}:GetBrancheFromCmdLine();
# Sinon je repart sur celle d'avant
$branchecvs = GetRunningBrancheName() unless $branchecvs;
- if ( CVS_update($branchecvs, $options) || ( !( $C = Get_conf() ) ) ) {
+ if ( CVS_update($branchecvs, $ref_options) || ( !( $C = Get_conf() ) ) ) {
Abort( $ERR_OPEN, "Impossible de charger la configuration\n" );
}
SaveRunningBrancheName($branchecvs);
- if ( defined( $options->{'noupdate'} ) ) {
+ if ( defined( $ref_options->{'noupdate'} ) ) {
Abort( $ERR_OPEN, "Configuration desactivee [noupdate]" );
}
@sortedkeys = sort { Trie_dependances( $C, $a, $b ) } keys %$C;
$| = 1;
- $errorcount = Do_updateloop( $C, $options, @sortedkeys );
+ $errorcount = Do_updateloop( $C, $ref_options, @sortedkeys );
Log( $errorcount . " error(s) detected." );
FlushLog();
}
-sub Do_help {
-
- print STDERR << "# ENDHELP";
-Usage: $0 [options]
-# -d --debug: print debug info
- -u --diff: diff files, versions, mountpoints, links => --simul
- -h --help: print help and exit
-# -i --install: install mode
- -s --simul: simulation mode, fake everything
- -v --verbose: be more verbose
- --branche-cvs=: update based on a specific CVS branche.
-
-# ENDHELP
-}
-
-sub Get_options {
- my (@argv) = @_;
-
- my %optionshash;
- my $options;
-
- Getopt::Long::Configure("bundling");
-
- $optionshash{"branche-cvs"}='';
- GetOptions(
- \%optionshash, 'debug|d', 'diff|u', 'help|h',
- 'install|i', 'simul|s', 'verbose|v', 'quiet|q',
- 'noupdate', 'noaction', 'branche-cvs=s'
- ) or die "GetOptions error, try --help: " . $!;
-
- $options = \%optionshash;
-
- if ( $options->{'quiet'} ) {
- Log("update-config started in quiet mode...");
- $DEFERREDLOG = 1;
- }
-
- if ( $options->{'diff'} ) {
- $options->{'simul'} = 1;
- }
-
- if ( defined( $ARGV[0] ) && $ARGV[0] eq ':NO-ACTION:' ) {
- Warn( $ERR_OPEN, ":NO-ACTION: depreciated, please use --noaction" );
- $options->{'noaction'} = 1;
- }
- if ( defined( $ARGV[0] ) && $ARGV[0] eq ':NO-UPDATE:' ) {
- Warn( $ERR_OPEN, ":NO-UPDATE: depreciated, please use --noupdate" );
- $options->{'noupdate'} = 1;
- }
-
- return $options;
-}
+# sub Do_help {
+#
+# print STDERR << "# ENDHELP";
+# Usage: $0 [options]
+# # -d --debug: print debug info
+# -u --diff: diff files, versions, mountpoints, links => --simul
+# -h --help: print help and exit
+# # -i --install: install mode
+# -s --simul: simulation mode, fake everything
+# -v --verbose: be more verbose
+# --branche-cvs=: update based on a specific CVS branche.
+#
+# # ENDHELP
+# }
+#
+# sub Get_options {
+# my (@argv) = @_;
+#
+# my %optionshash;
+# my $options;
+#
+# Getopt::Long::Configure("bundling");
+#
+# $optionshash{"branche-cvs"}='';
+# GetOptions(
+# \%optionshash, 'debug|d', 'diff|u', 'help|h',
+# 'install|i', 'simul|s', 'verbose|v', 'quiet|q',
+# 'noupdate', 'noaction', 'branche-cvs=s'
+# ) or die "GetOptions error, try --help: " . $!;
+#
+# $options = \%optionshash;
+#
+# if ( $options->{'quiet'} ) {
+# Log("update-config started in quiet mode...");
+# $DEFERREDLOG = 1;
+# }
+#
+# if ( $options->{'diff'} ) {
+# $options->{'simul'} = 1;
+# }
+#
+# if ( defined( $ARGV[0] ) && $ARGV[0] eq ':NO-ACTION:' ) {
+# Warn( $ERR_OPEN, ":NO-ACTION: depreciated, please use --noaction" );
+# $options->{'noaction'} = 1;
+# }
+# if ( defined( $ARGV[0] ) && $ARGV[0] eq ':NO-UPDATE:' ) {
+# Warn( $ERR_OPEN, ":NO-UPDATE: depreciated, please use --noupdate" );
+# $options->{'noupdate'} = 1;
+# }
+#
+# return $options;
+# }
sub Get_conf {
Modified: trunk/sbin/update-config
URL: http://svn.debian.org/wsvn/pf-tools/trunk/sbin/update-config?rev=537&op=diff
==============================================================================
--- trunk/sbin/update-config (original)
+++ trunk/sbin/update-config Mon Jun 18 13:21:56 2007
@@ -21,8 +21,78 @@
use strict;
use warnings;
+use Getopt::Long qw( :config ignore_case_always bundling ) ;
+use PFTools::Update ;
+use PFTools::Conf ;
-use PFTools::Update;
+my $program = $0;
+$program =~ s%.*/%%; # cheap basename
-Do_update(@ARGV);
+my $version = sprintf( "svn-r%s", q$Revision$ =~ /([\d.]+)/ ) ;
+sub Do_help {
+
+ print STDERR << "# ENDHELP";
+ $program - version $version
+
+Usage: $0 [options]
+# -d --debug: print debug info
+ -u --diff: diff files, versions, mountpoints, links => --simul
+ -h --help: print help and exit
+# -i --install: install mode
+ -s --simul: simulation mode, fake everything
+ -v --verbose: be more verbose
+ --branche-cvs=: update based on a specific CVS branche.
+
+# ENDHELP
+}
+
+my %optionshash;
+my $options = {} ;
+$options->{'branche-cvs'} = '' ;
+$options->{'diff'} = 0 ;
+$options->{'help'} = 0 ;
+$options->{'simul'} = 0 ;
+$options->{'verbose'} = 0 ;
+$options->{'quiet'} = 0 ;
+$options->{'noupdate'} = 0 ;
+$options->{'noaction'} = 0 ;
+
+GetOptions(
+ 'debug|d' => \$options->{'debug'},
+ 'diff|u' => \$options->{'diff'},
+ 'help|h' => \$options->{'help'},
+ 'install|i' => \$options->{'install'},
+ 'simul|s' => \$options->{'simul'},
+ 'verbose|v' => \$options->{'verbose'},
+ 'quiet|q' => \$options->{'quiet'},
+ 'noupdate' => \$options->{'noupdate'},
+ 'noaction' => \$options->{'noaction'},
+ 'branche-cvs=s' => \$options->{'branche-cvs'}
+) or die "GetOptions error, try --help: " . $!;
+
+if ( $options->{'help'} ) {
+ Do_help();
+ exit;
+}
+
+if ( $options->{'quiet'} ) {
+ Log("update-config started in quiet mode...");
+ $DEFERREDLOG = 1;
+}
+
+if ( $options->{'diff'} ) {
+ $options->{'simul'} = 1;
+}
+
+if ( defined( $ARGV[0] ) && $ARGV[0] eq ':NO-ACTION:' ) {
+ Warn( $ERR_OPEN, ":NO-ACTION: depreciated, please use --noaction" );
+ $options->{'noaction'} = 1;
+}
+if ( defined( $ARGV[0] ) && $ARGV[0] eq ':NO-UPDATE:' ) {
+ Warn( $ERR_OPEN, ":NO-UPDATE: depreciated, please use --noupdate" );
+ $options->{'noupdate'} = 1;
+}
+
+Do_update( $options ) ;
+
More information about the Pf-tools-commits
mailing list