pf-tools/pf-tools: 10 new changesets
parmelan-guest at users.alioth.debian.org
parmelan-guest at users.alioth.debian.org
Thu Sep 23 13:59:07 UTC 2010
details: http://hg.debian.org/hg/pf-tools/pf-tools/rev/74b8d306e3c6
changeset: 810:74b8d306e3c6
user: Thomas Parmelan <tom+pf-tools at ankh.fr.EU.org>
date: Tue Sep 21 19:49:44 2010 +0200
description:
Add the first tests for Load_conf()
details: http://hg.debian.org/hg/pf-tools/pf-tools/rev/11b7f61b9fb8
changeset: 811:11b7f61b9fb8
user: Thomas Parmelan <tom+pf-tools at ankh.fr.EU.org>
date: Tue Sep 21 23:16:43 2010 +0200
description:
Style and comments in Syntax.pm
details: http://hg.debian.org/hg/pf-tools/pf-tools/rev/81fdc35dc18a
changeset: 812:81fdc35dc18a
user: Thomas Parmelan <tom+pf-tools at ankh.fr.EU.org>
date: Tue Sep 21 23:27:57 2010 +0200
description:
Comments
details: http://hg.debian.org/hg/pf-tools/pf-tools/rev/e02ba30f4215
changeset: 813:e02ba30f4215
user: Thomas Parmelan <tom+pf-tools at ankh.fr.EU.org>
date: Tue Sep 21 23:50:04 2010 +0200
description:
Style
details: http://hg.debian.org/hg/pf-tools/pf-tools/rev/151c2586a74c
changeset: 814:151c2586a74c
user: Thomas Parmelan <tom+pf-tools at ankh.fr.EU.org>
date: Wed Sep 22 09:08:27 2010 +0200
description:
s/$0/$PROGRAM_NAME/
details: http://hg.debian.org/hg/pf-tools/pf-tools/rev/b700a94384c8
changeset: 815:b700a94384c8
user: Thomas Parmelan <tom+pf-tools at ankh.fr.EU.org>
date: Wed Sep 22 09:27:39 2010 +0200
description:
basename $PROGRAM_NAME + delete useless $version
details: http://hg.debian.org/hg/pf-tools/pf-tools/rev/c9c532d7af0b
changeset: 816:c9c532d7af0b
user: Thomas Parmelan <tom+pf-tools at ankh.fr.EU.org>
date: Wed Sep 22 09:31:23 2010 +0200
description:
Unbreak Logger.pm
details: http://hg.debian.org/hg/pf-tools/pf-tools/rev/4b0d1edf3bbc
changeset: 817:4b0d1edf3bbc
user: Thomas Parmelan <tom+pf-tools at ankh.fr.EU.org>
date: Wed Sep 22 09:46:34 2010 +0200
description:
use base qw( Exporter );
details: http://hg.debian.org/hg/pf-tools/pf-tools/rev/a670426c7ee8
changeset: 818:a670426c7ee8
user: Thomas Parmelan <tom+pf-tools at ankh.fr.EU.org>
date: Thu Sep 23 15:50:35 2010 +0200
description:
Add a missing ";" + just croak() on error
details: http://hg.debian.org/hg/pf-tools/pf-tools/rev/bdef630830f9
changeset: 819:bdef630830f9
user: Thomas Parmelan <tom+pf-tools at ankh.fr.EU.org>
date: Thu Sep 23 15:58:33 2010 +0200
description:
Style
diffstat:
47 files changed, 220 insertions(+), 812 deletions(-)
filters/filter_distrib | 21 ++++-----------------
filters/filter_privateresolve | 24 +++---------------------
filters/filter_vlan2if | 20 +-------------------
lib/PFTools/Bridge.pm | 21 ++-------------------
lib/PFTools/Compat/Parser.pm | 23 ++++-------------------
lib/PFTools/Compat/Translation.pm | 23 ++++-------------------
lib/PFTools/Conf.pm | 18 +++++++++++++-----
lib/PFTools/Conf/Config.pm | 23 +++++------------------
lib/PFTools/Conf/Host.pm | 23 ++++-------------------
lib/PFTools/Conf/Network.pm | 27 +++++----------------------
lib/PFTools/Conf/Syntax.pm | 22 +++++-----------------
lib/PFTools/Disk.pm | 23 ++++-------------------
lib/PFTools/Logger.pm | 24 +++++-------------------
lib/PFTools/Net.pm | 2 +-
lib/PFTools/Packages.pm | 23 ++++++-----------------
lib/PFTools/Packages/DEB.pm | 23 ++++++-----------------
lib/PFTools/Structqueries.pm | 26 ++++----------------------
lib/PFTools/Update.pm | 26 +++-----------------------
lib/PFTools/Update/Addfile.pm | 22 +++-------------------
lib/PFTools/Update/Addlink.pm | 24 +++++-------------------
lib/PFTools/Update/Addmount.pm | 22 +++-------------------
lib/PFTools/Update/Common.pm | 25 ++++++-------------------
lib/PFTools/Update/Createfile.pm | 25 ++++++-------------------
lib/PFTools/Update/Installpkg.pm | 26 +++++++-------------------
lib/PFTools/Update/Mkdir.pm | 25 ++++++-------------------
lib/PFTools/Update/Purgepkg.pm | 25 ++++++-------------------
lib/PFTools/Update/Removedir.pm | 24 +++++-------------------
lib/PFTools/Update/Removefile.pm | 24 +++++-------------------
lib/PFTools/Utils.pm | 21 ++++-----------------
lib/PFTools/VCS.pm | 24 +++++++-----------------
lib/PFTools/VCS/CVS.pm | 24 ++++++------------------
lib/PFTools/VCS/SVN.pm | 24 ++++++------------------
sbin/fix_hosts | 22 ++++------------------
sbin/mk_dhcp | 24 ++++--------------------
sbin/mk_grubopt | 21 ++++-----------------
sbin/mk_interfaces | 24 ++++--------------------
sbin/mk_pxelinuxcfg | 24 ++++--------------------
sbin/mk_resolvconf | 23 ++++-------------------
sbin/mk_sitezone | 22 ++++------------------
sbin/mk_sourceslist | 22 ++++------------------
sbin/update-config | 24 ++++--------------------
t/13.conf.t | 20 ++++++++++++++++++++
tools/Display_IP_config | 19 +------------------
tools/Translate_old_config | 19 -------------------
tools/kvmlaunch | 3 ---
tools/umlaunch | 13 ++-----------
tools/xenlaunch | 25 +++++++------------------
diffs (3537 lines):
diff -r 3fd194956c81 -r bdef630830f9 filters/filter_distrib
--- a/filters/filter_distrib Thu Sep 23 11:37:07 2010 +0200
+++ b/filters/filter_distrib Thu Sep 23 15:58:33 2010 +0200
@@ -1,26 +1,27 @@
#!/usr/bin/perl
-##
-## Copyright (C) 2007-2010 Christophe Caillet <quadchris at free.fr>
-##
-## 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 the Free Software Foundation; either version 2
-## of the License, or (at your option) any later version.
-##
-## This program is distributed in the hope that it will be useful,
-## but WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-## GNU General Public License for more details.
-##
-## You should have received a copy of the GNU General Public License
-## along with this program; if not, write to the Free Software
-## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
-##
+#
+# Copyright (C) 2007-2010 Christophe Caillet <quadchris at free.fr>
+#
+# 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 the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+#
use strict;
use warnings;
use English qw( -no_match_vars ); # Avoids regex performance penalty
+use File::Basename;
use Getopt::Long qw( :config ignore_case_always bundling );
use IO::File;
use Sys::Hostname;
@@ -51,9 +52,7 @@
my $PF_CONFIG = {};
my $GLOBAL_STRUCT = {};
-my $program = $0;
-$program =~ s%.*/%%; # cheap basename
-
+my $program = basename $PROGRAM_NAME;
###################################
# Funtions
diff -r 3fd194956c81 -r bdef630830f9 filters/filter_privateresolve
--- a/filters/filter_privateresolve Thu Sep 23 11:37:07 2010 +0200
+++ b/filters/filter_privateresolve Thu Sep 23 15:58:33 2010 +0200
@@ -1,30 +1,29 @@
#!/usr/bin/perl
-##
-## $Id$
-##
-## Copyright (C) 2010 Christophe Caillet <quadchris at free.fr>
-## Copyright (C) 2003-2005 Damien Clermonte <damien at sitadelle.com>
-## Copyright (C) 2001-2003 Olivier Molteni <olivier at molteni.net>
-##
-## 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 the Free Software Foundation; either version 2
-## of the License, or (at your option) any later version.
-##
-## This program is distributed in the hope that it will be useful,
-## but WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-## GNU General Public License for more details.
-##
-## You should have received a copy of the GNU General Public License
-## along with this program; if not, write to the Free Software
-## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
-##
+#
+# Copyright (C) 2010 Christophe Caillet <quadchris at free.fr>
+# Copyright (C) 2003-2005 Damien Clermonte <damien at sitadelle.com>
+# Copyright (C) 2001-2003 Olivier Molteni <olivier at molteni.net>
+#
+# 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 the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+#
use strict;
use warnings;
use English qw( -no_match_vars ); # Avoids regex performance penalty
+use File::Basename;
use IO::File;
use Getopt::Long qw( :config ignore_case_always bundling );
use Sys::Hostname;
@@ -55,8 +54,7 @@
'type-resolve' => 'cnf',
};
-my $program = $0;
-$program =~ s%.*/%%; # cheap basename
+my $program = basename $PROGRAM_NAME;
###################################
# Funtions
diff -r 3fd194956c81 -r bdef630830f9 filters/filter_vlan2if
--- a/filters/filter_vlan2if Thu Sep 23 11:37:07 2010 +0200
+++ b/filters/filter_vlan2if Thu Sep 23 15:58:33 2010 +0200
@@ -1,23 +1,23 @@
#!/usr/bin/perl
-##
-## Copyright (C) 2010 Christophe Caillet <quadchris at free.fr>
-## Copyright (C) 2003-2005 Damien Clermonte <damien at sitadelle.com>
-## Copyright (C) 2001-2003 Olivier Molteni <olivier at molteni.net>
-##
-## 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 the Free Software Foundation; either version 2
-## of the License, or (at your option) any later version.
-##
-## This program is distributed in the hope that it will be useful,
-## but WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-## GNU General Public License for more details.
-##
-## You should have received a copy of the GNU General Public License
-## along with this program; if not, write to the Free Software
-## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
-##
+#
+# Copyright (C) 2010 Christophe Caillet <quadchris at free.fr>
+# Copyright (C) 2003-2005 Damien Clermonte <damien at sitadelle.com>
+# Copyright (C) 2001-2003 Olivier Molteni <olivier at molteni.net>
+#
+# 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 the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+#
# eth:vlan -> ethx.y:z
# eth.vlan -> ethx.y
@@ -27,6 +27,7 @@
use warnings;
use English qw( -no_match_vars ); # Avoids regex performance penalty
+use File::Basename;
use Getopt::Long qw( :config ignore_case_always bundling );
use IO::File;
use Sys::Hostname;
@@ -56,8 +57,7 @@
my $PF_CONFIG = {};
my $GLOBAL_STRUCT = {};
-my $program = $0;
-$program =~ s%.*/%%; # cheap basename
+my $program = basename $PROGRAM_NAME;
###################################
# Funtions
diff -r 3fd194956c81 -r bdef630830f9 lib/PFTools/Bridge.pm
--- a/lib/PFTools/Bridge.pm Thu Sep 23 11:37:07 2010 +0200
+++ b/lib/PFTools/Bridge.pm Thu Sep 23 15:58:33 2010 +0200
@@ -1,27 +1,26 @@
package PFTools::Bridge;
-##
-## $Id$
-##
-## Copyright (C) 2008 Christophe Caillet <quadchris at free.fr>
-##
-## 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 the Free Software Foundation; either version 2
-## of the License, or (at your option) any later version.
-##
-## This program is distributed in the hope that it will be useful,
-## but WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-## GNU General Public License for more details.
-##
-## You should have received a copy of the GNU General Public License
-## along with this program; if not, write to the Free Software
-## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
-##
+#
+# Copyright (C) 2008 Christophe Caillet <quadchris at free.fr>
+#
+# 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 the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+#
use strict;
use warnings;
+use base qw( Exporter );
use English qw( -no_match_vars ); # Avoids regex performance penalty
BEGIN {
@@ -33,10 +32,6 @@
die "Sorry, I need vlan, bridge-utils, uml-utilities and iproute2";
}
}
-
-use Exporter;
-
-our @ISA = ('Exporter');
our @EXPORT = qw(
Get_all_bridges
diff -r 3fd194956c81 -r bdef630830f9 lib/PFTools/Compat/Parser.pm
--- a/lib/PFTools/Compat/Parser.pm Thu Sep 23 11:37:07 2010 +0200
+++ b/lib/PFTools/Compat/Parser.pm Thu Sep 23 15:58:33 2010 +0200
@@ -1,33 +1,30 @@
package PFTools::Compat::Parser;
-##
-## $Id$
-##
-## Copyright (C) 2010 Christophe Caillet <quadchris at free.fr>
-##
-## 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 the Free Software Foundation; either version 2
-## of the License, or (at your option) any later version.
-##
-## This program is distributed in the hope that it will be useful,
-## but WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-## GNU General Public License for more details.
-##
-## You should have received a copy of the GNU General Public License
-## along with this program; if not, write to the Free Software
-## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
-##
+
+#
+# Copyright (C) 2010 Christophe Caillet <quadchris at free.fr>
+#
+# 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 the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+#
use strict;
use warnings;
+use base qw( Exporter );
use English qw( -no_match_vars ); # Avoids regex performance penalty
-use Exporter;
use PFTools::Logger;
-
-our @ISA = ('Exporter');
our @EXPORT = qw(
Subst_vars
diff -r 3fd194956c81 -r bdef630830f9 lib/PFTools/Compat/Translation.pm
--- a/lib/PFTools/Compat/Translation.pm Thu Sep 23 11:37:07 2010 +0200
+++ b/lib/PFTools/Compat/Translation.pm Thu Sep 23 15:58:33 2010 +0200
@@ -1,34 +1,30 @@
package PFTools::Compat::Translation;
-##
-## $Id$
-##
-## Copyright (C) 2010 Christophe Caillet <quadchris at free.fr>
-##
-## 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 the Free Software Foundation; either version 2
-## of the License, or (at your option) any later version.
-##
-## This program is distributed in the hope that it will be useful,
-## but WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-## GNU General Public License for more details.
-##
-## You should have received a copy of the GNU General Public License
-## along with this program; if not, write to the Free Software
-## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
-##
+#
+# Copyright (C) 2010 Christophe Caillet <quadchris at free.fr>
+#
+# 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 the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+#
use strict;
use warnings;
+use base qw( Exporter );
use English qw( -no_match_vars ); # Avoids regex performance penalty
-use Exporter;
use NetAddr::IP;
use PFTools::Logger;
-
-our @ISA = ('Exporter');
our @EXPORT = qw (
Translate_old2new_host
diff -r 3fd194956c81 -r bdef630830f9 lib/PFTools/Conf.pm
--- a/lib/PFTools/Conf.pm Thu Sep 23 11:37:07 2010 +0200
+++ b/lib/PFTools/Conf.pm Thu Sep 23 15:58:33 2010 +0200
@@ -318,21 +318,47 @@
return $result;
}
+=head2 Load_conf( $file, $hash_subst, $context, $pf_config )
+
+Reads configuration from $file in context $context.
+Returns undef if empty or undefined arguments.
+Croaks on other errors.
+
+FIXME: add more documentation here
+
+=cut
+
sub Load_conf {
my ( $file, $hash_subst, $context, $pf_config ) = @_;
return unless $file and $hash_subst and $context and $pf_config;
- if ( $context !~ m/^$ALLOWED_PARSING_CONTEXT$/ ) {
- Abort(
- $CODE->{'INVALID_CONTEXT'},
- "Context $context for file $file doesn't match $ALLOWED_PARSING_CONTEXT"
- );
+ if ( ref $file ) {
+ croak q{ERROR: Invalid non-scalar $file};
+ }
+ if ( ref $context ) {
+ croak q{ERROR: Invalid non-scalar $context};
+ }
+ if ( ref $hash_subst ne 'HASH' ) {
+ croak q{ERROR: Invalid non-hashref $hash_subst};
+ }
+ if ( ref $pf_config ne 'HASH' ) {
+ croak q{ERROR: Invalid non-hashref $pf_config};
}
+ if ( $context !~ m/^$ALLOWED_PARSING_CONTEXT$/ ) {
+ croak qq{ERROR: Invalid context $context for file $file doesn't match $ALLOWED_PARSING_CONTEXT};
+ }
+
+ # this will croak() on error
my $parsed = Parser_ini($file);
- if ( $context =~ /^(model|host)$/ ) {
+ my $select = $context eq 'config' ? 'action' : 'type'; # compute it only once
+
+ # FIXME: some code factorization seems possible, but
+ # proper tests are needed before changing things here.
+
+ if ( $context eq 'host' or $context eq 'model' ) {
if ( defined $parsed->{'hostgroup'}->{'model'} ) {
$parsed->{'hostgroup'}->{'__model'} = Load_conf(
Get_source(
@@ -346,22 +372,20 @@
}
}
else {
- my $select = ( $context eq 'config' ) ? 'action' : 'type';
foreach my $section ( keys %{$parsed} ) {
- next if ( $section =~ /^__/ );
+ next if $section =~ m{ \A __ }xms; # skip "internal" sections
+
if ( !defined $parsed->{$section}->{$select} ) {
- Abort(
- $CODE->{'UNDEF_KEY'},
- "Key $select on section $section from file $file MUST BE defined"
- );
+ croak qq{Key $select must be defined in section $section from file $file};
}
- my $sect_type = $parsed->{$section}->{$select};
- if ( $sect_type eq 'include' ) {
+
+ my $section_type = $parsed->{$section}->{$select};
+ if ( $section_type eq 'include' ) {
# We need to dive into deep ...
$parsed->{$section}->{'__content'}
= Load_conf(
- Get_source( $section, "", $hash_subst, $pf_config ),
+ Get_source( $section, q{}, $hash_subst, $pf_config ),
$hash_subst, $context, $pf_config
);
}
@@ -373,36 +397,25 @@
# Basic checks
foreach my $section ( keys %{$parsed} ) {
- next if $section =~ /^__/;
- my $sect_type;
- if ( $context =~ /^(host|model)$/ ) {
- $section =~ /^([^:]+)(::(.+))?$/;
- $sect_type = $1;
+ next if $section =~ m{ \A __ }xms; # skip "internal" sections
- # $iface_name = $3;
+ my $section_type;
+ if ( $context eq 'host' or $context eq 'model' ) {
+ unless ( $section =~ m{ \A ([^:]+) (?: :: (.+) )? \z }xms ) {
+ croak qq{ERROR: Unable to compute section type for section $section};
+ }
+ $section_type = $1;
+ # $iface_name = $2;
}
else {
- my $select = ( $context eq 'config' ) ? 'action' : 'type';
if ( !defined $parsed->{$section}->{$select} ) {
- Abort(
- $CODE->{'UNDEF_KEY'},
- "Key $select on section $section from file $file MUST BE defined"
- );
+ croak qq{Key $select must be defined in section $section from file $file};
}
- $sect_type = $parsed->{$section}->{$select};
+ $section_type = $parsed->{$section}->{$select};
}
- my ( $code, $msg )
- = Chk_section_struct(
- $section, $sect_type, $parsed->{$section},
- $context
- );
- if ( $code > 1 ) {
- Warn(
- $code,
- "Errors occur during parsing model from file $file"
- );
- Abort( $code, $msg );
- }
+
+ Chk_section_struct( $section, $section_type, $parsed->{$section},
+ $context );
}
return $parsed;
diff -r 3fd194956c81 -r bdef630830f9 lib/PFTools/Conf/Config.pm
--- a/lib/PFTools/Conf/Config.pm Thu Sep 23 11:37:07 2010 +0200
+++ b/lib/PFTools/Conf/Config.pm Thu Sep 23 15:58:33 2010 +0200
@@ -1,32 +1,31 @@
package PFTools::Conf::Config;
-##
-## Copyright (C) 2010 Christophe Caillet <quadchris at free.fr>
-##
-## 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 the Free Software Foundation; either version 2
-## of the License, or (at your option) any later version.
-##
-## This program is distributed in the hope that it will be useful,
-## but WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-## GNU General Public License for more details.
-##
-## You should have received a copy of the GNU General Public License
-## along with this program; if not, write to the Free Software
-## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
-## MA 02110-1301, USA
-##
+
+#
+# Copyright (C) 2010 Christophe Caillet <quadchris at free.fr>
+#
+# 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 the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1301, USA
+#
use strict;
use warnings;
+use base qw( Exporter );
use English qw( -no_match_vars ); # Avoids regex performance penalty
-use Exporter;
use PFTools::Logger;
-
-our @ISA = ('Exporter');
our @EXPORT = qw(
Init_CONFIG_STRUCT
diff -r 3fd194956c81 -r bdef630830f9 lib/PFTools/Conf/Host.pm
--- a/lib/PFTools/Conf/Host.pm Thu Sep 23 11:37:07 2010 +0200
+++ b/lib/PFTools/Conf/Host.pm Thu Sep 23 15:58:33 2010 +0200
@@ -1,30 +1,29 @@
package PFTools::Conf::Host;
-##
-## $Id: Net.pm 786 2010-07-27 15:16:09Z ccaillet-guest $
-##
-## Copyright (C) 2010 Christophe Caillet <quadchris at free.fr>
-##
-## 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 the Free Software Foundation; either version 2
-## of the License, or (at your option) any later version.
-##
-## This program is distributed in the hope that it will be useful,
-## but WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-## GNU General Public License for more details.
-##
-## You should have received a copy of the GNU General Public License
-## along with this program; if not, write to the Free Software
-## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
-##
+
+#
+# Copyright (C) 2010 Christophe Caillet <quadchris at free.fr>
+#
+# 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 the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+#
use strict;
use warnings;
+use base qw( Exporter );
use Carp;
use English qw( -no_match_vars ); # Avoids regex performance penalty
-use Exporter;
use Fcntl ':mode';
use POSIX qw(ceil floor);
@@ -32,8 +31,6 @@
use PFTools::Logger;
use PFTools::Net;
use PFTools::Structqueries;
-
-our @ISA = ('Exporter');
our @EXPORT = qw(
Build_host_from_server
diff -r 3fd194956c81 -r bdef630830f9 lib/PFTools/Conf/Network.pm
--- a/lib/PFTools/Conf/Network.pm Thu Sep 23 11:37:07 2010 +0200
+++ b/lib/PFTools/Conf/Network.pm Thu Sep 23 15:58:33 2010 +0200
@@ -1,38 +1,35 @@
package PFTools::Conf::Network;
-##
-## $Id$
-##
-## Copyright (C) 2007-2009 Christophe Caillet <quadchris at free.fr>
-## Copyright (C) 2005-2007 Thomas Parmelan <tom+pf-tools at ankh.fr.EU.org>
-## Copyright (C) 2003-2005 Damien Clermonte <damien at sitadelle.com>
-## Copyright (C) 2001-2003 Olivier Molteni <olivier at molteni.net>
-##
-## 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 the Free Software Foundation; either version 2
-## of the License, or (at your option) any later version.
-##
-## This program is distributed in the hope that it will be useful,
-## but WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-## GNU General Public License for more details.
-##
-## You should have received a copy of the GNU General Public License
-## along with this program; if not, write to the Free Software
-## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
-##
+
+#
+# Copyright (C) 2007-2009 Christophe Caillet <quadchris at free.fr>
+# Copyright (C) 2005-2007 Thomas Parmelan <tom+pf-tools at ankh.fr.EU.org>
+# Copyright (C) 2003-2005 Damien Clermonte <damien at sitadelle.com>
+# Copyright (C) 2001-2003 Olivier Molteni <olivier at molteni.net>
+#
+# 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 the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+#
use strict;
use warnings;
+use base qw( Exporter );
use English qw( -no_match_vars ); # Avoids regex performance penalty
-use Exporter;
use PFTools::Logger;
use PFTools::Net;
use PFTools::Structqueries;
-
-our @ISA = ('Exporter');
our @EXPORT = qw(
Add_network
diff -r 3fd194956c81 -r bdef630830f9 lib/PFTools/Conf/Syntax.pm
--- a/lib/PFTools/Conf/Syntax.pm Thu Sep 23 11:37:07 2010 +0200
+++ b/lib/PFTools/Conf/Syntax.pm Thu Sep 23 15:58:33 2010 +0200
@@ -1,31 +1,30 @@
package PFTools::Conf::Syntax;
-##
-## Copyright (C) 2010 Christophe Caillet <quadchris at free.fr>
-##
-## 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 the Free Software Foundation; either version 2
-## of the License, or (at your option) any later version.
-##
-## This program is distributed in the hope that it will be useful,
-## but WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-## GNU General Public License for more details.
-##
-## You should have received a copy of the GNU General Public License
-## along with this program; if not, write to the Free Software
-## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
-##
+#
+# Copyright (C) 2010 Christophe Caillet <quadchris at free.fr>
+#
+# 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 the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+#
use strict;
use warnings;
+use base qw( Exporter );
+use Carp;
use English qw( -no_match_vars ); # Avoids regex performance penalty
-use Exporter;
use PFTools::Logger;
-
-our @ISA = ('Exporter');
our @EXPORT = qw(
$DEF_SECTIONS
@@ -41,10 +40,31 @@
our @EXPORT_OK = qw();
# Syntax definitions
-our $ALLOWED_PARSING_CONTEXT = '(host|network|config|model)';
+
+# FIXME: factorize the common part of $HOSTTYPE_CONFIG_REGEX,
+# $MODEL_CONFIG_REGEX and $HOST_CONFIG_REGEX
+
+# FIXME: $CONFIG_REGEX->{'foo'} instead of $FOO_CONFIG_REGEX
+
+our $ALLOWED_PARSING_CONTEXT = qr{host|network|config|model};
our $HOSTTYPE_CONFIG_REGEX = qr{
- \A
- (?<HOSTTYPE> # HOSTTYPE
+ \A
+ (?<HOSTTYPE> # HOSTTYPE
+ (
+ (?<POPNAME> # POPNAME (optional)
+ [a-z]{3}\d
+ )
+ -
+ )?
+ (
+ [a-z0-9-]+[a-z-] # host type (without the POP name)
+ )
+ )
+ \z
+}xms;
+our $MODEL_CONFIG_REGEX = qr{
+ \A
+ (?<HOSTTYPE> # HOSTTYPE
(
(?<POPNAME> # POPNAME (optional)
[a-z]{3}\d{1}
@@ -55,14 +75,16 @@
[a-z0-9-]+[a-z-] # host type (without the POP name)
)
)
+ %* # HOSTDIGITS MARK (optional)
+ _* # HOSTNODEINDEX MARK (optional)
\z
}xms;
-our $MODEL_CONFIG_REGEX = qr{
- \A
- (?<HOSTTYPE> # HOSTTYPE
+our $HOST_CONFIG_REGEX = qr{
+ \A
+ (?<HOSTTYPE> # HOSTTYPE
(
- (?<POPNAME> # POPNAME (optional)
- [a-z]{3}\d{1}
+ (?<POPNAME> # POPNAME (optional)
+ [a-z]{3}\d
)
-
)?
@@ -70,30 +92,31 @@
[a-z0-9-]+[a-z-] # host type (without the POP name)
)
)
- %* # HOSTDIGITS MARK (optional)
- _* # HOSTNODEINDEX MARK (optional)
- \z
+ (?<HOSTDIGITS> # HOSTDIGITS (optional)
+ \d*
+ )
+ (?<HOSTNODEINDEX> # HOSTNODEINDEX (optional)
+ [a-z]*
+ )
+ \z
}xms;
-our $HOST_CONFIG_REGEX = qr{
- \A
- (?<HOSTTYPE> # HOSTTYPE
- (
- (?<POPNAME> # POPNAME (optional)
- [a-z]{3}\d{1}
- )
- -
- )?
- (
- [a-z0-9-]+[a-z-] # host type (without the POP name)
- )
- )(?<HOSTDIGITS>\d*) # HOSTDIGITS (optional)
- (?<HOSTNODEINDEX>[a-z]*) # HOSTNODEINDEX (optional)
- \z
+
+# deploy, POPNAME-rdeploy or POPNAME-spawn
+#our $DEPLOY_CONFIG_REGEX = '((?:\w{3}\d-r)?deploy|(\w{3}\d-)?spawn)';
+our $DEPLOY_CONFIG_REGEX = qr{
+ (
+ deploy
+ |
+ [a-z]{3}\d
+ -
+ (?:
+ rdeploy | spawn
+ )
+ )
}xms;
-our $DEPLOY_CONFIG_REGEX = '((?:\w{3}\d-r)?deploy|(\w{3}\d-)?spawn)';
#####################################
-# Sturcture for the hash below :
+# Structure for the hash below :
# {
# <context> = {
# <section> = {
@@ -117,14 +140,14 @@
'ipv6' => 'undefined',
'iface_opt' => 'undefined',
'@route' => 'undefined',
- '@route6' => 'undefined'
+ '@route6' => 'undefined',
},
'deployment' => {
'MANDATORY_KEYS' => [ 'arch', 'mode', 'distrib' ],
'arch' => 'i386|amd64',
'mode' => '(debian|ubuntu)',
'distrib' => '[a-z]+',
- 'dhcpvlan' => '\w+'
+ 'dhcpvlan' => '\w+',
},
'hostgroup' => {
'MANDATORY_KEYS' => [ 'number', 'hostname' ],
@@ -135,7 +158,7 @@
'nodes' => '[\d]+',
'prefix' => '(true|false)',
'hostname' => $MODEL_CONFIG_REGEX,
- 'hosttype' => $HOSTTYPE_CONFIG_REGEX
+ 'hosttype' => $HOSTTYPE_CONFIG_REGEX,
},
'boot' => {
'MANDATORY_KEYS' => ['kernel'],
@@ -143,14 +166,14 @@
'kernel' => 'undefined',
'initrd' => 'undefined',
'cmdline' => 'undefined',
- 'console' => '(default|ttyS0,115200n8)'
+ 'console' => '(default|ttyS0,115200n8)',
},
'dns' => {
'MANDATORY_KEYS' => ['resolver'],
'resolver' => 'undefined',
'shortname' => 'undefined',
- 'alias' => 'undefined'
- }
+ 'alias' => 'undefined',
+ },
},
'network' => {
'zone' => {
@@ -178,34 +201,34 @@
'state' => 'ROOT|EDGE',
'dhcpvlan' => '[\w\-]+',
'prefix' => '\w+',
- 'console' => '(default|ttyS0,115200n8)'
+ 'console' => '(default|ttyS0,115200n8)',
},
'network' => {
'MANDATORY_KEYS' => [ 'network', 'site' ],
'comment' => 'undefined',
'tag' => '\d{1,4}',
- 'network' => '([\d]{1,3}\.){3}[\d]{1,3}\/\d+',
+ 'network' => '([\d]{1,3}\.){3}[\d]{1,3}(\/\d+)?',
'network6' => 'undefined',
'scope' => '(private|public)',
'site' => '(ALL|[\w\-]+(\s*,\s*[\w\-]+)*)',
'gateway' => '([\d]{1,3})((\.[\d]{1,3}){1,3})?',
- 'gateway6' => 'undefined'
+ 'gateway6' => 'undefined',
},
'server' => {
- 'MANDATORY_KEYS' => [ 'site', 'number', ],
- 'comment' => 'undefined',
- 'site' => '(ALL|[\w\-]+(\s*,\s*[\w\-]+)*)',
- 'number' => '\d+',
- 'ipv4' => '([\d]{1,3})((\.[\d]{1,3}){1,3})?',
- 'ipv6' => 'undefined',
- 'alias' => '[a-z][a-z0-9\-]+[a-z0-9]',
- 'shortname' => '[a-z][a-z0-9\-]+[a-z0-9]'
+ 'MANDATORY_KEYS' => [ 'site', 'number', ],
+ 'comment' => 'undefined',
+ 'site' => '(ALL|[\w\-]+(\s*,\s*[\w\-]+)*)',
+ 'number' => '\d+',
+ 'ipv4' => '([\d]{1,3})((\.[\d]{1,3}){1,3})?',
+ 'ipv6' => 'undefined',
+ 'alias' => '[a-z][a-z0-9\-]+[a-z0-9]',
+ 'shortname' => '[a-z][a-z0-9\-]+[a-z0-9]',
},
'service' => {
'MANDATORY_KEYS' => [ 'site', '@host' ],
'comment' => 'undefined',
- '@host' => '[\w\-\:\/]+'
- }
+ '@host' => '[\w\-\:\/]+',
+ },
},
'config' => {
'addfile' => {
@@ -219,7 +242,7 @@
'on_config' => 'undefined',
'before_change' => 'undefined',
'on_noaction' => 'undefined',
- 'after_change' => 'undefined'
+ 'after_change' => 'undefined',
},
'createfile' => {
'depends' => 'undefined',
@@ -231,7 +254,7 @@
'on_config' => 'undefined',
'before_change' => 'undefined',
'on_noaction' => 'undefined',
- 'after_change' => 'undefined'
+ 'after_change' => 'undefined',
},
'removefile' => {},
'mkdir' => {
@@ -241,7 +264,7 @@
'on_config' => 'undefined',
'before_change' => 'undefined',
'on_noaction' => 'undefined',
- 'after_change' => 'undefined'
+ 'after_change' => 'undefined',
},
'addlink' => {
'MANDATORY_KEYS' => ['source'],
@@ -249,7 +272,7 @@
'on_config' => 'undefined',
'before_change' => 'undefined',
'on_noaction' => 'undefined',
- 'after_change' => 'undefined'
+ 'after_change' => 'undefined',
},
'addmount' => {
'MANDATORY_KEYS' => [ 'source', 'fstype', 'options' ],
@@ -257,133 +280,142 @@
'source' => 'undefined',
'fstype' => '(nfs|ext[2-4]|btrfs|cifs)',
'options' => 'undefined',
- 'mode' => '[0-7]?[0-7]{3}'
+ 'mode' => '[0-7]?[0-7]{3}',
},
'installpkg' => {
'version' => 'undefined',
'on_config' => 'undefined',
'before_change' => 'undefined',
'on_noaction' => 'undefined',
- 'after_change' => 'undefined'
+ 'after_change' => 'undefined',
},
'purgepkg' => {
'version' => 'undefined',
'on_config' => 'undefined',
'before_change' => 'undefined',
'on_noaction' => 'undefined',
- 'after_change' => 'undefined'
+ 'after_change' => 'undefined',
},
'filter-model' => {
- 'MANDATORY_KEYS' => ['filter'],
- 'filter' => 'undefined'
+ 'MANDATORY_KEYS' => [ 'filter' ],
+ 'filter' => 'undefined',
},
'actiongroup' => {
'on_config' => 'undefined',
'before_change' => 'undefined',
'on_noaction' => 'undefined',
- 'after_change' => 'undefined'
- }
- }
+ 'after_change' => 'undefined',
+ },
+ },
};
$DEF_SECTIONS->{'config'}->{'apt-get'}
= $DEF_SECTIONS->{'config'}->{'installpkg'};
$DEF_SECTIONS->{'config'}->{'dpkg-purge'}
= $DEF_SECTIONS->{'config'}->{'purgepkg'};
-sub Chk_section_struct ($$$$) {
- my ( $sect_name, $sect_type, $sect_hash, $context ) = @_;
- my ( $iface_type, $definition, $int_context, $sect_tmp );
+=head2
- $int_context = ( $context eq 'model' ) ? 'host' : $context;
+Chk_section_struct( $section_name, $section_type, $section_hash, $context )
- if ( !defined $DEF_SECTIONS->{$int_context}->{$sect_type} ) {
- return ( $CODE->{'INVALID_SECTNAME'},
- "Invalid section type " . $sect_type );
+Check $section_hash validity against $DEF_SECTIONS. Returns a true value on
+success, or croaks on errors.
+
+=cut
+
+sub Chk_section_struct {
+ my ( $section_name, $section_type, $section_hash, $context ) = @_;
+
+ my $int_context = ( $context eq 'model' ) ? 'host' : $context;
+
+ if ( !defined $DEF_SECTIONS->{$int_context}->{$section_type} ) {
+ croak qq{ERROR: Invalid section type $section_type};
}
- if ( $context =~ /^(host|model)$/ ) {
- if ( $sect_name
- =~ /^\Q$sect_type\E(::((eth|bond)[\d]+(\.TAG[\d]+)?))?$/ )
+ my ( $iface_type, $section_tmp);
+ if ( $context eq 'host' or $context eq 'model' ) {
+ unless ($section_name
+ =~ m{
+ \A
+ \Q$section_type\E
+ (?:
+ ::
+ (?: # logical interface name
+ (?:eth|bond) [\d]+ # real interface name
+ (?: # optional 802.1Q tag
+ [.]
+ TAG [\d]+
+ )?
+ )
+ )?
+ \z
+ }xms
+ )
{
- $iface_type = $3;
- }
- else {
- return ( $CODE->{'INVALID_SECTNAME'},
- "Invalid section name " . $sect_name );
+ croak qq{ERROR: Invalid section name $section_name};
}
- # Cleaning key name by removing .default or .%HOSTNUM% suffix
- foreach my $key ( keys %{$sect_hash} ) {
+ # Clean key names by removing .default or .%HOSTNUM% suffix
+ foreach my $key ( keys %{$section_hash} ) {
my $new = $key;
$new =~ s/\..*$//;
- $sect_tmp->{$new}->{'ORIG_NAME'} = $key;
- $sect_tmp->{$new}->{'VALUE'} = $sect_hash->{$key};
+ $section_tmp->{$new}->{'ORIG_NAME'} = $key;
+ $section_tmp->{$new}->{'VALUE'} = $section_hash->{$key};
}
}
else {
- $sect_tmp = $sect_hash;
+ $section_tmp = $section_hash;
}
- $definition = $DEF_SECTIONS->{$int_context}->{$sect_type};
+ my $definition = $DEF_SECTIONS->{$int_context}->{$section_type};
- # Checking mandatory keys
+ # Check mandatory keys
foreach my $key ( @{ $definition->{'MANDATORY_KEYS'} } ) {
- if ( $sect_type eq 'interface' ) {
- next if ( $iface_type eq 'eth' && $key eq 'slaves' );
- next if ( $key =~ /^ipv/ && $context eq 'model' );
+ if ( $section_type eq 'interface' ) {
+ next if $iface_type eq 'eth' and $key eq 'slaves';
+ next if $key =~ m{\A ipv}xms and $context eq 'model';
}
- last if ( $sect_type eq 'hostgroup' && $context eq 'model' );
- return ( $CODE->{'UNDEF_KEY'},
- "Mandatory key "
- . $key
- . " MUST BE defined on section "
- . $sect_name
- . " in context "
- . $context )
- if ( !defined( $sect_tmp->{$key} ) );
+ last if $section_type eq 'hostgroup' and $context eq 'model';
+ if ( !defined $section_tmp->{$key} ) {
+ croak qq{Mandatory key $key must be defined in section $section_name in context $context};
+ }
}
- # Checking all keys defined
+ # Check all keys defined
foreach my $key ( keys %{$definition} ) {
next
- if ( $key eq 'MANDATORY_KEYS'
- || $key =~ /^__/
- || $definition->{$key} eq 'undefined'
- || !defined $sect_tmp->{$key} );
- my $tab_values = [];
- my $key_name;
+ if $key eq 'MANDATORY_KEYS'
+ or $key =~ m{\A __}xms
+ or $definition->{$key} eq 'undefined' # FIXME
+ or !defined $section_tmp->{$key};
+
+ my ( $tab_values, $key_name );
if ( $int_context eq 'host' ) {
$tab_values
= ( $key !~ /^@/ )
- ? [ $sect_tmp->{$key}->{'VALUE'} ]
- : $sect_tmp->{$key}->{'VALUE'};
- $key_name = $sect_tmp->{$key}->{'ORIG_NAME'};
+ ? [ $section_tmp->{$key}->{'VALUE'} ]
+ : $section_tmp->{$key}->{'VALUE'};
+ $key_name = $section_tmp->{$key}->{'ORIG_NAME'};
}
else {
$tab_values
= ( $key !~ /^@/ )
- ? [ $sect_tmp->{$key} ]
- : $sect_tmp->{$key};
+ ? [ $section_tmp->{$key} ]
+ : $section_tmp->{$key};
$key_name = $key;
}
+
foreach my $value ( @{$tab_values} ) {
- # Removing trailing space
- $value =~ s/^\s*//;
- $value =~ s/\s*$//;
- if ( "$value" !~ /^$definition->{$key}$/ ) {
- return ( $CODE->{'INVALID_VALUE'},
- "Value |"
- . $value
- . "| for key "
- . $key_name
- . " on section "
- . $sect_name
- . " doesn't match "
- . $definition->{$key} );
+ # Remove surrounding spaces
+ $value =~ s{\A \s*}{}xms;
+ $value =~ s{\s* \z}{}xms;
+
+ if ( $value !~ m{ \A $definition->{$key} \z }xms ) {
+ croak qq{Value '$value' for key $key_name in section $section_name doesn't match $definition->{$key}};
}
}
}
- return ( $CODE->{'OK'}, "" );
+
+ return 1;
}
1;
diff -r 3fd194956c81 -r bdef630830f9 lib/PFTools/Disk.pm
--- a/lib/PFTools/Disk.pm Thu Sep 23 11:37:07 2010 +0200
+++ b/lib/PFTools/Disk.pm Thu Sep 23 15:58:33 2010 +0200
@@ -1,33 +1,30 @@
package PFTools::Disk;
-##
-## $Id$
-##
-## Copyright (C) 2007 Christophe Caillet <christophe.caillet at gmail.com>
-##
-## 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 the Free Software Foundation; either version 2
-## of the License, or (at your option) any later version.
-##
-## This program is distributed in the hope that it will be useful,
-## but WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-## GNU General Public License for more details.
-##
-## You should have received a copy of the GNU General Public License
-## along with this program; if not, write to the Free Software
-## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
-##
+
+#
+# Copyright (C) 2007 Christophe Caillet <christophe.caillet at gmail.com>
+#
+# 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 the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+#
use strict;
use warnings;
+use base qw( Exporter );
use English qw( -no_match_vars ); # Avoids regex performance penalty
-use Exporter;
use PFTools::Logger;
-
-our @ISA = ('Exporter');
our @EXPORT = qw(
Build_structure_from_fstab
diff -r 3fd194956c81 -r bdef630830f9 lib/PFTools/Logger.pm
--- a/lib/PFTools/Logger.pm Thu Sep 23 11:37:07 2010 +0200
+++ b/lib/PFTools/Logger.pm Thu Sep 23 15:58:33 2010 +0200
@@ -1,35 +1,31 @@
package PFTools::Logger;
-##
-## $Id$
-##
-## Copyright (C) 2010 Christophe Caillet <quadchris at free.fr>
-##
-## 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 the Free Software Foundation; either version 2
-## of the License, or (at your option) any later version.
-##
-## This program is distributed in the hope that it will be useful,
-## but WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-## GNU General Public License for more details.
-##
-## You should have received a copy of the GNU General Public License
-## along with this program; if not, write to the Free Software
-## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
-##
+#
+# Copyright (C) 2010 Christophe Caillet <quadchris at free.fr>
+#
+# 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 the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+#
use strict;
use warnings;
+use base qw( Exporter );
+use Carp qw( confess croak );
use File::Basename;
use English qw( -no_match_vars ); # Avoids regex performance penalty
-use Exporter;
-
-our @ISA = ('Exporter');
our @EXPORT = qw(
- $DEFERREDLOG
$CODE
deferredlogsystem
@@ -47,8 +43,6 @@
);
our @EXPORT_OK = qw();
-
-my $DEFERREDLOG = 0;
# Error code and error messages
our $CODE = {
@@ -69,7 +63,9 @@
'DUPLICATE_VALUE' => 21,
};
-# Vars needed by pf-launch
+my $basename = basename $PROGRAM_NAME;
+my $log_is_deferred = 0;
+
my $sortie;
my $tmpfile = "/tmp/update-config.log"; # FIXME File::Temp
@@ -80,20 +76,18 @@
sub RotateCursor {
print STDERR $rotatecursortemplate[$rotatecursorcount], "\r";
- $rotatecursorcount
- = ( $rotatecursorcount + 1 ) % ( $#rotatecursortemplate + 1 );
+ $rotatecursorcount = ( $rotatecursorcount + 1 ) % @rotatecursortemplate;
}
sub Set_deferredlog {
- $DEFERREDLOG = 1;
+ $log_is_deferred = 1;
}
sub Unset_deferredlog {
- $DEFERREDLOG = 0;
+ $log_is_deferred = 0;
}
sub DeferOutput {
-
local *REAL_STDOUT;
local *REAL_STDERR;
@@ -106,19 +100,19 @@
$sortie->{'_stdout'} = *REAL_STDOUT;
$sortie->{'_stderr'} = *REAL_STDERR;
- open( STDOUT, "+>$tmpfile" ) or warn "Can't open tmp file for stdout";
- open( STDERR, ">&STDOUT" ) or warn "Can't open tmp file for stderr";
+ open( STDOUT, "+>$tmpfile" )
+ or warn qq{Can't open $tmpfile for stdout: $OS_ERROR};
+ open( STDERR, ">&STDOUT" )
+ or warn qq{Can't open $tmpfile for stderr: $OS_ERROR};
unlink $tmpfile;
select STDERR;
$| = 1;
select STDOUT;
$| = 1;
-
}
sub UndeferOutput {
-
seek( STDOUT, 0, 0 );
local $/;
$deferbuffer = <STDOUT>;
@@ -143,7 +137,6 @@
$| = 1;
select STDOUT;
$| = 1;
-
}
sub deferredlogpipe {
@@ -152,11 +145,10 @@
return unless $pipe_cmd;
DeferOutput()
- if $deferredlog or $DEFERREDLOG;
+ if $deferredlog or $log_is_deferred;
unless ( open DEFERREDLOGPIPE, '-|', $pipe_cmd ) {
- Warn( $CODE->{'OPEN'}, "Unable to open pipe $pipe_cmd: $OS_ERROR" );
- return;
+ croak qq{Unable to open pipe $pipe_cmd: $OS_ERROR};
}
my $ret = '';
@@ -167,7 +159,7 @@
close DEFERREDLOGPIPE;
UndeferOutput()
- if $deferredlog or $DEFERREDLOG;
+ if $deferredlog or $log_is_deferred;
if ($deferbuffer) {
$deferredlogbuffer .= $deferbuffer;
@@ -186,12 +178,12 @@
return unless $system_cmd;
DeferOutput()
- if $deferredlog or $DEFERREDLOG;
+ if $deferredlog or $log_is_deferred;
- my $ret = system($system_cmd );
+ my $ret = system($system_cmd);
UndeferOutput()
- if $deferredlog or $DEFERREDLOG;
+ if $deferredlog or $log_is_deferred;
if ($deferbuffer) {
$deferredlogbuffer .= $deferbuffer;
@@ -244,7 +236,7 @@
$deferredlogbuffer .= "\n";
- if ( !$DEFERREDLOG ) {
+ if ( !$log_is_deferred ) {
FlushLog();
}
else {
@@ -255,23 +247,21 @@
sub Debug {
my (@msg) = @_;
- my $basename = basename $0;
Log( "$basename: DEBUG: ", @msg );
}
sub Warn {
my ( $err, @msg ) = @_; # FIXME: $err unused!?
- my $basename = basename $0;
Log( "$basename: WARN: ", @msg );
}
sub Abort {
my ( $err, @msg ) = @_;
- my $basename = basename $0;
Log( "$basename: ERR: ", @msg );
FlushLog();
+ confess q{Please fix the caller by using croak() instead of Abort()};
exit $err;
}
diff -r 3fd194956c81 -r bdef630830f9 lib/PFTools/Net.pm
--- a/lib/PFTools/Net.pm Thu Sep 23 11:37:07 2010 +0200
+++ b/lib/PFTools/Net.pm Thu Sep 23 15:58:33 2010 +0200
@@ -23,16 +23,14 @@
use strict;
use warnings;
+use base qw( Exporter );
use Carp;
use English qw( -no_match_vars ); # Avoids regex performance penalty
-use Exporter;
use Net::DNS;
use NetAddr::IP;
use PFTools::Logger;
#use PFTools::Structqueries;
-
-our @ISA = ('Exporter');
our @EXPORT = qw(
Get_netblock_from_vlan
diff -r 3fd194956c81 -r bdef630830f9 lib/PFTools/Packages.pm
--- a/lib/PFTools/Packages.pm Thu Sep 23 11:37:07 2010 +0200
+++ b/lib/PFTools/Packages.pm Thu Sep 23 15:58:33 2010 +0200
@@ -1,33 +1,31 @@
package PFTools::Packages;
-##
-## Copyright (C) 2009-2010 Christophe Caillet <quadchris at free.fr>
-##
-## 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 the Free Software Foundation; either version 2
-## of the License, or (at your option) any later version.
-##
-## This program is distributed in the hope that it will be useful,
-## but WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-## GNU General Public License for more details.
-##
-## You should have received a copy of the GNU General Public License
-## along with this program; if not, write to the Free Software
-## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
-##
+#
+# Copyright (C) 2009-2010 Christophe Caillet <quadchris at free.fr>
+#
+# 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 the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+#
use strict;
use warnings;
+use base qw( Exporter );
use English qw( -no_match_vars ); # Avoids regex performance penalty
-use Exporter;
use Module::Runtime qw( use_module );
use PFTools::Logger;
use PFTools::Packages::DEB;
-
-our @ISA = ('Exporter');
our @EXPORT = qw(
Cmp_pkg_version
diff -r 3fd194956c81 -r bdef630830f9 lib/PFTools/Packages/DEB.pm
--- a/lib/PFTools/Packages/DEB.pm Thu Sep 23 11:37:07 2010 +0200
+++ b/lib/PFTools/Packages/DEB.pm Thu Sep 23 15:58:33 2010 +0200
@@ -1,32 +1,31 @@
package PFTools::Packages::DEB;
-##
-## Copyright (C) 2009 Christophe Caillet <quadchris at free.fr>
-##
-## 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 the Free Software Foundation; either version 2
-## of the License, or (at your option) any later version.
-##
-## This program is distributed in the hope that it will be useful,
-## but WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-## GNU General Public License for more details.
-##
-## You should have received a copy of the GNU General Public License
-## along with this program; if not, write to the Free Software
-## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
-##
+
+#
+# Copyright (C) 2009 Christophe Caillet <quadchris at free.fr>
+#
+# 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 the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+#
use strict;
use warnings;
+use base qw( Exporter );
use English qw( -no_match_vars ); # Avoids regex performance penalty
-use Exporter;
use IO::File;
use PFTools::Logger;
-
-our @ISA = ('Exporter');
our @EXPORT = qw(
Pkg_status
diff -r 3fd194956c81 -r bdef630830f9 lib/PFTools/Structqueries.pm
--- a/lib/PFTools/Structqueries.pm Thu Sep 23 11:37:07 2010 +0200
+++ b/lib/PFTools/Structqueries.pm Thu Sep 23 15:58:33 2010 +0200
@@ -1,36 +1,33 @@
package PFTools::Structqueries;
-##
-## $Id$
-##
-## Copyright (C) 2007-2010 Christophe Caillet <quadchris at free.fr>
-## Copyright (C) 2005-2007 Thomas Parmelan <tom+pf-tools at ankh.fr.EU.org>
-## Copyright (C) 2003-2005 Damien Clermonte <damien at sitadelle.com>
-## Copyright (C) 2001-2003 Olivier Molteni <olivier at molteni.net>
-##
-## 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 the Free Software Foundation; either version 2
-## of the License, or (at your option) any later version.
-##
-## This program is distributed in the hope that it will be useful,
-## but WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-## GNU General Public License for more details.
-##
-## You should have received a copy of the GNU General Public License
-## along with this program; if not, write to the Free Software
-## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
-##
+
+#
+# Copyright (C) 2007-2010 Christophe Caillet <quadchris at free.fr>
+# Copyright (C) 2005-2007 Thomas Parmelan <tom+pf-tools at ankh.fr.EU.org>
+# Copyright (C) 2003-2005 Damien Clermonte <damien at sitadelle.com>
+# Copyright (C) 2001-2003 Olivier Molteni <olivier at molteni.net>
+#
+# 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 the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+#
use strict;
use warnings;
+use base qw( Exporter );
use English qw( -no_match_vars ); # Avoids regex performance penalty
-use Exporter;
use PFTools::Logger;
-
-our @ISA = ('Exporter');
our @EXPORT = qw(
Get_zone_from_hostname
diff -r 3fd194956c81 -r bdef630830f9 lib/PFTools/Update.pm
--- a/lib/PFTools/Update.pm Thu Sep 23 11:37:07 2010 +0200
+++ b/lib/PFTools/Update.pm Thu Sep 23 15:58:33 2010 +0200
@@ -1,33 +1,32 @@
package PFTools::Update;
-##
-## $Id$
-##
-## Copyright (C) 2007-2009 Christophe Caillet <quadchris at free.fr>
-## Copyright (C) 2004-2007 Thomas Parmelan <tom+pf-tools at ankh.fr.EU.org>
-## Copyright (C) 2004 Gonéri Le Bouder <goneri at sitadelle.com>
-## Copyright (C) 2003-2005 Damien Clermonte <damien at sitadelle.com>
-## Copyright (C) 2001-2003 Olivier Molteni <olivier at molteni.net>
-##
-## 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 the Free Software Foundation; either version 2
-## of the License, or (at your option) any later version.
-##
-## This program is distributed in the hope that it will be useful,
-## but WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-## GNU General Public License for more details.
-##
-## You should have received a copy of the GNU General Public License
-## along with this program; if not, write to the Free Software
-## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
-##
+
+#
+# Copyright (C) 2007-2009 Christophe Caillet <quadchris at free.fr>
+# Copyright (C) 2004-2007 Thomas Parmelan <tom+pf-tools at ankh.fr.EU.org>
+# Copyright (C) 2004 Gonéri Le Bouder <goneri at sitadelle.com>
+# Copyright (C) 2003-2005 Damien Clermonte <damien at sitadelle.com>
+# Copyright (C) 2001-2003 Olivier Molteni <olivier at molteni.net>
+#
+# 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 the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+#
use strict;
use warnings;
+use base qw( Exporter );
use English qw( -no_match_vars ); # Avoids regex performance penalty
-use Exporter;
use PFTools::Logger;
use PFTools::Packages;
@@ -41,8 +40,6 @@
use PFTools::Update::Purgepkg;
use PFTools::Update::Removedir;
use PFTools::Update::Removefile;
-
-our @ISA = ('Exporter');
our @EXPORT = qw(
Get_depends_for_action
diff -r 3fd194956c81 -r bdef630830f9 lib/PFTools/Update/Addfile.pm
--- a/lib/PFTools/Update/Addfile.pm Thu Sep 23 11:37:07 2010 +0200
+++ b/lib/PFTools/Update/Addfile.pm Thu Sep 23 15:58:33 2010 +0200
@@ -1,29 +1,28 @@
package PFTools::Update::Addfile;
-##
-## $Id$
-##
-## Copyright (C) 2010 Christophe Caillet <quadchris at free.fr>
-##
-## 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 the Free Software Foundation; either version 2
-## of the License, or (at your option) any later version.
-##
-## This program is distributed in the hope that it will be useful,
-## but WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-## GNU General Public License for more details.
-##
-## You should have received a copy of the GNU General Public License
-## along with this program; if not, write to the Free Software
-## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
-##
+
+#
+# Copyright (C) 2010 Christophe Caillet <quadchris at free.fr>
+#
+# 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 the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+#
use strict;
use warnings;
+use base qw( Exporter );
use English qw( -no_match_vars ); # Avoids regex performance penalty
-use Exporter;
use File::Compare;
use File::Copy;
use Text::Diff;
@@ -31,8 +30,6 @@
use PFTools::Conf;
use PFTools::Logger;
use PFTools::Update::Common;
-
-our @ISA = ('Exporter');
our @EXPORT = qw(
Addfile_depends
diff -r 3fd194956c81 -r bdef630830f9 lib/PFTools/Update/Addlink.pm
--- a/lib/PFTools/Update/Addlink.pm Thu Sep 23 11:37:07 2010 +0200
+++ b/lib/PFTools/Update/Addlink.pm Thu Sep 23 15:58:33 2010 +0200
@@ -1,35 +1,32 @@
package PFTools::Update::Addlink;
-##
-## $Id$
-##
-## Copyright (C) 2010 Christophe Caillet <quadchris at free.fr>
-##
-## 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 the Free Software Foundation; either version 2
-## of the License, or (at your option) any later version.
-##
-## This program is distributed in the hope that it will be useful,
-## but WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-## GNU General Public License for more details.
-##
-## You should have received a copy of the GNU General Public License
-## along with this program; if not, write to the Free Software
-## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
-##
+
+#
+# Copyright (C) 2010 Christophe Caillet <quadchris at free.fr>
+#
+# 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 the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+#
use strict;
use warnings;
+use base qw( Exporter );
use English qw( -no_match_vars ); # Avoids regex performance penalty
-use Exporter;
use PFTools::Conf;
use PFTools::Logger;
use PFTools::Update::Common;
-
-our @ISA = ('Exporter');
our @EXPORT = qw(
Addlink_depends
diff -r 3fd194956c81 -r bdef630830f9 lib/PFTools/Update/Addmount.pm
--- a/lib/PFTools/Update/Addmount.pm Thu Sep 23 11:37:07 2010 +0200
+++ b/lib/PFTools/Update/Addmount.pm Thu Sep 23 15:58:33 2010 +0200
@@ -1,29 +1,28 @@
package PFTools::Update::Addmount;
-##
-## $Id$
-##
-## Copyright (C) 2010 Christophe Caillet <quadchris at free.fr>
-##
-## 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 the Free Software Foundation; either version 2
-## of the License, or (at your option) any later version.
-##
-## This program is distributed in the hope that it will be useful,
-## but WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-## GNU General Public License for more details.
-##
-## You should have received a copy of the GNU General Public License
-## along with this program; if not, write to the Free Software
-## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
-##
+
+#
+# Copyright (C) 2010 Christophe Caillet <quadchris at free.fr>
+#
+# 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 the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+#
use strict;
use warnings;
+use base qw( Exporter );
use English qw( -no_match_vars ); # Avoids regex performance penalty
-use Exporter;
use IO::File;
use File::Copy;
use Text::Diff;
@@ -36,8 +35,6 @@
use PFTools::Structqueries;
use PFTools::Update::Common;
use PFTools::Update::Mkdir;
-
-our @ISA = ('Exporter');
our @EXPORT = qw(
Addmount_depends
diff -r 3fd194956c81 -r bdef630830f9 lib/PFTools/Update/Common.pm
--- a/lib/PFTools/Update/Common.pm Thu Sep 23 11:37:07 2010 +0200
+++ b/lib/PFTools/Update/Common.pm Thu Sep 23 15:58:33 2010 +0200
@@ -1,36 +1,33 @@
package PFTools::Update::Common;
-##
-## $Id$
-##
-## Copyright (C) 2010 Christophe Caillet <quadchris at free.fr>
-##
-## 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 the Free Software Foundation; either version 2
-## of the License, or (at your option) any later version.
-##
-## This program is distributed in the hope that it will be useful,
-## but WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-## GNU General Public License for more details.
-##
-## You should have received a copy of the GNU General Public License
-## along with this program; if not, write to the Free Software
-## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
-##
+
+#
+# Copyright (C) 2010 Christophe Caillet <quadchris at free.fr>
+#
+# 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 the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+#
use strict;
use warnings;
+use base qw( Exporter );
use English qw( -no_match_vars ); # Avoids regex performance penalty
-use Exporter;
use File::Copy;
use File::Path qw( make_path );
use PFTools::Conf;
use PFTools::Logger;
-
-our @ISA = ('Exporter');
our @EXPORT = qw(
Do_on_config
diff -r 3fd194956c81 -r bdef630830f9 lib/PFTools/Update/Createfile.pm
--- a/lib/PFTools/Update/Createfile.pm Thu Sep 23 11:37:07 2010 +0200
+++ b/lib/PFTools/Update/Createfile.pm Thu Sep 23 15:58:33 2010 +0200
@@ -1,36 +1,33 @@
package PFTools::Update::Createfile;
-##
-## $Id$
-##
-## Copyright (C) 2010 Christophe Caillet <quadchris at free.fr>
-##
-## 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 the Free Software Foundation; either version 2
-## of the License, or (at your option) any later version.
-##
-## This program is distributed in the hope that it will be useful,
-## but WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-## GNU General Public License for more details.
-##
-## You should have received a copy of the GNU General Public License
-## along with this program; if not, write to the Free Software
-## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
-##
+
+#
+# Copyright (C) 2010 Christophe Caillet <quadchris at free.fr>
+#
+# 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 the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+#
use strict;
use warnings;
+use base qw( Exporter );
use English qw( -no_match_vars ); # Avoids regex performance penalty
-use Exporter;
use File::Copy;
use PFTools::Conf;
use PFTools::Logger;
use PFTools::Update::Common;
-
-our @ISA = ('Exporter');
our @EXPORT = qw(
Createfile_depends
diff -r 3fd194956c81 -r bdef630830f9 lib/PFTools/Update/Installpkg.pm
--- a/lib/PFTools/Update/Installpkg.pm Thu Sep 23 11:37:07 2010 +0200
+++ b/lib/PFTools/Update/Installpkg.pm Thu Sep 23 15:58:33 2010 +0200
@@ -1,39 +1,36 @@
package PFTools::Update::Installpkg;
-##
-## $Id$
-##
-## Copyright (C) 2010 Christophe Caillet <quadchris at free.fr>
-##
-## 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 the Free Software Foundation; either version 2
-## of the License, or (at your option) any later version.
-##
-## This program is distributed in the hope that it will be useful,
-## but WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-## GNU General Public License for more details.
-##
-## You should have received a copy of the GNU General Public License
-## along with this program; if not, write to the Free Software
-## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
-##
+
+#
+# Copyright (C) 2010 Christophe Caillet <quadchris at free.fr>
+#
+# 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 the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+#
use strict;
use warnings;
+use base qw( Exporter );
use Debconf::ConfModule;
use Debconf::Db;
use Debconf::Template;
use English qw( -no_match_vars ); # Avoids regex performance penalty
-use Exporter;
use PFTools::Conf;
use PFTools::Logger;
use PFTools::Packages;
use PFTools::Update::Common;
-
-our @ISA = ('Exporter');
our @EXPORT = qw(
Installpkg_depends
diff -r 3fd194956c81 -r bdef630830f9 lib/PFTools/Update/Mkdir.pm
--- a/lib/PFTools/Update/Mkdir.pm Thu Sep 23 11:37:07 2010 +0200
+++ b/lib/PFTools/Update/Mkdir.pm Thu Sep 23 15:58:33 2010 +0200
@@ -1,36 +1,33 @@
package PFTools::Update::Mkdir;
-##
-## $Id$
-##
-## Copyright (C) 2010 Christophe Caillet <quadchris at free.fr>
-##
-## 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 the Free Software Foundation; either version 2
-## of the License, or (at your option) any later version.
-##
-## This program is distributed in the hope that it will be useful,
-## but WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-## GNU General Public License for more details.
-##
-## You should have received a copy of the GNU General Public License
-## along with this program; if not, write to the Free Software
-## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
-##
+
+#
+# Copyright (C) 2010 Christophe Caillet <quadchris at free.fr>
+#
+# 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 the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+#
use strict;
use warnings;
+use base qw( Exporter );
use English qw( -no_match_vars ); # Avoids regex performance penalty
-use Exporter;
use File::Path qw( make_path );
use PFTools::Conf;
use PFTools::Logger;
use PFTools::Update::Common;
-
-our @ISA = ('Exporter');
our @EXPORT = qw(
Mkdir_depends
diff -r 3fd194956c81 -r bdef630830f9 lib/PFTools/Update/Purgepkg.pm
--- a/lib/PFTools/Update/Purgepkg.pm Thu Sep 23 11:37:07 2010 +0200
+++ b/lib/PFTools/Update/Purgepkg.pm Thu Sep 23 15:58:33 2010 +0200
@@ -1,36 +1,33 @@
package PFTools::Update::Purgepkg;
-##
-## $Id$
-##
-## Copyright (C) 2010 Christophe Caillet <quadchris at free.fr>
-##
-## 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 the Free Software Foundation; either version 2
-## of the License, or (at your option) any later version.
-##
-## This program is distributed in the hope that it will be useful,
-## but WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-## GNU General Public License for more details.
-##
-## You should have received a copy of the GNU General Public License
-## along with this program; if not, write to the Free Software
-## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
-##
+
+#
+# Copyright (C) 2010 Christophe Caillet <quadchris at free.fr>
+#
+# 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 the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+#
use strict;
use warnings;
+use base qw( Exporter );
use English qw( -no_match_vars ); # Avoids regex performance penalty
-use Exporter;
use PFTools::Conf;
use PFTools::Logger;
use PFTools::Packages;
use PFTools::Update::Common;
-
-our @ISA = ('Exporter');
our @EXPORT = qw(
Purgepkg_action
diff -r 3fd194956c81 -r bdef630830f9 lib/PFTools/Update/Removedir.pm
--- a/lib/PFTools/Update/Removedir.pm Thu Sep 23 11:37:07 2010 +0200
+++ b/lib/PFTools/Update/Removedir.pm Thu Sep 23 15:58:33 2010 +0200
@@ -1,35 +1,32 @@
package PFTools::Update::Removedir;
-##
-## $Id$
-##
-## Copyright (C) 2010 Christophe Caillet <quadchris at free.fr>
-##
-## 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 the Free Software Foundation; either version 2
-## of the License, or (at your option) any later version.
-##
-## This program is distributed in the hope that it will be useful,
-## but WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-## GNU General Public License for more details.
-##
-## You should have received a copy of the GNU General Public License
-## along with this program; if not, write to the Free Software
-## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
-##
+
+#
+# Copyright (C) 2010 Christophe Caillet <quadchris at free.fr>
+#
+# 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 the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+#
use strict;
use warnings;
+use base qw( Exporter );
use English qw( -no_match_vars ); # Avoids regex performance penalty
-use Exporter;
use PFTools::Conf;
use PFTools::Logger;
use PFTools::Update::Common;
-
-our @ISA = ('Exporter');
our @EXPORT = qw(
Removedir_action
diff -r 3fd194956c81 -r bdef630830f9 lib/PFTools/Update/Removefile.pm
--- a/lib/PFTools/Update/Removefile.pm Thu Sep 23 11:37:07 2010 +0200
+++ b/lib/PFTools/Update/Removefile.pm Thu Sep 23 15:58:33 2010 +0200
@@ -1,35 +1,32 @@
package PFTools::Update::Removefile;
-##
-## $Id$
-##
-## Copyright (C) 2010 Christophe Caillet <quadchris at free.fr>
-##
-## 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 the Free Software Foundation; either version 2
-## of the License, or (at your option) any later version.
-##
-## This program is distributed in the hope that it will be useful,
-## but WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-## GNU General Public License for more details.
-##
-## You should have received a copy of the GNU General Public License
-## along with this program; if not, write to the Free Software
-## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
-##
+
+#
+# Copyright (C) 2010 Christophe Caillet <quadchris at free.fr>
+#
+# 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 the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+#
use strict;
use warnings;
+use base qw( Exporter );
use English qw( -no_match_vars ); # Avoids regex performance penalty
-use Exporter;
use PFTools::Conf;
use PFTools::Logger;
use PFTools::Update::Common;
-
-our @ISA = ('Exporter');
our @EXPORT = qw(
Removefile_action
diff -r 3fd194956c81 -r bdef630830f9 lib/PFTools/Utils.pm
--- a/lib/PFTools/Utils.pm Thu Sep 23 11:37:07 2010 +0200
+++ b/lib/PFTools/Utils.pm Thu Sep 23 15:58:33 2010 +0200
@@ -1,28 +1,28 @@
package PFTools::Utils;
-##
-## Copyright (C) 2010 Christophe Caillet <quadchris at free.fr>
-##
-## 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 the Free Software Foundation; either version 2
-## of the License, or (at your option) any later version.
-##
-## This program is distributed in the hope that it will be useful,
-## but WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-## GNU General Public License for more details.
-##
-## You should have received a copy of the GNU General Public License
-## along with this program; if not, write to the Free Software
-## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
-##
+#
+# Copyright (C) 2010 Christophe Caillet <quadchris at free.fr>
+#
+# 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 the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+#
use strict;
use warnings;
+use base qw( Exporter );
use Digest::MD5;
use English qw( -no_match_vars ); # Avoids regex performance penalty
-use Exporter;
use File::Compare;
use File::Copy;
use IO::File;
@@ -34,8 +34,6 @@
use PFTools::Structqueries;
use PFTools::Update;
use PFTools::VCS;
-
-our @ISA = ('Exporter');
our @EXPORT = qw(
Init_TOOLS
@@ -58,24 +56,13 @@
our @EXPORT_OK = qw();
#########################################################################
-# Prototypes : needed by recursive calls
-
-sub __Do_updateloop ($$$$$);
-
-#########################################################################
# Functions
sub Init_TOOLS ($;$$$) {
my ( $hostname, $pf_config_file, $global_store_file, $reload ) = @_;
my ( $pf_config, $global_struct );
- if ( $pf_config_file && $pf_config_file ne '' ) {
- if ( !-e $pf_config_file ) {
- Abort( $CODE->{'OPEN'},
- "Unable to open configuration file "
- . $pf_config_file
- . " : no such file or directory" );
- }
+ if ( $pf_config_file ) {
$pf_config = Init_PF_CONFIG($pf_config_file);
}
elsif ( -e '/etc/pf-tools.conf' ) {
@@ -998,7 +985,7 @@
return $interfaces;
}
-sub __Do_updateloop ($$$$$) {
+sub __Do_updateloop {
my ( $host_config, $options, $hash_subst, $global_config, $sortedkeys )
= @_;
my $errorcount = 0;
diff -r 3fd194956c81 -r bdef630830f9 lib/PFTools/VCS.pm
--- a/lib/PFTools/VCS.pm Thu Sep 23 11:37:07 2010 +0200
+++ b/lib/PFTools/VCS.pm Thu Sep 23 15:58:33 2010 +0200
@@ -1,34 +1,33 @@
package PFTools::VCS;
-##
-## Copyright (C) 2010 Christophe Caillet <quadchris at free.fr>
-##
-## 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 the Free Software Foundation; either version 2
-## of the License, or (at your option) any later version.
-##
-## This program is distributed in the hope that it will be useful,
-## but WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-## GNU General Public License for more details.
-##
-## You should have received a copy of the GNU General Public License
-## along with this program; if not, write to the Free Software
-## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
-##
+
+#
+# Copyright (C) 2010 Christophe Caillet <quadchris at free.fr>
+#
+# 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 the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+#
use strict;
use warnings;
+use base qw( Exporter );
use Carp;
use English qw( -no_match_vars ); # Avoids regex performance penalty
-use Exporter;
use File::Path qw( make_path remove_tree );
use Module::Runtime qw ( use_module );
use PFTools::Logger;
-
-our @ISA = ('Exporter');
our @EXPORT = qw(
VCS_checkout
diff -r 3fd194956c81 -r bdef630830f9 lib/PFTools/VCS/CVS.pm
--- a/lib/PFTools/VCS/CVS.pm Thu Sep 23 11:37:07 2010 +0200
+++ b/lib/PFTools/VCS/CVS.pm Thu Sep 23 15:58:33 2010 +0200
@@ -1,34 +1,33 @@
package PFTools::VCS::CVS;
-##
-## Copyright (C) 2010 Christophe Caillet <quadchris at free.fr>
-##
-## 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 the Free Software Foundation; either version 2
-## of the License, or (at your option) any later version.
-##
-## This program is distributed in the hope that it will be useful,
-## but WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-## GNU General Public License for more details.
-##
-## You should have received a copy of the GNU General Public License
-## along with this program; if not, write to the Free Software
-## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
-## USA
-##
+
+#
+# Copyright (C) 2010 Christophe Caillet <quadchris at free.fr>
+#
+# 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 the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+# USA
+#
use strict;
use warnings;
+use base qw( Exporter );
use Carp;
use English qw( -no_match_vars ); # Avoids regex performance penalty
-use Exporter;
use File::Path qw( make_path remove_tree );
use PFTools::Logger;
-
-our @ISA = ('Exporter');
our @EXPORT = qw(
checkout
diff -r 3fd194956c81 -r bdef630830f9 lib/PFTools/VCS/SVN.pm
--- a/lib/PFTools/VCS/SVN.pm Thu Sep 23 11:37:07 2010 +0200
+++ b/lib/PFTools/VCS/SVN.pm Thu Sep 23 15:58:33 2010 +0200
@@ -1,34 +1,33 @@
package PFTools::VCS::SVN;
-##
-## Copyright (C) 2010 Christophe Caillet <quadchris at free.fr>
-##
-## 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 the Free Software Foundation; either version 2
-## of the License, or (at your option) any later version.
-##
-## This program is distributed in the hope that it will be useful,
-## but WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-## GNU General Public License for more details.
-##
-## You should have received a copy of the GNU General Public License
-## along with this program; if not, write to the Free Software
-## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
-## USA
-##
+
+#
+# Copyright (C) 2010 Christophe Caillet <quadchris at free.fr>
+#
+# 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 the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+# USA
+#
use strict;
use warnings;
+use base qw( Exporter );
use Carp;
use English qw( -no_match_vars ); # Avoids regex performance penalty
-use Exporter;
use File::Path qw( make_path remove_tree );
use PFTools::Logger;
-
-our @ISA = ('Exporter');
our @EXPORT = qw(
checkout
@@ -37,17 +36,23 @@
sub checkout {
my ( $hostname, $pf_config, $options ) = @_;
- unless( $hostname or $pf_config or $options ) {
- carp q{ERROR: $hostname, $pf_config, $options are invalid}
- return;
+ unless ($hostname) {
+ croak q{ERROR: Invalid undefined or empty $hostname};
}
- if( ref $hostname ) {
- carp q{ERROR: $hostname MUST BE a string};
- return;
+ unless ($pf_config) {
+ croak q{ERROR: Invalid undefined or empty $pf_config};
}
- unless( $pf_config eq 'HASH' or $options eq 'HASH' ) {
- carp q{ERROR: non-ref $pf_config and/or $options};
- return;
+ unless ($options) {
+ croak q{ERROR: Invalid undefined or empty $options};
+ }
+ if ( ref $hostname ) {
+ croak q{ERROR: Invalid non-scalar $hostname};
+ }
+ if ( ref $pf_config ne 'HASH' ) {
+ croak q{ERROR: Invalid non-hashref $pf_config};
+ }
+ if ( ref $options ne 'HASH' ) {
+ croak q{ERROR: Invalid non-hashref $options};
}
my $svn_cmd = $pf_config->{'vcs'}->{'command'};
diff -r 3fd194956c81 -r bdef630830f9 sbin/fix_hosts
--- a/sbin/fix_hosts Thu Sep 23 11:37:07 2010 +0200
+++ b/sbin/fix_hosts Thu Sep 23 15:58:33 2010 +0200
@@ -1,27 +1,28 @@
#!/usr/bin/perl
-##
-## Copyright (C) 2007-2010 Christophe Caillet <quadchris at free.fr>
-##
-## 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 the Free Software Foundation; either version 2
-## of the License, or (at your option) any later version.
-##
-## This program is distributed in the hope that it will be useful,
-## but WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-## GNU General Public License for more details.
-##
-## You should have received a copy of the GNU General Public License
-## along with this program; if not, write to the Free Software
-## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
-## USA
-##
+#
+# Copyright (C) 2007-2010 Christophe Caillet <quadchris at free.fr>
+#
+# 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 the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+# USA
+#
use strict;
use warnings;
use English qw( -no_match_vars ); # Avoids regex performance penalty
+use File::Basename;
use Getopt::Long qw( :config ignore_case_always bundling );
use IO::File;
use Sys::Hostname;
@@ -56,8 +57,7 @@
my $PF_CONFIG = {};
my $GLOBAL_STRUCT = {};
-my $program = $0;
-$program =~ s%.*/%%; # cheap basename
+my $program = basename $PROGRAM_NAME;
###################################
# Funtions
diff -r 3fd194956c81 -r bdef630830f9 sbin/mk_dhcp
--- a/sbin/mk_dhcp Thu Sep 23 11:37:07 2010 +0200
+++ b/sbin/mk_dhcp Thu Sep 23 15:58:33 2010 +0200
@@ -1,29 +1,30 @@
#!/usr/bin/perl
-##
-## Copyright (C) 2007-2008 Christophe Caillet <quadchris at free.fr>
-## Copyright (C) 2003-2005 Damien Clermonte <damien at sitadelle.com>
-## Copyright (C) 2001-2003 Olivier Molteni <olivier at molteni.net>
-##
-## 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 the Free Software Foundation; either version 2
-## of the License, or (at your option) any later version.
-##
-## This program is distributed in the hope that it will be useful,
-## but WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-## GNU General Public License for more details.
-##
-## You should have received a copy of the GNU General Public License
-## along with this program; if not, write to the Free Software
-## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
-## USA
-##
+#
+# Copyright (C) 2007-2008 Christophe Caillet <quadchris at free.fr>
+# Copyright (C) 2003-2005 Damien Clermonte <damien at sitadelle.com>
+# Copyright (C) 2001-2003 Olivier Molteni <olivier at molteni.net>
+#
+# 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 the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+# USA
+#
use strict;
use warnings;
use English qw( -no_match_vars ); # Avoids regex performance penalty
+use File::Basename;
use Getopt::Long qw( :config ignore_case_always bundling );
use IO::File;
@@ -55,10 +56,7 @@
my $PF_CONFIG = {};
my $GLOBAL_STRUCT = {};
-my $program = $0;
-$program =~ s%.*/%%; # cheap basename
-
-#my $version = sprintf( "svn-r%s", q$Revision$ =~ /([\d.]+)/ );
+my $program = basename $PROGRAM_NAME;
#####################################
# Functions
diff -r 3fd194956c81 -r bdef630830f9 sbin/mk_grubopt
--- a/sbin/mk_grubopt Thu Sep 23 11:37:07 2010 +0200
+++ b/sbin/mk_grubopt Thu Sep 23 15:58:33 2010 +0200
@@ -1,26 +1,27 @@
#!/usr/bin/perl
-##
-## Copyright (C) 2007-2010 Christophe Caillet <quadchris at free.fr>
-##
-## 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 the Free Software Foundation; either version 2
-## of the License, or (at your option) any later version.
-##
-## This program is distributed in the hope that it will be useful,
-## but WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-## GNU General Public License for more details.
-##
-## You should have received a copy of the GNU General Public License
-## along with this program; if not, write to the Free Software
-## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
-##
+#
+# Copyright (C) 2007-2010 Christophe Caillet <quadchris at free.fr>
+#
+# 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 the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+#
use strict;
use warnings;
use English qw( -no_match_vars ); # Avoids regex performance penalty
+use File::Basename;
use Getopt::Long qw( :config ignore_case_always bundling );
use Sys::Hostname;
@@ -54,8 +55,7 @@
my $PF_CONFIG = {};
my $GLOBAL_STRUCT = {};
-my $program = $0;
-$program =~ s%.*/%%; # cheap basename
+my $program = basename $PROGRAM_NAME;
######################################################
# Functions
diff -r 3fd194956c81 -r bdef630830f9 sbin/mk_interfaces
--- a/sbin/mk_interfaces Thu Sep 23 11:37:07 2010 +0200
+++ b/sbin/mk_interfaces Thu Sep 23 15:58:33 2010 +0200
@@ -1,29 +1,30 @@
#!/usr/bin/perl
-##
-## Copyright (C) 2007-2010 Christophe Caillet <quadchris at free.fr>
-## Copyright (C) 2003-2005 Damien Clermonte <damien at sitadelle.com>
-## Copyright (C) 2001-2003 Olivier Molteni <olivier at molteni.net>
-##
-## 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 the Free Software Foundation; either version 2
-## of the License, or (at your option) any later version.
-##
-## This program is distributed in the hope that it will be useful,
-## but WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-## GNU General Public License for more details.
-##
-## You should have received a copy of the GNU General Public License
-## along with this program; if not, write to the Free Software
-## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
-## USA
-##
+#
+# Copyright (C) 2007-2010 Christophe Caillet <quadchris at free.fr>
+# Copyright (C) 2003-2005 Damien Clermonte <damien at sitadelle.com>
+# Copyright (C) 2001-2003 Olivier Molteni <olivier at molteni.net>
+#
+# 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 the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+# USA
+#
use strict;
use warnings;
use English qw( -no_match_vars ); # Avoids regex performance penalty
+use File::Basename;
use Getopt::Long qw( :config ignore_case_always bundling );
use IO::File;
use Sys::Hostname;
@@ -59,15 +60,13 @@
"#\n",
);
-my $program = $0;
-$program =~ s%.*/%%; # cheap basename
+my $program = basename $PROGRAM_NAME;
###################################
# Funtions
sub Do_help {
print STDERR << "# ENDHELP";
-
Usage: $program [options]
--help : print help and exit
-h --host : hostname for which we want to build interfaces file
diff -r 3fd194956c81 -r bdef630830f9 sbin/mk_pxelinuxcfg
--- a/sbin/mk_pxelinuxcfg Thu Sep 23 11:37:07 2010 +0200
+++ b/sbin/mk_pxelinuxcfg Thu Sep 23 15:58:33 2010 +0200
@@ -1,29 +1,30 @@
#!/usr/bin/perl
-##
-## Copyright (C) 2007-2010 Christophe Caillet <quadchris at free.fr>
-## Copyright (C) 2003-2005 Damien Clermonte <damien at sitadelle.com>
-## Copyright (C) 2001-2003 Olivier Molteni <olivier at molteni.net>
-##
-## 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 the Free Software Foundation; either version 2
-## of the License, or (at your option) any later version.
-##
-## This program is distributed in the hope that it will be useful,
-## but WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-## GNU General Public License for more details.
-##
-## You should have received a copy of the GNU General Public License
-## along with this program; if not, write to the Free Software
-## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
-## USA
-##
+#
+# Copyright (C) 2007-2010 Christophe Caillet <quadchris at free.fr>
+# Copyright (C) 2003-2005 Damien Clermonte <damien at sitadelle.com>
+# Copyright (C) 2001-2003 Olivier Molteni <olivier at molteni.net>
+#
+# 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 the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+# USA
+#
use strict;
use warnings;
use English qw( -no_match_vars ); # Avoids regex performance penalty
+use File::Basename;
use Getopt::Long qw( :config ignore_case_always bundling );
use File::Path qw( make_path );
@@ -53,8 +54,7 @@
my $GLOBAL_STRUCT = {};
my $DEFAULT_PRESEED = '';
-my $program = $0;
-$program =~ s%.*/%%; # cheap basename
+my $program = basename $PROGRAM_NAME;
############################################
diff -r 3fd194956c81 -r bdef630830f9 sbin/mk_resolvconf
--- a/sbin/mk_resolvconf Thu Sep 23 11:37:07 2010 +0200
+++ b/sbin/mk_resolvconf Thu Sep 23 15:58:33 2010 +0200
@@ -1,28 +1,29 @@
#!/usr/bin/perl
-##
-## Copyright (C) 2007-2010 Christophe Caillet <quadchris at free.fr>
-## Copyright (C) 2003-2005 Damien Clermonte <damien at sitadelle.com>
-## Copyright (C) 2001-2003 Olivier Molteni <olivier at molteni.net>
-##
-## 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 the Free Software Foundation; either version 2
-## of the License, or (at your option) any later version.
-##
-## This program is distributed in the hope that it will be useful,
-## but WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-## GNU General Public License for more details.
-##
-## You should have received a copy of the GNU General Public License
-## along with this program; if not, write to the Free Software
-## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
-##
+#
+# Copyright (C) 2007-2010 Christophe Caillet <quadchris at free.fr>
+# Copyright (C) 2003-2005 Damien Clermonte <damien at sitadelle.com>
+# Copyright (C) 2001-2003 Olivier Molteni <olivier at molteni.net>
+#
+# 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 the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+#
use strict;
use warnings;
use English qw( -no_match_vars ); # Avoids regex performance penalty
+use File::Basename;
use Getopt::Long qw( :config ignore_case_always bundling );
use Sys::Hostname;
@@ -51,8 +52,7 @@
my $PF_CONFIG = {};
my $GLOBAL_STRUCT = {};
-my $program = $0;
-$program =~ s%.*/%%; # cheap basename
+my $program = basename $PROGRAM_NAME;
###################################
# Funtions
diff -r 3fd194956c81 -r bdef630830f9 sbin/mk_sitezone
--- a/sbin/mk_sitezone Thu Sep 23 11:37:07 2010 +0200
+++ b/sbin/mk_sitezone Thu Sep 23 15:58:33 2010 +0200
@@ -1,27 +1,28 @@
#!/usr/bin/perl
-##
-## Copyright (C) 2010 Christophe Caillet <quadchris at free.fr>
-##
-## 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 the Free Software Foundation; either version 2
-## of the License, or (at your option) any later version.
-##
-## This program is distributed in the hope that it will be useful,
-## but WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-## GNU General Public License for more details.
-##
-## You should have received a copy of the GNU General Public License
-## along with this program; if not, write to the Free Software
-## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
-## USA
-##
+#
+# Copyright (C) 2010 Christophe Caillet <quadchris at free.fr>
+#
+# 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 the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+# USA
+#
use strict;
use warnings;
use English qw( -no_match_vars ); # Avoids regex performance penalty
+use File::Basename;
use Getopt::Long qw( :config ignore_case_always bundling );
use IO::File;
@@ -47,8 +48,7 @@
my $PF_CONFIG = {};
my $GLOBAL_STRUCT = {};
-my $program = $0;
-$program =~ s%.*/%%; # cheap basename
+my $program = basename $PROGRAM_NAME;
#################################################
# Functions
diff -r 3fd194956c81 -r bdef630830f9 sbin/mk_sourceslist
--- a/sbin/mk_sourceslist Thu Sep 23 11:37:07 2010 +0200
+++ b/sbin/mk_sourceslist Thu Sep 23 15:58:33 2010 +0200
@@ -1,27 +1,28 @@
#!/usr/bin/perl
-##
-## Copyright (C) 2007-2010 Christophe Caillet <quadchris at free.fr>
-##
-## 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 the Free Software Foundation; either version 2
-## of the License, or (at your option) any later version.
-##
-## This program is distributed in the hope that it will be useful,
-## but WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-## GNU General Public License for more details.
-##
-## You should have received a copy of the GNU General Public License
-## along with this program; if not, write to the Free Software
-## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
-## USA
-##
+#
+# Copyright (C) 2007-2010 Christophe Caillet <quadchris at free.fr>
+#
+# 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 the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+# USA
+#
use strict;
use warnings;
use English qw( -no_match_vars ); # Avoids regex performance penalty
+use File::Basename;
use Getopt::Long qw( :config ignore_case_always bundling );
use Sys::Hostname;
@@ -56,8 +57,7 @@
my $PF_CONFIG = {};
my $GLOBAL_STRUCT = {};
-my $program = $0;
-$program =~ s%.*/%%; # cheap basename
+my $program = basename $PROGRAM_NAME;
############################################
# Functions
diff -r 3fd194956c81 -r bdef630830f9 sbin/update-config
--- a/sbin/update-config Thu Sep 23 11:37:07 2010 +0200
+++ b/sbin/update-config Thu Sep 23 15:58:33 2010 +0200
@@ -1,29 +1,30 @@
#!/usr/bin/perl
-##
-## Copyright (C) 2007-2010 Christophe Caillet <quadchris at free.fr>
-## Copyright (C) 2003-2005 Damien Clermonte <damien at sitadelle.com>
-## Copyright (C) 2001-2003 Olivier Molteni <olivier at molteni.net>
-##
-## 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 the Free Software Foundation; either version 2
-## of the License, or (at your option) any later version.
-##
-## This program is distributed in the hope that it will be useful,
-## but WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-## GNU General Public License for more details.
-##
-## You should have received a copy of the GNU General Public License
-## along with this program; if not, write to the Free Software
-## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
-## USA
-##
+#
+# Copyright (C) 2007-2010 Christophe Caillet <quadchris at free.fr>
+# Copyright (C) 2003-2005 Damien Clermonte <damien at sitadelle.com>
+# Copyright (C) 2001-2003 Olivier Molteni <olivier at molteni.net>
+#
+# 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 the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+# USA
+#
use strict;
use warnings;
use English qw( -no_match_vars ); # Avoids regex performance penalty
+use File::Basename;
use Getopt::Long qw( :config ignore_case_always bundling );
use Sys::Hostname;
@@ -37,8 +38,7 @@
my $PF_CONFIG = {};
my $GLOBAL_STRUCT = {};
-my $program = $0;
-$program =~ s%.*/%%; # cheap basename
+my $program = basename $PROGRAM_NAME;
###################################
diff -r 3fd194956c81 -r bdef630830f9 t/13.conf.t
--- a/t/13.conf.t Thu Sep 23 11:37:07 2010 +0200
+++ b/t/13.conf.t Thu Sep 23 15:58:33 2010 +0200
@@ -323,3 +323,46 @@
unlink $global_config_file;
remove_tree( qw( /tmp/pftools-conf-test/ ) );
+
+########################################################################
+note('Testing PFTools::Conf::Load_conf');
+can_ok( 'PFTools::Conf', qw( Load_conf ) );
+
+ok !defined Load_conf()
+ => 'Returns undef if no args';
+
+ok !defined Load_conf( 'file' )
+ => 'Returns undef if only one arg';
+
+ok !defined Load_conf( 'file', {} )
+ => 'Returns undef if only two args';
+
+ok !defined Load_conf( 'file', {}, 'context' )
+ => 'Returns undef if only three args';
+
+throws_ok { Load_conf( {}, {}, 'context', {} ) }
+ qr{ \A ERROR: [ ] Invalid [ ] non-scalar [ ] [\$] file }xms
+ => q{Dies if non-scalar $file};
+
+throws_ok { Load_conf( 'file', {}, {}, {} ) }
+ qr{ \A ERROR: [ ] Invalid [ ] non-scalar [ ] [\$] context }xms
+ => q{Dies if non-scalar $context};
+
+throws_ok { Load_conf( 'file', 'subst', 'context', {} ) }
+ qr{ \A ERROR: [ ] Invalid [ ] non-hashref [ ] [\$] hash_subst }xms
+ => q{Dies if non-hashref $hash_subst};
+
+throws_ok { Load_conf( 'file', {}, 'context', 'pf_config' ) }
+ qr{ \A ERROR: [ ] Invalid [ ] non-hashref [ ] [\$] pf_config }xms
+ => q{Dies if non-hashref $pf_config};
+
+throws_ok { Load_conf( 'file', {}, 'context', {} ) }
+ qr{ \A ERROR: [ ] Invalid [ ] context [ ] }xms
+ => q{Dies if invalid $context};
+
+throws_ok { Load_conf( 'inexistent file', {}, 'config', {} ) }
+ qr{ \A ERROR: [ ] Unable [ ] to [ ] load [ ] }xms
+ => q{Dies if inexistent $file};
+
+diag( 'FIXME: other tests needed here for Load_conf() with real files and contexts' );
+
diff -r 3fd194956c81 -r bdef630830f9 tools/Display_IP_config
--- a/tools/Display_IP_config Thu Sep 23 11:37:07 2010 +0200
+++ b/tools/Display_IP_config Thu Sep 23 15:58:33 2010 +0200
@@ -1,22 +1,22 @@
#!/usr/bin/perl
-##
-## Copyright (C) 2008-2010 Christophe Caillet <quadchris at free.fr>
-## Copyright (C) 2004 Stephane Pontier <shad at sitadelle.com>
-##
-## 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 the Free Software Foundation; either version 2
-## of the License, or (at your option) any later version.
-##
-## This program is distributed in the hope that it will be useful,
-## but WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-## GNU General Public License for more details.
-##
-## You should have received a copy of the GNU General Public License
-## along with this program; if not, write to the Free Software
-## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
-##
+#
+# Copyright (C) 2008-2010 Christophe Caillet <quadchris at free.fr>
+# Copyright (C) 2004 Stephane Pontier <shad at sitadelle.com>
+#
+# 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 the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+#
# liste toute les adresses ip depuis le fichier private-network
# prend le fichier private-network en argument et un 1 en second
@@ -25,8 +25,8 @@
use strict;
use warnings;
-use Data::Dumper;
use English qw( -no_match_vars ); # Avoids regex performance penalty
+use File::Basename;
use Getopt::Long qw ( :config ignore_case_always bundling );
use NetAddr::IP;
@@ -54,8 +54,7 @@
my $PF_CONFIG = {};
my $GLOBAL_STRUCT = {};
-my $program = $0;
-$program =~ s%.*/%%; # cheap basename
+my $program = basename $PROGRAM_NAME;
######################################################
# Functions
diff -r 3fd194956c81 -r bdef630830f9 tools/Translate_old_config
--- a/tools/Translate_old_config Thu Sep 23 11:37:07 2010 +0200
+++ b/tools/Translate_old_config Thu Sep 23 15:58:33 2010 +0200
@@ -1,24 +1,22 @@
#!/usr/bin/perl
-##
-## $Id$
-##
-## Copyright (C) 2008-2010 Christophe Caillet <quadchris at free.fr>
-## Copyright (C) 2004 Stephane Pontier <shad at sitadelle.com>
-##
-## 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 the Free Software Foundation; either version 2
-## of the License, or (at your option) any later version.
-##
-## This program is distributed in the hope that it will be useful,
-## but WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-## GNU General Public License for more details.
-##
-## You should have received a copy of the GNU General Public License
-## along with this program; if not, write to the Free Software
-## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
-##
+#
+# Copyright (C) 2008-2010 Christophe Caillet <quadchris at free.fr>
+# Copyright (C) 2004 Stephane Pontier <shad at sitadelle.com>
+#
+# 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 the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+#
# liste toute les adresses ip depuis le fichier private-network
# prend le fichier private-network en argument et un 1 en second
@@ -28,6 +26,7 @@
use warnings;
use Data::Dumper;
+use File::Basename;
use English qw( -no_match_vars ); # Avoids regex performance penalty
use Getopt::Long qw ( :config ignore_case_always bundling );
@@ -43,18 +42,13 @@
my $TYPE = "config";
my $HELP = 0;
-my $program = $0;
-$program =~ s%.*/%%; # cheap basename
-
-my $version = sprintf( "svn-r%s", q$Revision$ =~ /([\d.]+)/ );
+my $program = basename $PROGRAM_NAME;
#################################
# Functions
sub Do_help () {
print STDERR << "# ENDHELP";
- $program - version $version
-
Usage: $program [options]
--help : print help and exit
-t --type : type of configuration file, allowed types are : config, network
diff -r 3fd194956c81 -r bdef630830f9 tools/kvmlaunch
--- a/tools/kvmlaunch Thu Sep 23 11:37:07 2010 +0200
+++ b/tools/kvmlaunch Thu Sep 23 15:58:33 2010 +0200
@@ -1,8 +1,4 @@
#!/usr/bin/perl
-#
-# $Id$
-#
-
#
# Copyright (C) 2009 Thomas Parmelan <tom+pf-tools at ankh.fr.EU.org>
#
@@ -34,12 +30,15 @@
use Carp;
use Digest::CRC qw( crc32_hex );
use English qw( -no_match_vars ); # Avoids regex performance penalty
+use File::Basename;
use File::Path;
use Getopt::Long;
use PFTools::Conf;
use PFTools::Net;
use PFTools::Update;
+
+my $program = basename $PROGRAM_NAME;
#$PFTools::Conf::PFTOOLS_VARS->{'UML'} = 1;
@@ -234,7 +233,7 @@
sub usage {
warn <<"EOH";
-Usage: $0 [options] [hostregexp|hostlist] ...
+Usage: $program [options] [hostregexp|hostlist] ...
Options:
--oneeach (-1) Ignore any host arg and launch 1 VM of each existing
host type.
diff -r 3fd194956c81 -r bdef630830f9 tools/umlaunch
--- a/tools/umlaunch Thu Sep 23 11:37:07 2010 +0200
+++ b/tools/umlaunch Thu Sep 23 15:58:33 2010 +0200
@@ -1,27 +1,22 @@
#!/usr/bin/perl
#
-# $Id$
-# $Name$
+# Copyright (C) 2004-2007 Thomas Parmelan <tom+pf-tools at ankh.fr.EU.org>
+# Copyright (C) 2003-2005 Damien Clermonte <damien at sitadelle.com>
#
-
-##
-## Copyright (C) 2004-2007 Thomas Parmelan <tom+pf-tools at ankh.fr.EU.org>
-## Copyright (C) 2003-2005 Damien Clermonte <damien at sitadelle.com>
-##
-## 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 the Free Software Foundation; either version 2
-## of the License, or (at your option) any later version.
-##
-## This program is distributed in the hope that it will be useful,
-## but WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-## GNU General Public License for more details.
-##
-## You should have received a copy of the GNU General Public License
-## along with this program; if not, write to the Free Software
-## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
-##
+# 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 the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+#
use strict;
use warnings;
@@ -35,6 +30,8 @@
use PFTools::Conf;
use PFTools::Net;
use PFTools::Update;
+
+my $program = basename $PROGRAM_NAME;
$PFTools::Conf::PFTOOLS_VARS->{'UML'} = 1;
@@ -77,7 +74,7 @@
) or die "GetOptions error, try --help";
if ( $options->{'help'} ) {
- print STDERR "Usage: $0 [options] [hostregexp] ...\n";
+ print STDERR "Usage: $program [options] [hostregexp] ...\n";
print STDERR "Options:\n";
print STDERR "\t-1 --oneeach 1 machine de chaque\n";
print STDERR "\t --detached deployer en tache de fond\n";
@@ -95,7 +92,7 @@
}
if ( !defined( $ARGV[0] ) ) {
- print STDERR "Usage: " . $0 . " host ...\n";
+ print STDERR "Usage: " . $program . " host ...\n";
exit 1;
}
diff -r 3fd194956c81 -r bdef630830f9 tools/xenlaunch
--- a/tools/xenlaunch Thu Sep 23 11:37:07 2010 +0200
+++ b/tools/xenlaunch Thu Sep 23 15:58:33 2010 +0200
@@ -1,32 +1,34 @@
#!/usr/bin/perl
-
-##
-## Copyright (C) 2005 Gonéri Le Bouder <goneri at sitadelle.com>
-##
-## 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 the Free Software Foundation; either version 2
-## of the License, or (at your option) any later version.
-##
-## This program is distributed in the hope that it will be useful,
-## but WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-## GNU General Public License for more details.
-##
-## You should have received a copy of the GNU General Public License
-## along with this program; if not, write to the Free Software
-## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
-##
+#
+# Copyright (C) 2005 Gonéri Le Bouder <goneri at sitadelle.com>
+#
+# 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 the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+#
use strict;
use warnings;
use Data::Dumper;
use English qw( -no_match_vars ); # Avoids regex performance penalty
+use File::Basename;
use File::Path qw( make_path );
use Getopt::Long;
use Sitalibs::Config;
+
+my $program = basename $PROGRAM_NAME;
my $XENCFGDIR = "/etc/xen";
my $KERNELDIR = "/distrib/tftpboot";
@@ -179,7 +181,7 @@
) or die "GetOptions error, try --help";
if ( $options->{'help'} ) {
- print STDERR "Usage: $0 [options] [hostregexp] ...\n";
+ print STDERR "Usage: $program [options] [hostregexp] ...\n";
print STDERR "Options:\n";
# print STDERR "\t-1 --oneeach 1 machine de chaque\n";
@@ -197,7 +199,7 @@
}
if ( !defined( $ARGV[0] ) ) {
- print STDERR "Usage: " . $0 . " host ...\n";
+ print STDERR "Usage: " . $program . " host ...\n";
exit 1;
}
More information about the pf-tools-commits
mailing list