head	1.19;
access;
symbols
	TIGRIS_1_1_0RC2:1.17
	TIGRIS_1_1_0RC1:1.17
	TIGRIS_1_1:1.17.0.10
	TIGRIS_1_0_8:1.17
	TIGRIS_1_0_8RC3:1.17
	TIGRIS_1_0_8RC2:1.17
	TIGRIS_1_0_8RC1:1.17
	TIGRIS_1_0_7:1.17
	TIGRIS_1_0_7RC3:1.17
	TIGRIS_1_0_7RC2:1.17
	TIGRIS_1_0_7RC1:1.17
	TIGRIS_1_0_6:1.17
	TIGRIS_1_0_6RC5:1.17
	TIGRIS_1_0_6RC4:1.17
	TIGRIS_1_0_6RC3:1.17
	TIGRIS_1_0_6RC2:1.17
	TIGRIS_1_0_6RC1:1.17
	TIGRIS_1_0_5:1.17
	TIGRIS_1_0_5RC6:1.17
	TIGRIS_1_0_5RC5:1.17
	TIGRIS_1_0_5RC4:1.17
	TIGRIS_1_0_5RC3:1.17
	TIGRIS_1_0_5RC2:1.17
	TIGRIS_1_0_5RC1:1.17
	TIGRIS_1_0_4:1.17
	TIGRIS_1_0_3:1.17
	TIGRIS_1_0_2:1.17
	TIGRIS_1_0_1:1.17
	TIGRIS_1_0:1.17.0.12
	TIGRIS_1_0_0:1.17
	TIGRIS_1_0_0_RC1:1.17.0.8
	dlr:1.1.1
	TIGRIS_0_9_2_4:1.17
	TIGRIS_0_9_2_3:1.17
	HELM_PEER_PORT_BRANCH:1.1.1.2
	TURBINE_PEER:1.17
	TIGRIS_0_9_2_1:1.17
	TIGRIS_0_9_2:1.17.0.6
	TIGRIS_0_9_0:1.17.0.4
	TIGRIS_0_8_4:1.17.0.2
	NEWHELM:1.1.1.1
	TIGRIS_NOV_12_2000:1.1.1
	OLDHELM:1.16.0.2
	TIGRIS_NOV_11_2000:1.16
	TIGRIS_SEP_13_2000:1.8.0.2
	TIGRIS_BASELINE:1.12;
locks; strict;
comment	@# @;


1.19
date	2001.04.18.02.02.58;	author kmaples;	state Exp;
branches;
next	1.18;

1.18
date	2001.04.17.04.44.54;	author kmaples;	state Exp;
branches;
next	1.17;

1.17
date	2000.11.12.22.57.33;	author dlr;	state Exp;
branches;
next	1.16;

1.16
date	2000.10.02.22.37.31;	author kmaples;	state Exp;
branches;
next	1.15;

1.15
date	2000.09.28.18.06.20;	author kmaples;	state Exp;
branches;
next	1.14;

1.14
date	2000.09.28.17.50.40;	author kmaples;	state Exp;
branches;
next	1.13;

1.13
date	2000.09.27.23.56.36;	author kmaples;	state Exp;
branches;
next	1.12;

1.12
date	2000.09.15.03.51.10;	author kmaples;	state Exp;
branches;
next	1.11;

1.11
date	2000.09.14.19.02.22;	author kmaples;	state Exp;
branches;
next	1.10;

1.10
date	2000.09.13.22.33.46;	author kmaples;	state Exp;
branches;
next	1.9;

1.9
date	2000.09.13.21.55.36;	author kmaples;	state Exp;
branches;
next	1.8;

1.8
date	2000.09.05.22.57.48;	author kmaples;	state Exp;
branches;
next	1.7;

1.7
date	2000.09.05.03.20.09;	author kmaples;	state Exp;
branches;
next	1.6;

1.6
date	2000.08.18.20.59.02;	author kmaples;	state Exp;
branches;
next	1.5;

1.5
date	2000.08.16.23.58.25;	author kmaples;	state Exp;
branches;
next	1.4;

1.4
date	2000.05.01.08.56.52;	author manoj;	state Exp;
branches;
next	1.3;

1.3
date	2000.05.01.08.51.32;	author manoj;	state Exp;
branches;
next	1.2;

1.2
date	2000.05.01.08.28.01;	author manoj;	state Exp;
branches;
next	1.1;

1.1
date	2000.04.29.00.04.10;	author jrobbins;	state Exp;
branches
	1.1.1.1;
next	;

1.1.1.1
date	2000.11.12.21.17.32;	author dlr;	state Exp;
branches;
next	1.1.1.2;

1.1.1.2
date	2001.02.21.00.35.57;	author dlr;	state Exp;
branches;
next	;


desc
@@


1.19
log
@Undoing yesterday's commit - my hastiness to implement some sort of logging
level notion into these scripts caused me great pain.
@
text
@#!/usr/bin/perl -wU

# ================================================================
# Copyright (c) 2000 Collab.Net.  All rights reserved.
# 
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
# 
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 
# 3. The end-user documentation included with the redistribution, if
# any, must include the following acknowlegement: "This product includes
# software developed by Collab.Net (http://www.Collab.Net/)."
# Alternately, this acknowlegement may appear in the software itself, if
# and wherever such third-party acknowlegements normally appear.
# 
# 4. The hosted project names must not be used to endorse or promote
# products derived from this software without prior written
# permission. For written permission, please contact info@@collab.net.
# 
# 5. Products derived from this software may not use the "Tigris" name
# nor may "Tigris" appear in their names without prior written
# permission of Collab.Net.
# 
# THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
# IN NO EVENT SHALL COLLAB.NET OR ITS CONTRIBUTORS BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# ====================================================================
# 
# This software consists of voluntary contributions made by many
# individuals on behalf of Collab.Net.
#


# cvs-module-edit
# $Id: cvs-module-edit,v 1.17 2000/11/12 22:57:33 dlr Exp $
# --------------------
# Provide operations for CVS as past of Tigris

# Flush buffer, just in case:
$| = 1;

# For the sake of -T:
$ENV{'PATH'} = "/bin:/usr/bin:/usr/local/bin";
# Detaint the args by brute force:
@@ARGV = detaint_array(@@ARGV);


use strict;

# Process arguments
my $sandbox             = $ARGV[0] || "";
my $htdoc_root          = $ARGV[1] || "";
my $project_name        = $ARGV[2] || "";
my $domain_name         = $ARGV[3] || ""; # unreferenced.
my $brand_name          = $ARGV[4] || ""; # unreferenced.
my $module_name         = $ARGV[5] || "";
my $module_description  = $ARGV[6] || "none";
my $is_web              = $ARGV[7] || "";

# Grab just the filename portion of this script to use as a 
# log identifier:
my $script_name = $0;
$script_name =~ s/^.*\/([^\/]+)$/  $1/;

# Paths and files derived from @@ARGV:
my $tigris_rep    = 'data/helm/cvs/repository';      # static portion off sbx
my $cvsroot       = "$sandbox/$tigris_rep";

# This is perhaps a bit overboard, but if we can get the system
# to tell us where CVS is, it's one less thing to have to hardcode:
my $default_cvs_bin = '/usr/bin/cvs';
my $cvs_bin = `which cvs` || $default_cvs_bin; 
chomp $cvs_bin;
# There's no reason to go on if CVS isn't there:
die "$script_name: CVS executable could not be found: $!\n" unless -x $cvs_bin;

#---------------------------------------------------------------
# MAIN
#---------------------------------------------------------------

print "$script_name: beginning for project $project_name\n";

# Move to the HTML directory to begin CVS checkout:
chdir($htdoc_root) or die "$script_name: chdir to $htdoc_root failed: $!\n";

if ($is_web) {
    print "$script_name: performing CVS co of $project_name/$module_name\n";

    # This conditional is entirely duplicated in cvs-module-add.
    # Such sadness - but anyway.  The idea is that 'edit' here
    # is really just flipping the 'is_web' flag on and off, hence the 
    # duplicaton:

    if(-d "$htdoc_root/$project_name/$module_name"){
        print "$script_name: $project_name/$module_name already exists under htdoc_root\n";
    } else {
        # Add the default content:
        my $pid = $$;
        my $x = 0;
        my $tempdir = "$pid.$x";

        while(-d "/tmp/$tempdir"){
            $x++;
            $tempdir = "$pid.$x";
        }
        # static area where the default content for web-related modules
        # resides (off of HTDOC_ROOT):
        my $default_content_dir = 'look/www/templates/';

        print "$script_name: creating /tmp/$tempdir for checkout\n";
        mkdir("/tmp/$tempdir", 0755)
            or die "$script_name: Couldn't create /tmp/$tempdir: $!\n";

        print "$script_name: moving to /tmp/$tempdir\n";
        chdir("/tmp/$tempdir")
            or die "$script_name: Couldn't chdir to /tmp/$tempdir: $!\n";

        print "$script_name: doing cvs co $project_name/$module_name\n";
        system("$cvs_bin",'-d',"$cvsroot",'co',"$project_name/$module_name") == 0
            or die "$script_name: Couldn't perform cvs co $project_name/$module_name: $!\n";
   
        print "$script_name: changing dir to $project_name/$module_name\n";
        chdir("$project_name/$module_name")
            or die "$script_name: Couldn't chdir to $project_name/$module_name: $!\n";
   
        # This is unfortunate - passing this as a scalar means /bin/sh
        # comes into the picture, but we need to do shell expansion, so
        # this will have to suffice for the time being:
        print "$script_name: rsyncing new content\n";
        system("rsync -ar --cvs-exclude $htdoc_root/$default_content_dir/* .") == 0
            or warn "$script_name: Couldn't rsync $htdoc_root/$default_content_dir/*: $!\n";

        my @@contents = `find . `;
        chomp(@@contents);
        @@contents = grep { $_ !~ m#CVS# && $_ ne '.'} @@contents;

        print "$script_name: adding default content to cvs\n";
        if(@@contents){
           system("$cvs_bin",'-d',"$cvsroot",'add', @@contents) == 0
                or die "$script_name: Couldn't perform cvs add: $!\n";
   
            print "$script_name: committing new content to cvs\n";
            system("$cvs_bin",'commit','-m',"$module_description") == 0
                or die "$script_name: Couldn't perform cvs commit: $!\n";
        }
        chdir('/tmp') or die "$script_name: Couldn't chdir /tmp: $!\n";
   
        print "$script_name: removing /tmp/$tempdir\n";
        system('rm','-rf',"/tmp/$tempdir") == 0
            or warn "$script_name: Couldn't remove /tmp/$tempdir: $!\n";
    }

} else {
	print "$script_name: performing CVS release of $project_name/$module_name\n";

    system("$cvs_bin -d $cvsroot -Q release -d $project_name/$module_name") == 0
        or die "$script_name: cvs release failed: $!\n";
}


#---------------------------------------------------------------
# END MAIN
#---------------------------------------------------------------

# A crude attempt to overcome data tainting in perl:
#-------------------
sub detaint_array {
#-------------------
    my @@unclean = @@_;
    my @@clean = ();

    foreach(@@unclean){
        # We don't really have rules for this, so at the moment
        # this acts as a passthrough:
        $_ =~ m/^(.*)$/;
        push(@@clean,$1);
    }

    return(@@clean);
}
__END__



@


1.18
log
@Scripts now use IN_PRODUCTION to determine logging level
@
text
@a54 5
my $scripts_dir = $ENV{'SANDBOX'} . '/helm/perl/scripts';

require "$scripts_dir/ParentChildArgumentBridge.pl"
    or die "Require failed: $!\n";

d97 1
a97 1
print_log(1, "$script_name: beginning for project $project_name\n");
d103 1
a103 1
    print_log(1, "$script_name: performing CVS co of $project_name/$module_name\n");
d111 1
a111 1
        print_log(1, "$script_name: $project_name/$module_name already exists under htdoc_root\n");
d126 1
a126 1
        print_log(1, "$script_name: creating /tmp/$tempdir for checkout\n");
d130 1
a130 1
        print_log(1, "$script_name: moving to /tmp/$tempdir\n");
d134 1
a134 1
        print_log(1, "$script_name: doing cvs co $project_name/$module_name\n");
d138 1
a138 1
        print_log(1, "$script_name: changing dir to $project_name/$module_name\n");
d145 1
a145 1
        print_log(1, "$script_name: rsyncing new content\n");
d153 1
a153 1
        print_log(1, "$script_name: adding default content to cvs\n");
d158 1
a158 1
            print_log(1, "$script_name: committing new content to cvs\n");
d164 1
a164 1
        print_log(1, "$script_name: removing /tmp/$tempdir\n");
d170 1
a170 1
	print_log(1, "$script_name: performing CVS release of $project_name/$module_name\n");
@


1.17
log
@Resolved merge conflicts.
@
text
@d51 1
a51 1
# $Id: cvs-module-edit,v 1.1.1.1 2000/11/12 21:17:32 dlr Exp $
d55 5
d102 1
a102 1
print "$script_name: beginning for project $project_name\n";
d108 1
a108 1
    print "$script_name: performing CVS co of $project_name/$module_name\n";
d116 1
a116 1
        print "$script_name: $project_name/$module_name already exists under htdoc_root\n";
d131 1
a131 1
        print "$script_name: creating /tmp/$tempdir for checkout\n";
d135 1
a135 1
        print "$script_name: moving to /tmp/$tempdir\n";
d139 1
a139 1
        print "$script_name: doing cvs co $project_name/$module_name\n";
d143 1
a143 1
        print "$script_name: changing dir to $project_name/$module_name\n";
d150 1
a150 1
        print "$script_name: rsyncing new content\n";
d158 1
a158 1
        print "$script_name: adding default content to cvs\n";
d163 1
a163 1
            print "$script_name: committing new content to cvs\n";
d169 1
a169 1
        print "$script_name: removing /tmp/$tempdir\n";
d175 1
a175 1
	print "$script_name: performing CVS release of $project_name/$module_name\n";
@


1.16
log
@Removed references to 'is_private' flag.  Not only is this unnecessary, but
according Leonard, it 'kills puppies and causes dutch elm disease'.
@
text
@d51 1
a51 1
# $Id: cvs-module-edit,v 1.15 2000/09/28 18:06:20 kmaples Exp $
a74 4
my $was_web             = $ARGV[8] || ""; # unreferenced.

# The user didn't actually ask us to do anything.
# exit 0 if ($is_web xor $was_web);
@


1.15
log
@Fixed reference to $module_description.
@
text
@d51 1
a51 1
# $Id: cvs-module-edit,v 1.14 2000/09/28 17:50:40 kmaples Exp $
a75 1
my $is_private          = $ARGV[9] || ""; # unreferenced.
@


1.14
log
@Fixed static pointer to /cvs to be $cvsroot.
@
text
@d51 1
a51 1
# $Id: cvs-module-edit,v 1.13 2000/09/27 23:56:36 kmaples Exp $
d73 4
a76 3
my $is_web              = $ARGV[6] || "";
my $was_web             = $ARGV[7] || ""; # unreferenced.
my $is_private          = $ARGV[8] || ""; # unreferenced.
@


1.13
log
@Changed cvs-module-edit to use the same method for adding cvs files that
cvs-module-add does.  Horrendeous duplication of code there.
@
text
@d51 1
a51 1
# $Id: cvs-module-edit,v 1.12 2000/09/15 03:51:10 kmaples Exp $
d159 1
a159 1
           system("$cvs_bin",'-d','/cvs', 'add', @@contents) == 0
@


1.12
log
@Fixed regex to display script name in logfiles.
@
text
@d51 1
a51 1
# $Id: cvs-module-edit,v 1.11 2000/09/14 19:02:22 kmaples Exp $
d107 65
a171 1
	print "$script_name: performing CVS co of $project_name/$module_name\n";
a172 2
    system("$cvs_bin -d $cvsroot -Q co $project_name/$module_name") == 0
        or die "$script_name: cvs checkout failed: $!\n";
@


1.11
log
@Miscellaneous changes to resolve tainting problems with setuid scripts.
CVS child scripts are now, unfortunately, permitted to perform unsafe ops.
@
text
@d51 1
a51 1
# $Id: cvs-module-edit,v 1.10 2000/09/13 22:33:46 kmaples Exp $
d83 1
a83 1
$script_name =~ s/^.*\/([\w]+)$/$1/;
@


1.10
log
@Added crude subroutine to all child scripts to detaint @@ARGV.  At the moment,
this isn't doing any real detainting - just spitting the args back out to get
around warnings setuid generates.  Complications with the scripts' knowledge
of it's own working dir when it's called prevent the effective use of 'require'
in the child scripts, thus the redundancy of code in the children (for the time
being)
@
text
@d1 1
a1 1
#!/usr/bin/perl -w
d51 1
a51 1
# $Id: cvs-module-edit,v 1.9 2000/09/13 21:55:36 kmaples Exp $
@


1.9
log
@Set PATH in child scripts to suppress -T warnings.
@
text
@d51 1
a51 1
# $Id: cvs-module-edit,v 1.8 2000/09/05 22:57:48 kmaples Exp $
d60 3
d123 17
@


1.8
log
@Corrected paths for the current position of the cvsroot in installations:
	[sandbox]/data/helm/cvs/repository
as opposed to the former
	[sandbox]/tigrisc/repository
@
text
@d51 1
a51 1
# $Id: cvs-module-edit,v 1.7 2000/09/05 03:20:09 kmaples Exp $
d57 3
@


1.7
log
@Minor fixes; set some default values to ' || "";'
@
text
@d51 1
a51 1
# $Id: cvs-module-edit,v 1.6 2000/08/18 20:59:02 kmaples Exp $
d80 1
a80 1
my $tigris_rep    = 'tigrisc/repository';      # static portion off sbx
@


1.6
log
@Removed unreferenced arg creating mismatch between calling script and
current script.
@
text
@d51 1
a51 1
# $Id: cvs-module-edit,v 1.4 2000/05/01 08:56:52 manoj Exp $
d61 9
a69 9
my $sandbox             = $ARGV[0];
my $htdoc_root          = $ARGV[1];
my $project_name        = $ARGV[2];
my $domain_name         = $ARGV[3]; # unreferenced.
my $brand_name          = $ARGV[4]; # unreferenced.
my $module_name         = $ARGV[5];
my $is_web              = $ARGV[6];
my $was_web             = $ARGV[7]; # unreferenced.
my $is_private          = $ARGV[8]; # unreferenced.
@


1.5
log
@Extensive rewrites and modifications to standarize interface with caller
@
text
@d67 3
a69 4
my $module_description  = $ARGV[6]; # unreferenced.
my $is_web              = $ARGV[7];
my $was_web             = $ARGV[8]; # unreferenced.
my $is_private          = $ARGV[9]; # unreferenced.
@


1.4
log
@Semantics of -d for "cvs release" were misunderstood. We still wanted
-d (to delete the directory after releasing it), but -d isn't useful
as a pointer to the actual module's root.
@
text
@d51 1
a51 1
# $Id: cvs-module-edit,v 1.3 2000/05/01 08:51:32 manoj Exp $
d55 3
d61 10
a70 9
my $sandbox      = $ARGV[0];
my $project_name        = $ARGV[1];
my $domain_name         = $ARGV[2];
my $brand_name          = $ARGV[3];
my $module_name         = $ARGV[4];
my $module_description  = $ARGV[5];
my $is_web              = $ARGV[6];
my $was_web             = $ARGV[7];
my $is_private          = $ARGV[8];
d75 22
a96 2
# my $cvsroot = $db->config('cvs_cvsroot');
my $cvsroot = "$sandbox/tigrisc/repository";
d98 2
a99 1
chdir("$sandbox/html") or die "chdir failed: $!";
d102 9
a110 10
    print "cvs: checkout a directory: " . $project_name . "/" . $module_name .
        " in web cvs root for domain " . $domain_name . "\n";
    system("/usr/bin/cvs -d $cvsroot -Q co $project_name/$module_name") == 0
        or die "cvs checkout failed: $!";
}
else {
    print "cvs: release a directory: " . $project_name . "/" . $module_name .
        " in web cvs root for domain " . $domain_name . "\n";
    system("/usr/bin/cvs -d $cvsroot -Q release -d $project_name/$module_name") == 0
        or die "cvs release failed: $!";
d112 9
@


1.3
log
@Bring these pieces closer to idempotency. This will make it easier to
use these scripts to restore consistency in case of a crash.
@
text
@d51 1
a51 1
# $Id: cvs-module-edit,v 1.2 2000/05/01 08:28:01 manoj Exp $
d74 1
a74 1
my $dir = "$sandbox/html/$project_name/$module_name";
d76 12
a87 5
$op = $is_web ? "checkout" : "release" ;
print "cvs: $op a directory: " . $project_name . "/" . $module_name .
    " in web cvs root for domain " . $domain_name . "\n";
system("/usr/bin/cvs -d $cvsroot -Q $op -d $dir $project_name/$module_name") == 0
    or die "cvs $op failed: $!";
@


1.2
log
@Initial untested versions of Perl code for CVS module management.
@
text
@d51 1
a51 1
# $Id: cvs-module-edit,v 1.1 2000/04/29 00:04:10 jrobbins Exp $
d69 1
a69 1
exit 0 if ($is_web xor $was_web);
@


1.1
log
@initial checkin
@
text
@d51 1
a51 1
# $Id: cvs.pm,v 1.1 2000/03/24 20:33:58 jrobbins Exp $
d57 10
d68 13
a80 14
sub checkoutWebModule {
    my ($class, $project_name, $domain_name, $brand_name,
        $module_name, $is_private) = @@_;
    print "cvs: update a directory: " . $project_name . "/" . $module_name .
        " in web cvs root for domain " . $domain_name . "\n";
    
}

sub releaseWebModule {
    my ($class, $project_name, $domain_name, $brand_name,
        $module_name, $is_private) = @@_;
    print "cvs release a directory: " . $project_name . "/" . $module_name .
        " in web cvs root for domain " . $domain_name . "\n";
}
@


1.1.1.1
log
@Merging newhelm tree into helm, as per IZ issue #557.  Previous major version of helm is tagged TIGRIS_NOV_11_2000.
@
text
@d1 1
a1 1
#!/usr/bin/perl -wU
d51 1
a51 1
# $Id: cvs-module-edit,v 1.2 2000/10/26 05:04:18 kmaples Exp $
a54 9
# Flush buffer, just in case:
$| = 1;

# For the sake of -T:
$ENV{'PATH'} = "/bin:/usr/bin:/usr/local/bin";
# Detaint the args by brute force:
@@ARGV = detaint_array(@@ARGV);


a56 102
# Process arguments
my $sandbox             = $ARGV[0] || "";
my $htdoc_root          = $ARGV[1] || "";
my $project_name        = $ARGV[2] || "";
my $domain_name         = $ARGV[3] || ""; # unreferenced.
my $brand_name          = $ARGV[4] || ""; # unreferenced.
my $module_name         = $ARGV[5] || "";
my $module_description  = $ARGV[6] || "none";
my $is_web              = $ARGV[7] || "";

# Grab just the filename portion of this script to use as a 
# log identifier:
my $script_name = $0;
$script_name =~ s/^.*\/([^\/]+)$/  $1/;

# Paths and files derived from @@ARGV:
my $tigris_rep    = 'data/helm/cvs/repository';      # static portion off sbx
my $cvsroot       = "$sandbox/$tigris_rep";

# This is perhaps a bit overboard, but if we can get the system
# to tell us where CVS is, it's one less thing to have to hardcode:
my $default_cvs_bin = '/usr/bin/cvs';
my $cvs_bin = `which cvs` || $default_cvs_bin; 
chomp $cvs_bin;
# There's no reason to go on if CVS isn't there:
die "$script_name: CVS executable could not be found: $!\n" unless -x $cvs_bin;

#---------------------------------------------------------------
# MAIN
#---------------------------------------------------------------

print "$script_name: beginning for project $project_name\n";

# Move to the HTML directory to begin CVS checkout:
chdir($htdoc_root) or die "$script_name: chdir to $htdoc_root failed: $!\n";

if ($is_web) {
    print "$script_name: performing CVS co of $project_name/$module_name\n";

    # This conditional is entirely duplicated in cvs-module-add.
    # Such sadness - but anyway.  The idea is that 'edit' here
    # is really just flipping the 'is_web' flag on and off, hence the 
    # duplicaton:

    if(-d "$htdoc_root/$project_name/$module_name"){
        print "$script_name: $project_name/$module_name already exists under htdoc_root\n";
    } else {
        # Add the default content:
        my $pid = $$;
        my $x = 0;
        my $tempdir = "$pid.$x";

        while(-d "/tmp/$tempdir"){
            $x++;
            $tempdir = "$pid.$x";
        }
        # static area where the default content for web-related modules
        # resides (off of HTDOC_ROOT):
        my $default_content_dir = 'look/www/templates/';

        print "$script_name: creating /tmp/$tempdir for checkout\n";
        mkdir("/tmp/$tempdir", 0755)
            or die "$script_name: Couldn't create /tmp/$tempdir: $!\n";

        print "$script_name: moving to /tmp/$tempdir\n";
        chdir("/tmp/$tempdir")
            or die "$script_name: Couldn't chdir to /tmp/$tempdir: $!\n";

        print "$script_name: doing cvs co $project_name/$module_name\n";
        system("$cvs_bin",'-d',"$cvsroot",'co',"$project_name/$module_name") == 0
            or die "$script_name: Couldn't perform cvs co $project_name/$module_name: $!\n";
   
        print "$script_name: changing dir to $project_name/$module_name\n";
        chdir("$project_name/$module_name")
            or die "$script_name: Couldn't chdir to $project_name/$module_name: $!\n";
   
        # This is unfortunate - passing this as a scalar means /bin/sh
        # comes into the picture, but we need to do shell expansion, so
        # this will have to suffice for the time being:
        print "$script_name: rsyncing new content\n";
        system("rsync -ar --cvs-exclude $htdoc_root/$default_content_dir/* .") == 0
            or warn "$script_name: Couldn't rsync $htdoc_root/$default_content_dir/*: $!\n";

        my @@contents = `find . `;
        chomp(@@contents);
        @@contents = grep { $_ !~ m#CVS# && $_ ne '.'} @@contents;

        print "$script_name: adding default content to cvs\n";
        if(@@contents){
           system("$cvs_bin",'-d',"$cvsroot",'add', @@contents) == 0
                or die "$script_name: Couldn't perform cvs add: $!\n";
   
            print "$script_name: committing new content to cvs\n";
            system("$cvs_bin",'commit','-m',"$module_description") == 0
                or die "$script_name: Couldn't perform cvs commit: $!\n";
        }
        chdir('/tmp') or die "$script_name: Couldn't chdir /tmp: $!\n";
   
        print "$script_name: removing /tmp/$tempdir\n";
        system('rm','-rf',"/tmp/$tempdir") == 0
            or warn "$script_name: Couldn't remove /tmp/$tempdir: $!\n";
    }
d58 6
a63 5
} else {
	print "$script_name: performing CVS release of $project_name/$module_name\n";

    system("$cvs_bin -d $cvsroot -Q release -d $project_name/$module_name") == 0
        or die "$script_name: cvs release failed: $!\n";
d66 5
a70 20

#---------------------------------------------------------------
# END MAIN
#---------------------------------------------------------------

# A crude attempt to overcome data tainting in perl:
#-------------------
sub detaint_array {
#-------------------
    my @@unclean = @@_;
    my @@clean = ();

    foreach(@@unclean){
        # We don't really have rules for this, so at the moment
        # this acts as a passthrough:
        $_ =~ m/^(.*)$/;
        push(@@clean,$1);
    }

    return(@@clean);
a71 4
__END__



@


1.1.1.2
log
@Replacing the HEAD with the HELM_PEER_PORT_BRANCH.
@
text
@d51 1
a51 1
# $Id: cvs-module-edit,v 1.17 2000/11/12 22:57:33 dlr Exp $
@


