pf-tools/pf-tools: 2 new changesets
parmelan-guest at users.alioth.debian.org
parmelan-guest at users.alioth.debian.org
Fri Sep 10 12:17:06 UTC 2010
changeset 9e4b2dc80f87 in /srv/hg.debian.org/hg/pf-tools/pf-tools
details: http://hg.debian.org/hg/pf-tools/pf-tools/pf-tools/pf-tools?cmd=changeset;node=9e4b2dc80f87
summary: Create the first test
changeset 38223b4691e9 in /srv/hg.debian.org/hg/pf-tools/pf-tools
details: http://hg.debian.org/hg/pf-tools/pf-tools/pf-tools/pf-tools?cmd=changeset;node=38223b4691e9
summary: merge before push
diffstat:
6 files changed, 138 insertions(+), 3 deletions(-)
debian/changelog | 1
lib/PFTools.pm | 16 ++++++++++++++
lib/PFTools/VCS.pm | 3 --
lib/PFTools/VCS/CVS.pm | 52 ++++++++++++++++++++++++++++++++++++++++++++++++
lib/PFTools/VCS/SVN.pm | 48 ++++++++++++++++++++++++++++++++++++++++++++
t/00.load.t | 21 +++++++++++++++++++
diffs (truncated from 562 to 300 lines):
diff -r 20e25f26bf06 -r 38223b4691e9 debian/changelog
--- a/debian/changelog Thu Sep 09 11:50:40 2010 +0000
+++ b/debian/changelog Fri Sep 10 13:41:35 2010 +0200
@@ -8,14 +8,21 @@
* Start using perltidy --perl-best-practices
* Use English
* Don't call mkdir, use File::Path's make_path() instead.
+ * Start writing some tests in t/*.t (run with "make test" or "prove -l").
[ Christophe Caillet ]
* use remove_tree with keep_root option instead of remove_tree + make_path
* use remove_tree only if $co_dir exists
* fix Get_source: hostname IS NOT mandatory
* use IO::File in sbin/*
+ * removing $Id$ line wich can introduce conflicts wiuth mercurial' push
+ * using Module::Runtime in PFTools::VCS with same function name on both
+ module PFTools::VCS::CVS and PFTools::VCS::SVN
+ * adding PFTools::VCS::CVS and PFTools::VCS::SVN
+ * fix depends on debian/control with libmodule-runtime-perl
+ * IO::File on Addmount (see README.coding.style)
- -- Christophe Caillet <quadchris at free.fr> Wed, 08 Sep 2010 15:00:52 +0200
+ -- Thomas Parmelan <tom at sitadelle.com> Fri, 10 Sep 2010 09:16:02 +0200
pf-tools (1.0-1) unstable; urgency=low
diff -r 20e25f26bf06 -r 38223b4691e9 debian/control
--- a/debian/control Thu Sep 09 11:50:40 2010 +0000
+++ b/debian/control Fri Sep 10 13:41:35 2010 +0200
@@ -8,7 +8,7 @@
Package: pf-tools
Architecture: all
-Depends: perl, perl (>= 5.10.0) | libmd5-perl, libconfig-inifiles-perl, libnetaddr-ip-perl, libnet-dns-perl, libtemplate-tiny-perl, libtext-diff-perl, cvs, ssh, iproute, debconf, psmisc
+Depends: perl, perl (>= 5.10.0) | libmd5-perl, libconfig-inifiles-perl, libnetaddr-ip-perl, libnet-dns-perl, libtemplate-tiny-perl, libtext-diff-perl, libmodule-runtime-perl, cvs, ssh, iproute, debconf, psmisc
Description: Outils de gestion de la plateforme
Mise a jour automatique et generation de conf.
Deploiement de machines.
diff -r 20e25f26bf06 -r 38223b4691e9 lib/PFTools.pm
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/PFTools.pm Fri Sep 10 13:41:35 2010 +0200
@@ -0,0 +1,33 @@
+package PFTools;
+
+#
+# Copyright (C) 2010 Thomas Parmelan <tom+pf-tools at ankh.fr.EU.org>
+#
+# 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
+
+#our @EXPORT = qw();
+#our @EXPORT_OK = qw();
+
+our $VERSION = '1.0.1-WIP';
+
+1; # Magic true value required at end of module
+
diff -r 20e25f26bf06 -r 38223b4691e9 lib/PFTools/Compat/Parser.pm
--- a/lib/PFTools/Compat/Parser.pm Thu Sep 09 11:50:40 2010 +0000
+++ b/lib/PFTools/Compat/Parser.pm Fri Sep 10 13:41:35 2010 +0200
@@ -80,7 +80,7 @@
}
# Subst_vars
-sub Subst_vars ($$) {
+sub Subst_vars {
my ( $str, $hash_subst ) = @_;
$str =~ s/%([^\%]+)%/$hash_subst->{$1}/gm;
diff -r 20e25f26bf06 -r 38223b4691e9 lib/PFTools/Update/Addmount.pm
--- a/lib/PFTools/Update/Addmount.pm Thu Sep 09 11:50:40 2010 +0000
+++ b/lib/PFTools/Update/Addmount.pm Fri Sep 10 13:41:35 2010 +0200
@@ -24,6 +24,7 @@
use English qw( -no_match_vars ); # Avoids regex performance penalty
use Exporter;
+use IO::File;
use File::Copy;
use Text::Diff;
@@ -256,13 +257,23 @@
}
if ($addfstab) {
my $tmp = Get_tmp_dest("/etc/fstab");
- unless ( open( NEWFSTAB, ">" . $tmp ) ) {
- Warn( $CODE->{'OPEN'}, "Unable to create tmp dest " . $tmp );
+ my $output_fh;
+ unless ( $output_fh = IO::File->new ( '>'. $tmp ) ) {
+ Warn( $CODE->{'OPEN'},
+ "Unable to create tmp destination $tmp : $OS_ERROR " );
return 1;
}
my $new_fstab = Build_fstab_from_structure($current_fstab);
- print NEWFSTAB join( "\n", @{$new_fstab} );
- close(NEWFSTAB);
+ unless ( print $output_fh join "\n", @{$new_fstab} ) {
+ Warn( $CODE->{'OPEN'},
+ "Unable to write on tmp destination $tmp : $OS_ERROR" );
+ return 1;
+ }
+ unless ( $output_fh->close() ) {
+ Warn ( $CODE->{'OPEN'},
+ "Unable to close tmp destination $tmp : $OS_ERROR" );
+ return 1;
+ }
if ( $options->{'diff'} ) {
print diff ( '/etc/fstab', $tmp, { STYLE => 'Unified' } );
}
diff -r 20e25f26bf06 -r 38223b4691e9 lib/PFTools/VCS.pm
--- a/lib/PFTools/VCS.pm Thu Sep 09 11:50:40 2010 +0000
+++ b/lib/PFTools/VCS.pm Fri Sep 10 13:41:35 2010 +0200
@@ -1,11 +1,6 @@
package PFTools::VCS;
##
-## $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>
+## 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
@@ -28,6 +23,7 @@
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;
@@ -37,148 +33,18 @@
VCS_checkout
);
-# Updating CVS repository
-sub __CVS_checkout ($$$) {
- my ( $hostname, $pf_config, $options ) = @_;
- my $cvs_cmd = $pf_config->{'vcs'}->{'command'};
-
- if ( defined $options->{'branch'} && $options->{'branch'} ne '' ) {
- if ( $cvs_cmd ne '' ) {
- Warn( $CODE->{'DUPLICATE_VALUE'},
- "Ignoring CVS command "
- . $cvs_cmd
- . " for using branche "
- . $options->{'branch'} );
- }
- }
- elsif ( $pf_config->{'vcs'}->{'branch'} ) {
- $options->{'branch'} = $pf_config->{'vcs'}->{'branch'};
- }
- else {
- $options->{'branch'} = "";
- }
-
- my $ret;
- my $umask = umask( $pf_config->{'vcs'}->{'umask'} );
-
- $ENV{'CVS_RSH'} = $pf_config->{'vcs'}->{'rsh'}
- if ( $pf_config->{'vcs'}->{'method'} eq 'rsh' );
-
- unless ( $cvs_cmd ne "" ) {
- if ( $hostname =~ /^$pf_config->{'regex'}->{'deploy_hosts'}/ ) {
- $cvs_cmd = "/usr/bin/cvs -R -d '";
- }
- else {
- print $hostname
- . " doesn't match "
- . $pf_config->{'regex'}->{'deploy_hosts'} . "\n"
- if ( $options->{'verbose'} );
- $cvs_cmd
- = "/usr/bin/cvs -d ':ext:"
- . $pf_config->{'vcs'}->{'user'} . '@'
- . $pf_config->{'vcs'}->{'server'};
- }
- $cvs_cmd .= $pf_config->{'vcs'}->{'vcsroot'} . "' checkout ";
- $cvs_cmd .= ' -r ' . $options->{'branch'}
- if ( $options->{'branch'} ne "" );
- $cvs_cmd .= $pf_config->{'vcs'}->{'module'};
- }
- print $cvs_cmd. "\n" if ( $options->{'debug'} || $options->{'verbose'} );
-
- my $co_dir = $pf_config->{'path'}->{'checkout_dir'};
- if ( -e $co_dir ) {
- remove_tree $co_dir
- or Abort ( $CODE->{'OPEN'},
- "Unable to remove the content of $co_dir before checking out" );
- }
- make_path $co_dir
- or Abort( $CODE->{'OPEN'},
- "Unable to create path $co_dir for checking out" );
-
- $ret = deferredlogsystem( "cd '" . $co_dir . "';" . $cvs_cmd );
- if ($ret) {
- FlushLog();
- }
- else {
- DelLog();
- }
- umask($umask);
- return $ret;
-}
-
-sub __SVN_checkout ($$$) {
- my ( $hostname, $pf_config, $options ) = @_;
- my $svn_cmd = $pf_config->{'vcs'}->{'command'};
-
- if ( defined $options->{'branch'} && $options->{'branch'} ne '' ) {
- if ( $svn_cmd ne '' ) {
- Warn( $CODE->{'DUPLICATE_VALUE'},
- "Ignoring SVN command "
- . $svn_cmd
- . " for using branche "
- . $options->{'branch'} );
- }
- }
- elsif ( $pf_config->{'vcs'}->{'branch'} ) {
- $options->{'branch'} = $pf_config->{'vcs'}->{'branch'};
- }
- else {
- $options->{'branch'} = "";
- }
-
- my $ret;
- my $umask = umask( $pf_config->{'vcs'}->{'umask'} );
-
- unless ( $svn_cmd ne "" ) {
- $svn_cmd
- = "svn checkout "
- . $pf_config->{'vcs'}->{'method'} . "://"
- . $pf_config->{'vcs'}->{'server'} . "/"
- . $pf_config->{'vcs'}->{'module'}
- . " --username "
- . $pf_config->{'vcs'}->{'user'}
- . " --password "
- . $pf_config->{'vcs'}->{'password'};
- }
- print $svn_cmd. "\n" if ( $options->{'debug'} || $options->{'verbose'} );
-
- my $co_dir = $pf_config->{'path'}->{'checkout_dir'};
- if ( -e $co_dir ) {
- remove_tree $co_dir
- or Abort ( $CODE->{'OPEN'},
- "Unable to remove the content of $co_dir before checking out" );
- }
- make_path $co_dir
- or Abort( $CODE->{'OPEN'},
- "Unable to create path $co_dir for checking out" );
-
- $ret = deferredlogsystem( "cd '" . $co_dir . "';" . $svn_cmd );
- if ($ret) {
- FlushLog();
- }
- else {
- DelLog();
- }
- umask($umask);
- return $ret;
-}
-
sub VCS_checkout ($$$) {
my ( $hostname, $pf_config, $options ) = @_;
- if ( $pf_config->{'vcs'}->{'type'} eq 'cvs' ) {
- if ( __CVS_checkout( $hostname, $pf_config, $options ) ) {
- return 0;
- }
- }
- elsif ( $pf_config->{'vcs'}->{'type'} eq 'svn' ) {
- if ( __SVN_checkout( $hostname, $pf_config, $options ) ) {
- return 0;
- }
- }
- else {
- Warn( $CODE->{'UNDEF_KEY'}, "Unkown type of VCS system" );
- return 0;
+ my $module_name = 'PFTools::VCS::'.uc($pf_config->{'vcs'}->{'type'});
+ my $module;
+
+ eval { $module = use_module($module_name); };
More information about the pf-tools-commits
mailing list