pf-tools/pf-tools: 13 new changesets
parmelan-guest at users.alioth.debian.org
parmelan-guest at users.alioth.debian.org
Wed Oct 13 08:38:30 UTC 2010
details: http://hg.debian.org/hg/pf-tools/pf-tools/rev/c597492337af
changeset: 874:c597492337af
user: "Christophe Caillet <quadchris at free.fr>"
date: Mon Oct 11 18:33:16 2010 +0200
description:
Coding style and remove useless use of PFTools::Logger
details: http://hg.debian.org/hg/pf-tools/pf-tools/rev/48fc6c105600
changeset: 875:48fc6c105600
user: "Christophe Caillet <quadchris at free.fr>"
date: Mon Oct 11 18:38:28 2010 +0200
description:
Coding style and remove useless us of PFTools::Logger
details: http://hg.debian.org/hg/pf-tools/pf-tools/rev/c883f2eadfb8
changeset: 876:c883f2eadfb8
user: "Christophe Caillet <quadchris at free.fr>"
date: Mon Oct 11 18:45:30 2010 +0200
description:
Coding style: avoid unless with a negative expression
details: http://hg.debian.org/hg/pf-tools/pf-tools/rev/3ebe9240d94a
changeset: 877:3ebe9240d94a
user: "Christophe Caillet <quadchris at free.fr>"
date: Mon Oct 11 18:48:46 2010 +0200
description:
Coding style and remove useless use of PFTools::Logger
details: http://hg.debian.org/hg/pf-tools/pf-tools/rev/4bdabea17a30
changeset: 878:4bdabea17a30
user: "Christophe Caillet <quadchris at free.fr>"
date: Mon Oct 11 19:07:45 2010 +0200
description:
Coding style and remove useless parameter in Do_update_from_GLOBAL
details: http://hg.debian.org/hg/pf-tools/pf-tools/rev/b8734604fad3
changeset: 879:b8734604fad3
user: "Christophe Caillet <quadchris at free.fr>"
date: Mon Oct 11 19:08:29 2010 +0200
description:
Coding style and remove useless uses, removing useless parameters when calling Do_update_from_GLOBAL
details: http://hg.debian.org/hg/pf-tools/pf-tools/rev/0adac7acf5e5
changeset: 880:0adac7acf5e5
user: "Christophe Caillet <quadchris at free.fr>"
date: Mon Oct 11 19:12:08 2010 +0200
description:
Coding style and remove useless use of PFTools::Logger
details: http://hg.debian.org/hg/pf-tools/pf-tools/rev/8a179cd1cb36
changeset: 881:8a179cd1cb36
user: "Christophe Caillet <quadchris at free.fr>"
date: Mon Oct 11 19:17:36 2010 +0200
description:
Coding style and remove useless PFTools::Logger
details: http://hg.debian.org/hg/pf-tools/pf-tools/rev/05b4f120935b
changeset: 882:05b4f120935b
user: "Christophe Caillet <quadchris at free.fr>"
date: Mon Oct 11 19:28:30 2010 +0200
description:
Coding style and remove useless PFTools::Logger and normalize parameters name according to sbin/*
details: http://hg.debian.org/hg/pf-tools/pf-tools/rev/99987da2c12a
changeset: 883:99987da2c12a
user: "Christophe Caillet <quadchris at free.fr>"
date: Mon Oct 11 19:31:00 2010 +0200
description:
Coding style and remove useless PFTools::Logger
details: http://hg.debian.org/hg/pf-tools/pf-tools/rev/3eb0e1e56a84
changeset: 884:3eb0e1e56a84
user: "Christophe Caillet <quadchris at free.fr>"
date: Mon Oct 11 19:31:46 2010 +0200
description:
Ooops forget this use :)
details: http://hg.debian.org/hg/pf-tools/pf-tools/rev/e68eb0981ae5
changeset: 885:e68eb0981ae5
user: "Christophe Caillet <quadchris at free.fr>"
date: Mon Oct 11 19:34:28 2010 +0200
description:
Coding style and remove usless PFTools::Logger
details: http://hg.debian.org/hg/pf-tools/pf-tools/rev/824a6d6ed01b
changeset: 886:824a6d6ed01b
user: "Christophe Caillet <quadchris at free.fr>"
date: Wed Oct 13 10:21:09 2010 +0200
description:
Removing INSTALLERS
diffstat:
3 files changed, 3 insertions(+), 8 deletions(-)
filters/filter_privateresolve | 8 ++------
lib/PFTools/Utils.pm | 2 +-
sbin/update-config | 1 -
diffs (726 lines):
diff -r 1e8f98a59538 -r 824a6d6ed01b Makefile
--- a/Makefile Mon Oct 11 15:51:28 2010 +0200
+++ b/Makefile Wed Oct 13 10:21:09 2010 +0200
@@ -11,7 +11,6 @@
FILTERS=filters/*
LIB=lib/PFTools/*
TOOLS=tools/*
-INSTALLERS=installers/*
CONF=conf/*
TPL=templates/*
@@ -64,10 +63,6 @@
mkdir -p $(SBIN_DIR)
install --owner=root --group=root --mode=0755 $(TOOLS) $(SBIN_DIR)
- # PFHost installers
- mkdir -p $(INSTALLERS_DIR)
- install --owner=root --group=root --mode=0755 $(INSTALLERS) $(INSTALLERS_DIR)
-
# PFHost config files sample
install -d $(DESTDIR)/usr/share/doc/pf-host/
install $(DOC_HOST) $(DESTDIR)/usr/share/doc/pf-host/
diff -r 1e8f98a59538 -r 824a6d6ed01b filters/filter_distrib
--- a/filters/filter_distrib Mon Oct 11 15:51:28 2010 +0200
+++ b/filters/filter_distrib Wed Oct 13 10:21:09 2010 +0200
@@ -26,7 +26,6 @@
use IO::File;
use Sys::Hostname;
-use PFTools::Logger;
use PFTools::Structqueries;
use PFTools::Utils;
@@ -90,26 +89,12 @@
);
unless( $options->{'site'} ) {
- unless( $PF_CONFIG->{'location'}->{'site'} ) {
- my $site_list = Get_site_from_hostname(
- $options->{'host'}, $GLOBAL_STRUCT
- );
- unless( $site_list ) {
- Abort( $CODE->{'UNDEF_KEY'},
- "Unknown hostname $options->{'host'}" );
- }
- if ( scalar @{$site_list} > 1 ) {
- Abort( $CODE->{'DUPLICATE_VALUE'},
- "Multiple sites for hostname $options->{'host'}" );
- }
- ($options->{'site'}) = @{$site_list};
- }
- $options->{'site'} = $PF_CONFIG->{'location'}->{'site'};
+ $options->{'site'} = $PF_CONFIG->{'location'}->{'site'}
+ || Get_uniq_site_from_hostname( $options->{'host'}, $GLOBAL_STRUCT );
}
if ( $options->{'input'} eq '' || $options->{'output'} eq '' ) {
- Abort( $CODE->{'UNDEF_KEY'},
- "Source and/or destination file is(are) not defined on CLI" );
+ die "Source and/or destination file is(are) not defined on CLI";
}
my $filtered_src = Search_and_replace(
@@ -118,19 +103,14 @@
$PF_CONFIG, "", $GLOBAL_STRUCT
);
-my $output_fh = IO::File->new ( ">" . $options->{'output'} );
-unless( $output_fh ) {
- Abort( $CODE->{'OPEN'},
- "Unable to open destination $options->{'output'} : $OS_ERROR" );
-}
+my $output_fh = IO::File->new ( ">" . $options->{'output'} )
+ or die "Unable to open destination $options->{'output'} : $OS_ERROR";
$output_fh->print( join( "", @{$filtered_src} ) )
- or Abort( $CODE->{'OPEN'},
- "Unable to write on destination $options->{'output'} : $OS_ERROR" );
+ or die "Unable to write on destination $options->{'output'} : $OS_ERROR";
$output_fh->close()
- or Abort( $CODE->{'OPEN'},
- "Unable to close destination $options->{'output'} : $OS_ERROR" );
+ or die "Unable to close destination $options->{'output'} : $OS_ERROR";
exit 0;
diff -r 1e8f98a59538 -r 824a6d6ed01b filters/filter_privateresolve
--- a/filters/filter_privateresolve Mon Oct 11 15:51:28 2010 +0200
+++ b/filters/filter_privateresolve Wed Oct 13 10:21:09 2010 +0200
@@ -28,30 +28,29 @@
use Getopt::Long qw( :config ignore_case_always bundling );
use Sys::Hostname;
-use PFTools::Logger;
use PFTools::Structqueries;
use PFTools::Utils;
#<<< please, perltidy, don't mess with this (keep each entry on its own line)
my @options_specifications = (
- 'config-file|config|c=s',
+ 'config|c=s',
'help',
- 'hostname|host|h=s',
- 'input-file|input|i=s',
- 'output-file|output|o=s',
- 'separator|sep=s',
+ 'host|h=s',
+ 'input|i=s',
+ 'output|o=s',
+ 'sep=s',
'site|s=s',
- 'store-file|store=s',
- 'type-resolve|type|t=s',
+ 'store=s',
+ 'type|t=s',
'zone|z=s',
);
#>>>
# default values
my $options = {
- 'help' => 0,
- 'hostname' => hostname,
- 'separator' => ' ',
- 'type-resolve' => 'cnf',
+ 'help' => 0,
+ 'host' => hostname,
+ 'sep' => ' ',
+ 'type' => 'cnf',
};
my $program = basename $PROGRAM_NAME;
@@ -64,16 +63,16 @@
Usage: $program [options]
--help : print help and exit
- -h --hostname : hostname for which we want to filter input
+ -h --host : hostname for which we want to filter input
-s --site : site on which hostname is defined (optional)
- -c --config-file : file where pf-tools configuration is stored
+ -c --config : file where pf-tools configuration is stored
e.g. /etc/pf-tools.conf (optional)
- --store-file : file where global structure datas are in
+ --store : file where global structure datas are in
storable format (optional)
-z --zone : zone on which we want to filter input
- -t --type-resolve : type for resolution. Allowed values are cnf
+ -t --type : type for resolution. Allowed values are cnf
(from global configuration structure) and dns
- --separator : separator between resolved IPs [default: space]
+ --sep : separator between resolved IPs [default: space]
-i --input : input file
-o --output : output file
@@ -91,47 +90,34 @@
exit 0;
}
-unless ( $options->{'input-file'} and $options->{'output-file'} ) {
- Abort( $CODE->{'UNDEF_KEY'},
- "Source and/or destination file is(are) not defined on CLI" );
+unless ( $options->{'input'} and $options->{'output'} ) {
+ die "Source and/or destination file is(are) not defined on CLI";
}
my ( $PF_CONFIG, $GLOBAL_STRUCT ) = Init_TOOLS(
- $options->{'hostname'},
- $options->{'config-file'},
- $options->{'store-file'}
+ $options->{'host'},
+ $options->{'config'},
+ $options->{'store'}
);
-# FIXME: make a (private) function to handle this?
unless ( $options->{'site'} ) {
- my $site = $PF_CONFIG->{'location'}->{'site'};
- unless ($site) {
- my $site_list = Get_site_from_hostname(
- $options->{'hostname'},
- $GLOBAL_STRUCT
- );
- unless ($site_list) {
- Abort( $CODE->{'UNDEF_KEY'},
- "Unknown hostname $options->{'hostname'}" );
- }
- if ( scalar @{$site_list} > 1 ) {
- Abort( $CODE->{'DUPLICATE_VALUE'},
- "Multiple sites for hostname $options->{'hostname'}" );
- }
- ($site) = @{$site_list};
- }
- $options->{'site'} = $site;
+ $options->{'site'} = $PF_CONFIG->{'location'}->{'site'}
+ || Get_uniq_site_from_hostname( $options->{'host'}, $GLOBAL_STRUCT );
}
-$options->{'zone'}
- = Get_zone_from_site_GLOBAL( $options->{'site'}, $GLOBAL_STRUCT )
- unless $options->{'zone'};
+$options->{'zone'} = Get_zone_from_site_GLOBAL(
+ $options->{'site'}, $GLOBAL_STRUCT
+) unless $options->{'zone'};
my $filtered_src = Search_and_replace(
- $options->{'hostname'}, $options->{'site'},
- $options->{'input-file'}, 'resolver',
- $PF_CONFIG, $options->{'separator'},
- $GLOBAL_STRUCT, $options->{'type-resolve'}
+ $options->{'host'},
+ $options->{'site'},
+ $options->{'input'},
+ 'resolver',
+ $PF_CONFIG,
+ $options->{'sep'},
+ $GLOBAL_STRUCT,
+ $options->{'type'}
);
# FIXME: functions with too many parameters should be converted
@@ -148,17 +134,13 @@
#};
#my $filtered_src = search_and_replace($args_ref);
-my $output_fh = IO::File->new("> $options->{'output-file'}")
- or Abort( $CODE->{'OPEN'},
- "Unable to open destination file $options->{'output-file'}: $OS_ERROR" );
+my $output_fh = IO::File->new( ">". $options->{'output'} )
+ or die "Unable to open destination $options->{'output'}: $OS_ERROR";
$output_fh->print( join '', @{$filtered_src} )
- or Abort( $CODE->{'OPEN'},
- "Unable to write to destination file $options->{'output-file'}: $OS_ERROR"
- );
+ or die "Unable to write to destination $options->{'output'}: $OS_ERROR";
$output_fh->close()
- or Abort( $CODE->{'OPEN'},
- "Unable to close destination file $options->{'output-file'}: $OS_ERROR" );
+ or die "Unable to close destination file $options->{'output'}: $OS_ERROR";
exit 0;
diff -r 1e8f98a59538 -r 824a6d6ed01b filters/filter_vlan2if
--- a/filters/filter_vlan2if Mon Oct 11 15:51:28 2010 +0200
+++ b/filters/filter_vlan2if Wed Oct 13 10:21:09 2010 +0200
@@ -32,7 +32,6 @@
use IO::File;
use Sys::Hostname;
-use PFTools::Logger;
use PFTools::Structqueries;
use PFTools::Utils;
@@ -95,27 +94,12 @@
);
unless( $options->{'site'} ) {
- unless( $PF_CONFIG->{'location'}->{'site'} ) {
- my $site_list = Get_site_from_hostname(
- $options->{'host'},
- $GLOBAL_STRUCT
- );
- unless( $site_list ) {
- Abort( $CODE->{'UNDEF_KEY'},
- "Unknown hostname $options->{'host'}" );
- }
- if ( scalar @{$site_list} > 1 ) {
- Abort( $CODE->{'DUPLICATE_VALUE'},
- "Multiple sites for hostname $options->{'host'}" );
- }
- ($options->{'site'}) = @{$site_list};
- }
- $options->{'site'} = $PF_CONFIG->{'location'}->{'site'};
+ $options->{'site'} = $PF_CONFIG->{'location'}->{'site'}
+ || Get_uniq_site_from_hostname( $options->{'host'}, $GLOBAL_STRUCT );
}
if ( $options->{'input'} eq '' || $options->{'output'} eq '' ) {
- Abort( $CODE->{'UNDEF_KEY'},
- "Source and/or destination file is(are) not defined on CLI" );
+ die "Source and/or destination file is(are) not defined on CLI";
}
my $filtered_src = Search_and_replace(
@@ -129,14 +113,11 @@
);
my $output_fh = IO::File->new( ">" . $options->{'output'} )
- or Abort( $CODE->{'OPEN'},
- "Unable to open destination $options->{'output'} : $OS_ERROR" );
+ or die "Unable to open destination $options->{'output'} : $OS_ERROR";
$output_fh->print( join( "", @{$filtered_src} ) )
- or Abort( $CODE->{'OPEN'},
- "Unable to write on destination $options->{'output'} : $OS_ERROR" );
+ or die "Unable to write on destination $options->{'output'} : $OS_ERROR";
$output_fh->close()
- or Abort( $CODE->{'OPEN'},
- "Unable to close destination $options->{'output'} : $OS_ERROR" );
+ or die "Unable to close destination $options->{'output'} : $OS_ERROR";
exit 0;
diff -r 1e8f98a59538 -r 824a6d6ed01b lib/PFTools/Utils.pm
--- a/lib/PFTools/Utils.pm Mon Oct 11 15:51:28 2010 +0200
+++ b/lib/PFTools/Utils.pm Wed Oct 13 10:21:09 2010 +0200
@@ -1029,11 +1029,11 @@
$section, $options
);
if ( defined( $host_config->{$section}->{'depends'} )
- && $host_config->{$section}->{'depends'} =~ /\S+/ )
+ && $host_config->{$section}->{'depends'} =~ m{\S+} )
{
my $depends = [];
my @dependsraw
- = split( /\s+/, $host_config->{$section}->{'depends'} );
+ = split( m{\s+}, $host_config->{$section}->{'depends'} );
foreach my $depend (@dependsraw) {
next if ( $depend eq "." );
if ( defined($depend)
@@ -1069,7 +1069,7 @@
$hash_subst, $global_config, $depends );
}
}
- print "[" . $section . "]" if ( ! $options->{'quiet'} );
+ print "[" . $section . "]\n" if ( ! $options->{'quiet'} );
$errorcount++ if( ! Exec_action(
$host_config->{$section}->{'action'},
$host_config->{$section},
@@ -1092,14 +1092,21 @@
return $errorcount;
}
-sub Do_update_from_GLOBAL ($$$$$) {
- my ( $hostname, $site, $options, $global_config, $pf_config ) = @_;
+sub Do_update_from_GLOBAL {
+ my ( $options, $global_config, $pf_config ) = @_;
my $errorcount = 0;
+ my $hostname = $options->{'host'};
+ unless( $hostname ) {
+ croak q{ERROR: undefined option host};
+ }
+ my $site = $options->{'site'};
+ unless( $site ) {
+ croak q{ERROR: undefined option site};
+ }
# Set_deferredlog();
if ( !VCS_checkout( $hostname, $pf_config, $options ) ) {
- Abort( $CODE->{'EXEC'},
- "Unable to checkout configuration from VCS system" );
+ croak q{ERROR: "Unable to checkout configuration from VCS system"};
}
# Unset_deferredlog();
my $hosttype = Get_hosttype_from_hostname(
diff -r 1e8f98a59538 -r 824a6d6ed01b lib/PFTools/VCS/CVS.pm
--- a/lib/PFTools/VCS/CVS.pm Mon Oct 11 15:51:28 2010 +0200
+++ b/lib/PFTools/VCS/CVS.pm Wed Oct 13 10:21:09 2010 +0200
@@ -69,7 +69,7 @@
$ENV{'CVS_RSH'} = $pf_config->{'vcs'}->{'rsh'}
if ( $pf_config->{'vcs'}->{'method'} eq 'rsh' );
- unless ( $cvs_cmd ne "" ) {
+ if( $cvs_cmd eq "" ) {
if ( $hostname =~ /^$pf_config->{'regex'}->{'deploy_hosts'}/ ) {
$cvs_cmd = "/usr/bin/cvs -R -d '";
}
diff -r 1e8f98a59538 -r 824a6d6ed01b sbin/mk_pxelinuxcfg
--- a/sbin/mk_pxelinuxcfg Mon Oct 11 15:51:28 2010 +0200
+++ b/sbin/mk_pxelinuxcfg Wed Oct 13 10:21:09 2010 +0200
@@ -28,7 +28,6 @@
use Getopt::Long qw( :config ignore_case_always bundling );
use File::Path qw( make_path );
-use PFTools::Logger;
use PFTools::Utils;
############################################
@@ -101,15 +100,13 @@
= $PF_CONFIG->{'path'}->{'preseed_dir'} . "/default_preseed.txt";
unless( $options->{'site'} ) {
unless( $PF_CONFIG->{'location'}->{'site'} ) {
- Abort( $CODE->{'UNDEF_KEY'},
- "A site MUST BE defined for building DNS zone forward" );
+ die "A site MUST BE defined for building DNS zone forward";
}
$options->{'site'} = $PF_CONFIG->{'location'}->{'site'};
}
unless( $GLOBAL_STRUCT->{'DHCP'}->{'BY_SITE'}->{$options->{'site'}} ) {
- Abort( $CODE->{'UNDEF_KEY'},
- "Unknown site $options->{'site'}" );
+ die "Unknown site $options->{'site'}";
}
my $site_part = $GLOBAL_STRUCT->{'SITE'}->{'BY_NAME'}->{$options->{'site'}};
diff -r 1e8f98a59538 -r 824a6d6ed01b sbin/mk_resolvconf
--- a/sbin/mk_resolvconf Mon Oct 11 15:51:28 2010 +0200
+++ b/sbin/mk_resolvconf Wed Oct 13 10:21:09 2010 +0200
@@ -27,7 +27,6 @@
use Getopt::Long qw( :config ignore_case_always bundling );
use Sys::Hostname;
-use PFTools::Logger;
use PFTools::Structqueries;
use PFTools::Utils;
@@ -89,22 +88,8 @@
);
unless( $options->{'site'} ) {
- unless( $PF_CONFIG->{'location'}->{'site'} ) {
- my $site_list = Get_site_from_hostname(
- $options->{'host'},
- $GLOBAL_STRUCT
- );
- unless( $site_list ) {
- Abort( $CODE->{'UNDEF_KEY'},
- "Unknown hostname $options->{'host'}" );
- }
- if ( scalar @{$site_list} > 1 ) {
- Abort( $CODE->{'DUPLICATE_VALUE'},
- "$options->{'host'} hostname appeared in multiple sites" );
- }
- ( $options->{'site'} ) = @{$site_list};
- }
- $options->{'site'} = $PF_CONFIG->{'location'}->{'site'};
+ $options->{'site'} = $PF_CONFIG->{'location'}->{'site'}
+ || Get_uniq_site_from_hostname( $options->{'host'}, $GLOBAL_STRUCT );
}
unless(
@@ -115,8 +100,7 @@
$options->{'output'}
)
) {
- Abort( $CODE->{'EXEC'},
- "An error occured during build of file " . $options->{'output'} );
+ die "An error occured during build of file $options->{'output'}";
}
exit 0;
diff -r 1e8f98a59538 -r 824a6d6ed01b sbin/mk_sitezone
--- a/sbin/mk_sitezone Mon Oct 11 15:51:28 2010 +0200
+++ b/sbin/mk_sitezone Wed Oct 13 10:21:09 2010 +0200
@@ -26,7 +26,6 @@
use Getopt::Long qw( :config ignore_case_always bundling );
use IO::File;
-use PFTools::Logger;
use PFTools::Utils;
#################################
@@ -84,16 +83,12 @@
);
unless( $options->{'site'} ) {
- unless( $PF_CONFIG->{'location'}->{'site'} ) {
- Abort( $CODE->{'UNDEF_KEY'},
- "A site MUST BE defined for building DNS zone forward" );
- }
- $options->{'site'} = $PF_CONFIG->{'location'}->{'site'};
+ $options->{'site'} = $PF_CONFIG->{'location'}->{'site'}
+ or die "A site MUST BE defined for building DNS zone forward";
}
unless ( $GLOBAL_STRUCT->{'DHCP'}->{'BY_SITE'}->{$options->{'site'}} ) {
- Abort( $CODE->{'UNDEF_KEY'},
- "Site $options->{'site'} is not defined into global configuration" );
+ die "Site $options->{'site'} is not defined into global configuration";
}
my $zone = Mk_zone_for_site(
@@ -103,13 +98,10 @@
);
my $output_fh = IO::File->new ( '>' . $options->{'output'} )
- or Abort( $CODE->{'OPEN'},
- "Unable to open destination $options->{'output'} : $OS_ERROR" );
+ or die "Unable to open destination $options->{'output'} : $OS_ERROR";
$output_fh->print( join "\n", @{$zone} )
- or Abort( $CODE->{'OPEN'},
- "Unable to write on destination $options->{'output'} : $OS_ERROR" );
+ or die "Unable to write on destination $options->{'output'} : $OS_ERROR";
$output_fh->close()
- or Abort( $CODE->{'OPEN'},
- "Unable to close destination$options->{'output'} : $OS_ERROR" );
+ or die "Unable to close destination$options->{'output'} : $OS_ERROR";
exit 0;
diff -r 1e8f98a59538 -r 824a6d6ed01b sbin/mk_sourceslist
--- a/sbin/mk_sourceslist Mon Oct 11 15:51:28 2010 +0200
+++ b/sbin/mk_sourceslist Wed Oct 13 10:21:09 2010 +0200
@@ -26,7 +26,6 @@
use Getopt::Long qw( :config ignore_case_always bundling );
use Sys::Hostname;
-use PFTools::Logger;
use PFTools::Structqueries;
use PFTools::Utils;
@@ -118,8 +117,7 @@
}
unless( $options->{'host'} ) {
- Abort( $CODE->{'UNDEF_KEY'},
- "Unable to build sources.list for an undefined hostname" );
+ die "Unable to build sources.list for an undefined hostname";
}
( $PF_CONFIG, $GLOBAL_STRUCT ) = Init_TOOLS(
@@ -129,28 +127,14 @@
);
unless( $options->{'site'} ) {
- unless( $PF_CONFIG->{'location'}->{'site'} ) {
- my $site_list = Get_site_from_hostname(
- $options->{'host'},
- $GLOBAL_STRUCT
- );
- unless( $site_list ) {
- Abort( $CODE->{'UNDEF_KEY'},
- "Unknown hostname $options->{'host'}" );
- }
- if ( scalar @{$site_list} > 1 ) {
- Abort( $CODE->{'DUPLICATE_VALUE'},
- "Multiple site for $options->{'host'}" );
- }
- ($options->{'site'}) = @{$site_list};
- }
- $options->{'site'} = $PF_CONFIG->{'location'}->{'site'};
+ $options->{'site'} = $PF_CONFIG->{'location'}->{'site'}
+ || Get_uniq_site_from_hostname( $options->{'host'}, $GLOBAL_STRUCT );
}
-$options->{'add'} =~ s/,/ /g;
+$options->{'add'} =~ s{,}{ }g;
$SECTIONS .= " " . $options->{'add'};
-$SECTIONS =~ s/^\s*//; # Removing trailing space(s)
-if( !
+$SECTIONS =~ s{\A \s*}{}xms; # Removing trailing space(s)
+unless(
Mk_sourceslist(
$options->{'host'},
$options->{'site'},
@@ -162,7 +146,7 @@
$PF_CONFIG
)
) {
- warn q{ERROR: An error occured during sources.list generation};
+ die q{ERROR: An error occured during sources.list generation};
}
exit 0;
diff -r 1e8f98a59538 -r 824a6d6ed01b sbin/update-config
--- a/sbin/update-config Mon Oct 11 15:51:28 2010 +0200
+++ b/sbin/update-config Wed Oct 13 10:21:09 2010 +0200
@@ -28,8 +28,6 @@
use Getopt::Long qw( :config ignore_case_always bundling );
use Sys::Hostname;
-use PFTools::Conf;
-use PFTools::Logger;
use PFTools::Structqueries;
use PFTools::Utils;
@@ -40,6 +38,29 @@
my $program = basename $PROGRAM_NAME;
+my @options_specs = (
+ 'branch=s',
+ 'debug|d',
+ 'diff|u',
+ 'force-reload|f',
+ 'help',
+ 'install|i',
+ 'noaction',
+ 'noupdate',
+ 'quiet|q',
+ 'simul|s',
+ 'pkg_type|p=s',
+ 'verbose|v',
+ 'config|c=s',
+ 'store=s',
+ 'host|h=s',
+ 'site=s'
+);
+
+my $options = {
+ 'help' => 0,
+ 'host' => hostname,
+};
###################################
# Funtions
@@ -69,83 +90,43 @@
### MAIN
# All options are disabled by default
-my $options = {};
-GetOptions(
- $options, 'branch=s', 'debug|d', 'diff|u',
- 'force-reload|f', 'help', 'install|i', 'noaction',
- 'noupdate', 'quiet|q', 'simul|s', 'pkg_type|p=s',
- 'verbose|v', 'config|c=s', 'store=s', 'host|h=s',
- 'site=s'
-) or die "GetOptions error, try --help: $!\n";
+GetOptions( @options_specs, $options )
+ or die "GetOptions error, try --help: $!\n";
if ( $options->{'help'} ) {
Do_help();
exit 0;
}
-$options->{'store'} = "" if ( !defined $options->{'store'} );
-my $HOSTNAME = $options->{'host'} || hostname;
-my $SITE = $options->{'site'};
+$options->{'store'} = "" unless( $options->{'store'} );
( $PF_CONFIG, $GLOBAL_STRUCT ) = Init_TOOLS(
- $HOSTNAME,
+ $options->{'host'},
$options->{'config'},
$options->{'store'},
$options->{'force-reload'}
);
#### VERIFYING UPDATE FEATURE IN PF-TOOLS CONFIG ABORTING IF DEACTIVATED !!!
-if ( !$PF_CONFIG->{'features'}->{'update'} ) {
- Abort( $CODE->{'OK'},
- "update-config command has been deactivated in pf-tools.conf"
- );
+unless( $PF_CONFIG->{'features'}->{'update'} ) {
+ die "update-config command has been deactivated in pf-tools.conf";
}
-unless( $SITE ) {
- unless( $PF_CONFIG->{'location'}->{'site'} ) {
- my $site_list = Get_site_from_hostname( $HOSTNAME, $GLOBAL_STRUCT );
- unless( $site_list ) {
- Abort( $CODE->{'UNDEF_KEY'},
- "Unknown hostname $HOSTNAME" );
- }
- if ( scalar @{$site_list} > 1 ) {
- Abort( $CODE->{'DUPLICATE_VALUE'},
- "Multiple site declaration for $HOSTNAME" );
- }
- ($SITE) = @{$site_list};
- }
- $SITE = $PF_CONFIG->{'location'}->{'site'};
-}
-
-if ( $options->{'help'} ) {
- Do_help();
- exit;
+unless( $options->{'site'} ) {
+ $options->{'site'} = $PF_CONFIG->{'location'}->{'site'}
+ || Get_uniq_site_from_hostname( $options->{'host'}, $GLOBAL_STRUCT );
}
if ( $options->{'quiet'} ) {
- Log("update-config started in quiet mode...");
- Set_deferredlog();
+ print "update-config started in quiet mode...\n";
}
$options->{'simul'} = 1 if ( $options->{'diff'} );
-if ( defined( $ARGV[0] ) && $ARGV[0] eq ':NO-ACTION:' ) {
- Warn( $CODE->{'OPEN'}, ":NO-ACTION: depreciated, please use --noaction" );
- $options->{'noaction'} = 1;
-}
-if ( defined( $ARGV[0] ) && $ARGV[0] eq ':NO-UPDATE:' ) {
- Warn( $CODE->{'OPEN'}, ":NO-UPDATE: depreciated, please use --noupdate" );
- $options->{'noupdate'} = 1;
-}
-
Do_update_from_GLOBAL(
- $HOSTNAME,
- $SITE,
$options,
$GLOBAL_STRUCT,
$PF_CONFIG
);
-Unset_deferredlog() if ( $options->{'quiet'} );
-
exit 0;
diff -r 1e8f98a59538 -r 824a6d6ed01b tools/Translate_old_config
--- a/tools/Translate_old_config Mon Oct 11 15:51:28 2010 +0200
+++ b/tools/Translate_old_config Wed Oct 13 10:21:09 2010 +0200
@@ -33,7 +33,6 @@
use PFTools::Compat::Parser;
use PFTools::Compat::Translation;
-use PFTools::Logger;
#################################
# Global vars
@@ -82,11 +81,8 @@
exit 0;
}
-if ( !-e $options->{'input'} ) {
- Abort( $CODE->{'UNDEF_KEY'},
- "File "
- . $options->{'input'}
- . " doesn't exist : unable to translate old configuration" );
+unless( -e $options->{'input'} ) {
+ die "File $options->{'input'} doesn't exist";
}
my $old_parsing = Parser_pftools(
@@ -128,9 +124,8 @@
}
}
-my $output_fh = IO::File->new( ">" . $options->{'output'} );
-die "Unable to open $options->{'output'} for translation "
- unless( $output_fh );
+my $output_fh = IO::File->new( ">" . $options->{'output'} )
+ or die "Unable to open $options->{'output'} for translation";
if ( $options->{'type'} eq 'config' ) {
foreach my $section ( keys %{$trans} ) {
More information about the pf-tools-commits
mailing list