pf-tools commit: r801 [ccaillet-guest] - /branches/next-gen/lib/PFTools/VCS.pm
parmelan-guest at users.alioth.debian.org
parmelan-guest at users.alioth.debian.org
Thu Aug 5 07:47:39 UTC 2010
Author: ccaillet-guest
Date: Thu Aug 5 07:47:30 2010
New Revision: 801
URL: http://svn.debian.org/wsvn/pf-tools/?sc=1&rev=801
Log:
Adding VCS hndler(s)
Added:
branches/next-gen/lib/PFTools/VCS.pm
Added: branches/next-gen/lib/PFTools/VCS.pm
URL: http://svn.debian.org/wsvn/pf-tools/branches/next-gen/lib/PFTools/VCS.pm?rev=801&op=file
==============================================================================
--- branches/next-gen/lib/PFTools/VCS.pm (added)
+++ branches/next-gen/lib/PFTools/VCS.pm Thu Aug 5 07:47:30 2010
@@ -1,0 +1,108 @@
+package PFTools::VCS;
+##
+## $Id: Conf.pm 798 2010-08-04 10:40:00Z ccaillet-guest $
+##
+## 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 Exporter;
+use PFTools::Logger;
+use Data::Dumper;
+
+our @ISA = ('Exporter');
+
+our @EXPORT = qw(
+ VCS_update
+);
+
+# Updating CVS repository
+sub __CVS_update ($$;$$) {
+ my ( $hostname, $pf_config, $branche, $options ) = @_;
+ my $cvs_cmd = $pf_config->{'vcs'}->{'command'};
+
+ if ( $branche ne '' ) {
+ if ( $cvs_cmd ne '' ) {
+ Warn ( $CODE->{'DUPLICATE_VALUE'},
+ "Ignoring CVS command ".$cvs_cmd." for using branche ".$branche );
+ }
+ }
+ elsif ( $pf_config->{'vcs'}->{'branche'} ) {
+ $branche = $pf_config->{'vcs'}->{'branche'};
+ }
+ else {
+ $branche = "";
+ }
+
+ my $ret;
+ my $umask = umask ( $pf_config->{'vcs'}->{'umask'} );
+
+ $ENV{'CVS_RSH'} = $pf_config->{'vcs'}->{'rsh'};
+
+ unless ( $cvs_cmd ne "" ) {
+ if ( $hostname =~ /^$pf_config->{'regex'}->{'deploy_hosts'}$/ ) {
+ $cvs_cmd = "/usr/bin/cvs -R -d '";
+ }
+ else {
+ $cvs_cmd = "/usr/bin/cvs -d ':ext:"
+ .$pf_config->{'vcs'}->{'user'}.'@'
+ .$pf_config->{'vcs'}->{'server'}
+ }
+ $cvs_cmd .= $pf_config->{'vcs'}->{'cvsroot'}."' checkout";
+ $cvs_cmd .= ' -r '.$branche if ( $branche 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 ( ! -d $co_dir ) {
+ system ( "/bin/mkdir -p '".$co_dir. "' 2>/dev/null" );
+ }
+
+ $ret = deferredlogsystem ( "cd '".$co_dir."';".$cvs_cmd, 1 );
+ if ($ret) {
+ FlushLog();
+ }
+ else {
+ DelLog();
+ }
+ umask($umask);
+ return $ret;
+}
+
+sub VCS_Update ($$$;$) {
+ my ( $hostname, $pf_config, $options, $branche ) = @_;
+
+ if ( $pf_config->{'vcs'} eq 'cvs' ) {
+ if ( __CVS_update ( $hostname, $pf_config, $branche, $options ) ) {
+ return 0;
+ }
+ }
+ else {
+ Warn ( $CODE->{'UNDEF_KEY'},
+ "Unkown type of VCS system" );
+ return 0;
+ }
+ return 1;
+}
+
+1;
More information about the pf-tools-commits
mailing list