head	1.33;
access;
symbols
	TIGRIS_1_1_0RC2:1.28
	TIGRIS_1_1_0RC1:1.28
	TIGRIS_1_1:1.28.0.10
	TIGRIS_1_0_8:1.28
	TIGRIS_1_0_8RC3:1.28
	TIGRIS_1_0_8RC2:1.28
	TIGRIS_1_0_8RC1:1.28
	TIGRIS_1_0_7:1.28
	TIGRIS_1_0_7RC3:1.28
	TIGRIS_1_0_7RC2:1.28
	TIGRIS_1_0_7RC1:1.28
	TIGRIS_1_0_6:1.28
	TIGRIS_1_0_6RC5:1.28
	TIGRIS_1_0_6RC4:1.28
	TIGRIS_1_0_6RC3:1.28
	TIGRIS_1_0_6RC2:1.28
	TIGRIS_1_0_6RC1:1.28
	TIGRIS_1_0_5:1.28
	TIGRIS_1_0_5RC6:1.28
	TIGRIS_1_0_5RC5:1.28
	TIGRIS_1_0_5RC4:1.28
	TIGRIS_1_0_5RC3:1.28
	TIGRIS_1_0_5RC2:1.28
	TIGRIS_1_0_5RC1:1.28
	TIGRIS_1_0_4:1.28
	TIGRIS_1_0_3:1.28
	TIGRIS_1_0_2:1.28
	TIGRIS_1_0_1:1.28
	TIGRIS_1_0:1.28.0.12
	TIGRIS_1_0_0:1.28
	TIGRIS_1_0_0_RC1:1.28.0.8
	dlr:1.1.1
	TIGRIS_0_9_2_4:1.28
	TIGRIS_0_9_2_3:1.28
	HELM_PEER_PORT_BRANCH:1.1.1.2
	TURBINE_PEER:1.28
	TIGRIS_0_9_2_1:1.28
	TIGRIS_0_9_2:1.28.0.6
	TIGRIS_0_9_0:1.28.0.4
	TIGRIS_0_8_4:1.28.0.2
	NEWHELM:1.1.1.1
	TIGRIS_NOV_12_2000:1.1.1
	OLDHELM:1.27.0.2
	TIGRIS_NOV_11_2000:1.27
	TIGRIS_SEP_13_2000:1.11.0.2
	TIGRIS_BASELINE:1.23;
locks; strict;
comment	@# @;


1.33
date	2001.06.05.01.37.54;	author stack;	state Exp;
branches;
next	1.32;

1.32
date	2001.06.04.16.26.47;	author stack;	state Exp;
branches;
next	1.31;

1.31
date	2001.05.10.20.40.42;	author thom;	state Exp;
branches;
next	1.30;

1.30
date	2001.04.18.02.02.58;	author kmaples;	state Exp;
branches;
next	1.29;

1.29
date	2001.04.17.04.44.54;	author kmaples;	state Exp;
branches;
next	1.28;

1.28
date	2000.11.12.22.57.33;	author dlr;	state Exp;
branches;
next	1.27;

1.27
date	2000.10.02.22.37.31;	author kmaples;	state Exp;
branches;
next	1.26;

1.26
date	2000.09.28.17.50.40;	author kmaples;	state Exp;
branches;
next	1.25;

1.25
date	2000.09.27.23.54.21;	author kmaples;	state Exp;
branches;
next	1.24;

1.24
date	2000.09.27.23.25.03;	author kmaples;	state Exp;
branches;
next	1.23;

1.23
date	2000.09.22.23.42.20;	author kmaples;	state Exp;
branches;
next	1.22;

1.22
date	2000.09.18.19.10.44;	author kmaples;	state Exp;
branches;
next	1.21;

1.21
date	2000.09.18.18.56.20;	author kmaples;	state Exp;
branches;
next	1.20;

1.20
date	2000.09.15.03.51.10;	author kmaples;	state Exp;
branches;
next	1.19;

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

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

1.17
date	2000.09.14.19.02.22;	author kmaples;	state Exp;
branches;
next	1.16;

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

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

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

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

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

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

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

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

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

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

1.6
date	2000.09.05.22.57.48;	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.08.02.18.37.57;	author kmaples;	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.30;	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.33
log
@Backing out my adding of the '-C' flag to cvs update in loginfo.  It doesn't
work inside loginfo.  Inside loginfo, a patch is applied to the file on
disk. If file on disk has been locally modified or is not the immediate
ancestor, the patch will often fail -- there will be merge errors.  Outside
of loginfo, the locally-modified file is moved aside if there will be
conflicts merging; then the file is updated.

Spent a while trying to figure why the difference.  Local vs. remote
repository is the only obvious difference.  Backing out change for not so
doesn't interfere w/ rolling of T106.
@
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-add
# $Id: cvs-module-add,v 1.32 2001/06/04 16:26:47 stack Exp $
# --------------------
# Provide operations for CVS as part 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";
my $module_dir    = "$cvsroot/$project_name/$module_name";

# 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;

my $loginfo_dir   = "$cvsroot/CVSROOT";
my $loginfo_file  = 'loginfo';

# This is the directive which get written out to the loginfo file:
my $loginfo_cmd   = "^$project_name/$module_name " 
    . "(sleep 2; if [ -d $htdoc_root/$project_name/$module_name ]; then cd $htdoc_root/$project_name/$module_name; $cvs_bin -q update -d; fi) &\n";

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

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

# Assume that if the directory exists, that the module has already
# been added:
if ( -d $module_dir) {
    print "$script_name: module '$module_name' exists\n";
} else {
    # Create the module directory:
    print "$script_name: adding dir $module_dir\n";
    mkdir($module_dir, 0775) or die "$script_name: mkdir $module_dir failed: $!\n";
}


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/' . $module_name;

    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";

    # Now go check out what we've just committed:
    chdir($htdoc_root) or die "$script_name: Couldn't chdir to $htdoc_root: $!\n";
    # Create the project dir if it doesn't already exist:
    mkdir($project_name, 0755) unless -d $project_name;
    chdir($project_name) or die "$script_name: Couldn't chdir /tmp: $!\n";
    system("$cvs_bin",'-d',"$cvsroot",'co','-d',"$module_name","$project_name/$module_name") == 0
        or die "$script_name: Couldn't perform cvs co: $!\n";

}

## <thom> remove the adding of the loginfo line.
## loginfo now contains a call to the publish.pl which will to the
## web publishing.
#
#      if($is_web){
#          print "$script_name: adding line to loginfo file in web cvs root.\n";   
#          my @@tmp = ();    ## Temp array for file contents
#          # This could be improved ... there are two passes at the file
#          # here; the first reads it in to check for the reference, and
#          # the second opens it for appending (if necessary).
#          if(open(LOGINFO, "<$loginfo_dir/$loginfo_file")){
#              @@tmp = <LOGINFO>;
#              close(LOGINFO);
#          } else {
#              print "$script_name: unable to open $loginfo_dir/$loginfo_file for read; will create\n";
#          }
#
#          # check to see if an entry for this particular mod already exists.
#          # Note that we haven't checked for the actual dir yet, so if
#          # success here should not indicate overall success:
#          if(grep m/\b$project_name\/$module_name\b/, @@tmp){
#              print "$script_name: previous entry in $loginfo_file found\n";
#          } else {
#              print "$script_name: creating entry for $htdoc_root/$project_name/$module_name\n";
#            
#              # This is the first time this is getting opened for writing,
#              # and it's possible that it came out 444.  So we'll try to change
#              # this for future generations: 
#              unless(-w "$loginfo_dir/$loginfo_file"){     
#                  chmod(0644, "$loginfo_dir/$loginfo_file")
#                      or die "$script_name: unable to set permissions on $loginfo_dir/$loginfo_file: $!\n";
#              }  
#              open(LOGINFO, ">> $loginfo_dir/$loginfo_file")
#                  or die "$script_name: unable to open $loginfo_dir/$loginfo_file for append: $!";
#
#              # Print command to the loginfo file:
#              print LOGINFO "$loginfo_cmd";
#              close(LOGINFO)
#                  or die "$script_name: unable to close $loginfo_dir/$loginfo_file: $!";
#          }
#      }


#---------------------------------------------------------------
# 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.32
log
@Change the cvs updating of web content so it does 'cvs update -Cd'
rather than 'cvs update -d' (The -C says, do fresh checkout; ignore
what is on the filesystem already; do not try to merge).
@
text
@d51 1
a51 1
# $Id: cvs-module-add,v 1.31 2001/05/10 20:40:42 thom Exp $
d99 1
a99 1
    . "(sleep 2; if [ -d $htdoc_root/$project_name/$module_name ]; then cd $htdoc_root/$project_name/$module_name; $cvs_bin -q update -Cd; fi) &\n";
@


1.31
log
@change the web publishing process to so that only one line is needed in
the loginfo file, "ALL $CVSROOT/CVSROOT/publish.pl %s", this line well
check to see if the commit contains published content and if so publish
it.
Issue number:
Obtained from:
Submitted by:
Reviewed by:
@
text
@d51 1
a51 1
# $Id: cvs-module-add,v 1.30 2001/04/18 02:02:58 kmaples Exp $
d99 1
a99 1
    . "(sleep 2; if [ -d $htdoc_root/$project_name/$module_name ]; then cd $htdoc_root/$project_name/$module_name; $cvs_bin -q update -d; fi) &\n";
@


1.30
log
@Undoing yesterday's commit - my hastiness to implement some sort of logging
level notion into these scripts caused me great pain.
@
text
@d51 1
a51 1
# $Id: cvs-module-add,v 1.28 2000/11/12 22:57:33 dlr Exp $
d185 41
a225 12
if($is_web){
    print "$script_name: adding line to loginfo file in web cvs root.\n";   
    my @@tmp = ();    ## Temp array for file contents
    # This could be improved ... there are two passes at the file
    # here; the first reads it in to check for the reference, and
    # the second opens it for appending (if necessary).
    if(open(LOGINFO, "<$loginfo_dir/$loginfo_file")){
        @@tmp = <LOGINFO>;
        close(LOGINFO);
    } else {
        print "$script_name: unable to open $loginfo_dir/$loginfo_file for read; will create\n";
    }
a226 24
    # check to see if an entry for this particular mod already exists.
    # Note that we haven't checked for the actual dir yet, so if
    # success here should not indicate overall success:
    if(grep m/\b$project_name\/$module_name\b/, @@tmp){
        print "$script_name: previous entry in $loginfo_file found\n";
    } else {
        print "$script_name: creating entry for $htdoc_root/$project_name/$module_name\n";
        
        # This is the first time this is getting opened for writing,
        # and it's possible that it came out 444.  So we'll try to change
        # this for future generations: 
        unless(-w "$loginfo_dir/$loginfo_file"){     
            chmod(0644, "$loginfo_dir/$loginfo_file")
                or die "$script_name: unable to set permissions on $loginfo_dir/$loginfo_file: $!\n";
        }  
        open(LOGINFO, ">> $loginfo_dir/$loginfo_file")
            or die "$script_name: unable to open $loginfo_dir/$loginfo_file for append: $!";

        # Print command to the loginfo file:
        print LOGINFO "$loginfo_cmd";
        close(LOGINFO)
            or die "$script_name: unable to close $loginfo_dir/$loginfo_file: $!";
    }
}
@


1.29
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";

d105 1
a105 1
print_log(1, "$script_name: beginning for project $project_name\n");
d110 1
a110 1
    print_log(1, "$script_name: module '$module_name' exists\n");
d113 1
a113 1
    print_log(1, "$script_name: adding dir $module_dir\n");
d119 1
a119 1
    print_log(1, "$script_name: $project_name/$module_name already exists under htdoc_root\n");
d134 1
a134 1
    print_log(1, "$script_name: creating /tmp/$tempdir for checkout\n");
d138 1
a138 1
    print_log(1, "$script_name: moving to /tmp/$tempdir\n");
d142 1
a142 1
    print_log(1, "$script_name: doing cvs co $project_name/$module_name\n");
d146 1
a146 1
    print_log(1, "$script_name: changing dir to $project_name/$module_name\n");
d153 1
a153 1
	print_log(1, "$script_name: rsyncing new content\n");
d160 1
a160 1
    print_log(1, "$script_name: adding default content to cvs\n");
d165 1
a165 1
        print_log(1, "$script_name: committing new content to cvs\n");
d171 1
a171 1
    print_log(1, "$script_name: removing /tmp/$tempdir\n");
d186 1
a186 1
    print_log(1, "$script_name: adding line to loginfo file in web cvs root.\n");
d195 1
a195 1
        print_log(1, "$script_name: unable to open $loginfo_dir/$loginfo_file for read; will create\n");
d202 1
a202 1
        print_log(1, "$script_name: previous entry in $loginfo_file found\n");
d204 1
a204 1
        print_log(1, "$script_name: creating entry for $htdoc_root/$project_name/$module_name\n");
@


1.28
log
@Resolved merge conflicts.
@
text
@d51 1
a51 1
# $Id: cvs-module-add,v 1.1.1.1 2000/11/12 21:17:30 dlr Exp $
d55 5
d110 1
a110 1
print "$script_name: beginning for project $project_name\n";
d115 1
a115 1
    print "$script_name: module '$module_name' exists\n";
d118 1
a118 1
    print "$script_name: adding dir $module_dir\n";
d124 1
a124 1
    print "$script_name: $project_name/$module_name already exists under htdoc_root\n";
d139 1
a139 1
    print "$script_name: creating /tmp/$tempdir for checkout\n";
d143 1
a143 1
    print "$script_name: moving to /tmp/$tempdir\n";
d147 1
a147 1
    print "$script_name: doing cvs co $project_name/$module_name\n";
d151 1
a151 1
    print "$script_name: changing dir to $project_name/$module_name\n";
d158 1
a158 1
	print "$script_name: rsyncing new content\n";   
d165 1
a165 1
    print "$script_name: adding default content to cvs\n";
d170 1
a170 1
        print "$script_name: committing new content to cvs\n";
d176 1
a176 1
    print "$script_name: removing /tmp/$tempdir\n";
d191 1
a191 1
    print "$script_name: adding line to loginfo file in web cvs root.\n";   
d200 1
a200 1
        print "$script_name: unable to open $loginfo_dir/$loginfo_file for read; will create\n";
d207 1
a207 1
        print "$script_name: previous entry in $loginfo_file found\n";
d209 1
a209 1
        print "$script_name: creating entry for $htdoc_root/$project_name/$module_name\n";
@


1.27
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-add,v 1.26 2000/09/28 17:50:40 kmaples Exp $
d116 37
a152 36
if($is_web){
    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:
d154 2
a155 2
        system("rsync -ar --cvs-exclude $htdoc_root/$default_content_dir/* .") == 0
            or warn "$script_name: Couldn't rsync $htdoc_root/$default_content_dir/*: $!\n";
d160 8
a167 23
        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";
    
        # Now go check out what we've just committed:
        chdir($htdoc_root) or die "$script_name: Couldn't chdir to $htdoc_root: $!\n";
        # Create the project dir if it doesn't already exist:
        mkdir($project_name, 0755) unless -d $project_name;
        chdir($project_name) or die "$script_name: Couldn't chdir /tmp: $!\n";
        system("$cvs_bin",'-d',"$cvsroot",'co','-d',"$module_name","$project_name/$module_name") == 0
            or die "$script_name: Couldn't perform cvs co: $!\n";
    
d169 1
d171 15
d205 8
a212 1

a243 1

@


1.26
log
@Fixed static pointer to /cvs to be $cvsroot.
@
text
@d51 1
a51 1
# $Id: cvs-module-add,v 1.25 2000/09/27 23:54:21 kmaples Exp $
a74 1
my $is_private         = $ARGV[8] || ''; # unreferenced.
@


1.25
log
@Minor change to avoid unnecessary process spawn.
@
text
@d51 1
a51 1
# $Id: cvs-module-add,v 1.24 2000/09/27 23:25:03 kmaples Exp $
d162 1
a162 1
           system("$cvs_bin",'-d','/cvs', 'add', @@contents) == 0
@


1.24
log
@Changed copying of default content to use rsync instead of cp.
@
text
@d51 1
a51 1
# $Id: cvs-module-add,v 1.23 2000/09/22 23:42:20 kmaples Exp $
d156 1
a156 1
	my @@contents = `find .| grep -v CVS`;
d158 2
a159 1

@


1.23
log
@Many changes and fixes; specified arguments to pass to bugzilla-*-delete
scripts; fixed some omissions preventing project dirs from being properly
deleted, etc.
@
text
@d51 1
a51 1
# $Id: cvs-module-add,v 1.22 2000/09/18 19:10:44 kmaples Exp $
d153 6
a158 19
        print "$script_name: copying default content\n";
        system("cp $htdoc_root/$default_content_dir/*.* ./") == 0
            or warn "$script_name: Couldn't cp $htdoc_root/$default_content_dir/*.*: $!\n";
    
        print "$script_name: getting dir contents\n";
        opendir(DIR,'./')
            or die "$script_name: couldn't read dirhandle: $!\n";
        my @@contents = readdir(DIR);
        closedir(DIR)
            or die "$script_name: couldn't close dirhandle: $!\n";
    
        my @@cleaned_contents = ();
        foreach(@@contents){
            next if m/^CVS/;
            next if m/^\./;
            push(@@cleaned_contents, $_);
        }
        @@contents = @@cleaned_contents;
    
a172 2
    
    
@


1.22
log
@Minor changes to account for repeated running of script.
@
text
@d51 1
a51 1
# $Id: cvs-module-add,v 1.21 2000/09/18 18:56:20 kmaples Exp $
d100 1
a100 1
    . "(sleep 2; cd $htdoc_root/$project_name/$module_name; $cvs_bin -q update -d) &\n";
@


1.21
log
@Not pretty, but it works.  Mostly this is a rearrangement of the order in
which things are done, but the script now goes into the HTDOC_ROOT/$project
directory and performs a cvs checkout of the newly-created module, and THEN
writing the update trigger to CVSROOT/loginfo, rather than writing the
trigger first, and relying upon it to cause the update to occur in HTDOC_ROOT
(I was unable to get cvs to behave corretly using this method).
@
text
@d51 1
a51 1
# $Id: cvs-module-add,v 1.20 2000/09/15 03:51:10 kmaples Exp $
a111 1
    print "$script_name: exiting successful\n";
d118 79
a196 49

    # 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: copying default content\n";
    system("cp $htdoc_root/$default_content_dir/*.* ./") == 0
        or warn "$script_name: Couldn't cp $htdoc_root/$default_content_dir/*.*: $!\n";

    print "$script_name: getting dir contents\n";
    opendir(DIR,'./')
        or die "$script_name: couldn't read dirhandle: $!\n";
    my @@contents = readdir(DIR);
    closedir(DIR)
        or die "$script_name: couldn't close dirhandle: $!\n";

    my @@cleaned_contents = ();
    foreach(@@contents){
        next if m/^CVS/;
        next if m/^\./;
        push(@@cleaned_contents, $_);
a197 27
    @@contents = @@cleaned_contents;

    print "$script_name: adding default content to cvs\n";
    if(@@contents){
       system("$cvs_bin",'-d','/cvs', '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";



    # Now go check out what we've just committed:
    chdir($htdoc_root) or die "$script_name: Couldn't chdir to $htdoc_root: $!\n";
    # Create the project dir if it doesn't already exist:
    mkdir($project_name, 0755) unless -d $project_name;
    chdir($project_name) or die "$script_name: Couldn't chdir /tmp: $!\n"; 
    system("$cvs_bin",'-d',"$cvsroot",'co','-d',"$module_name","$project_name/$module_name") == 0 
        or die "$script_name: Couldn't perform cvs co: $!\n";

@


1.20
log
@Fixed regex to display script name in logfiles.
@
text
@d51 1
a51 1
# $Id: cvs-module-add,v 1.19 2000/09/14 23:06:26 kmaples Exp $
a117 1

a118 29
    print "$script_name: adding line to loginfo file in web cvs root.\n";
    my @@tmp = ();

    # This could be improved ... there are two passes at the file
    # here; the first reads it in to check for the reference, and
    # the second opens it for appending (if necessary).
    if(open(LOGINFO, "<$loginfo_dir/$loginfo_file")){
        @@tmp = <LOGINFO>;
        close(LOGINFO);
    } else {
        print "$script_name: unable to open $loginfo_dir/$loginfo_file for read; will create\n";
    }

    # check to see if an entry for this particular mod already exists.
    # Note that we haven't checked for the actual dir yet, so if
    # success here should not indicate overall success:
    if(grep m/\b$project_name\/$module_name\b/, @@tmp){
        print "$script_name: previous entry in $loginfo_file found\n";
    } else {
        print "$script_name: creating entry for $htdoc_root/$project_name/$module_name\n";

        open(LOGINFO, ">> $loginfo_dir/$loginfo_file")
            or die "$script_name: unable to open $loginfo_dir/$loginfo_file for append: $!";

        # Print command to the loginfo file:
        print LOGINFO "$loginfo_cmd";
        close(LOGINFO)
            or die "$script_name: unable to close $loginfo_dir/$loginfo_file: $!";
    }
a120 1

d124 1
a124 1
    
a128 1
    
d132 1
a132 1
    
d134 1
a134 1
    mkdir("/tmp/$tempdir", 0755) 
d138 2
a139 2
    chdir("/tmp/$tempdir") 
        or die "$script_name: Couldn't chdir to /tmp/$tempdir: $!\n";   
d144 1
a144 1
    
d148 2
a149 2
    
    # This is unfortunate - passing this as a scalar means /bin/sh 
d155 1
a155 1
    
d158 1
a158 1
 	or die "$script_name: couldn't read dirhandle: $!\n";
d161 3
a163 3
	or die "$script_name: couldn't close dirhandle: $!\n";	
    
    my @@cleaned_contents = ();	
d169 1
a169 1
    @@contents = @@cleaned_contents; 		
d173 1
a173 1
       system("$cvs_bin",'-d','/cvs', 'add', @@contents) == 0 
d175 1
a175 1
    
d180 2
a181 2
    chdir('/tmp') or die "$script_name: Couldn't chdir /tmp: $!\n";;
    
d183 1
a183 1
    system('rm','-rf',"/tmp/$tempdir") == 0 
d186 39
d226 1
@


1.19
log
@Added provision for module description on cvs commit
@
text
@d51 1
a51 1
# $Id: cvs-module-add,v 1.18 2000/09/14 20:53:48 kmaples Exp $
d80 1
a80 1
$script_name =~ s/^.*\/([\w]+)$/$1/;
@


1.18
log
@Fixes and debugging.
@
text
@d51 1
a51 1
# $Id: cvs-module-add,v 1.17 2000/09/14 19:02:22 kmaples Exp $
d67 1
a67 1
my $sandbox        = $ARGV[0] || '';
d73 2
a74 2
my $module_description = $ARGV[6] || ''; # unreferenced.
my $is_web         = $ARGV[7] || ''; 
d209 1
a209 1
        system("$cvs_bin",'commit','-m') == 0
@


1.17
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-add,v 1.16 2000/09/14 00:04:45 kmaples Exp $
d209 1
a209 1
        system("$cvs_bin",'commit') == 0
@


1.16
log
@Fixed cvs action to occur only if directory is not empty.
@
text
@d1 1
a1 1
#!/usr/bin/perl -w
d51 1
a51 1
# $Id: cvs-module-add,v 1.15 2000/09/13 23:54:32 kmaples Exp $
d185 2
a186 2
    system("cp -r $htdoc_root/$default_content_dir/* ./") == 0
        or warn "$script_name: Couldn't cp $htdoc_root/$default_content_dir/*: $!\n";
d205 1
a205 1
        system("$cvs_bin", 'add', @@contents) == 0
@


1.15
log
@Added code to remove some bad cvs dirs from list of files to add to cvs
@
text
@d51 1
a51 1
# $Id: cvs-module-add,v 1.14 2000/09/13 23:44:27 kmaples Exp $
d191 1
a191 1
    my @@contents = readdir(DIR) || ();
d204 8
a211 7
    system("$cvs_bin", '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') == 0
        or die "$script_name: Couldn't perform cvs commit: $!\n";
    
@


1.14
log
@Fixed insecure system call
@
text
@d51 1
a51 1
# $Id: cvs-module-add,v 1.13 2000/09/13 22:33:46 kmaples Exp $
d194 8
@


1.13
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
@d51 1
a51 1
# $Id: cvs-module-add,v 1.12 2000/09/13 21:55:36 kmaples Exp $
d188 7
d196 1
a196 1
    system("$cvs_bin add *") == 0
@


1.12
log
@Set PATH in child scripts to suppress -T warnings.
@
text
@d51 1
a51 1
# $Id: cvs-module-add,v 1.11 2000/09/12 17:57:45 kmaples Exp $
d60 3
d207 17
@


1.11
log
@Added section for checking in default content if 'is_web' flag is set;
removed bad calls to cvs add.
@
text
@d51 1
a51 1
# $Id: cvs-module-add,v 1.10 2000/09/12 16:28:06 kmaples Exp $
d57 3
@


1.10
log
@Stubs for bugzilla-related functions
@
text
@d51 1
a51 1
# $Id: cvs-module-add,v 1.9 2000/09/08 19:31:17 kmaples Exp $
a110 4
    ## 'cvs add dir', or some such.
    chdir("$module_dir/..") or die "$script_name: couldn't chdir to $module_dir../:$!\n";
    system("$cvs_bin add $module_name") == 0
        or die "$script_name: couldn't perform cvs add: $!\n";
d143 52
a194 6
	# mkdir temp;
	# cd temp;
	# cvs -d $cvsroot co $project_name/$module_name
	# cd $project_name/$module_name
	# cp $HTDOC_ROOT/look/www/templates/*html (or all) ./;
	# cvs add *; cvs commit; 
@


1.9
log
@Changing script interactions with cvs
@
text
@d51 1
a51 1
# $Id: cvs-module-add,v 1.8 2000/09/08 18:17:15 kmaples Exp $
d147 6
a152 5

# Currently trying to work out what this operation should really do:
#   chdir($module_dir) or die "$script_name: unable to chdir to $module_dir:$!\n";
#   system($cvs_bin,) == 0
#        or die "$script_name: unable to perform :$!\n";
@


1.8
log
@Minor changes; mostly formatting
@
text
@d51 1
a51 1
# $Id: cvs-module-add,v 1.7 2000/09/08 17:19:06 kmaples Exp $
d113 1
a113 1
    system($cvs_bin,'add',$module_name) == 0 
d119 1
d122 1
a122 1
    # here; the first reads it in to check for the reference, and 
d124 9
a132 7
    open(LOGINFO, "<$loginfo_dir/$loginfo_file")
        or die "$script_name: unable to open $loginfo_dir/$loginfo_file for read: $!";
    my @@tmp = <LOGINFO>;
    close(LOGINFO);
    
    # check to see if an entry for this particular mod already exists. 
    # Note that we haven't checked for the actual dir yet, so if 
d138 1
a138 1
    
d142 3
a144 3
        # Print command to the loginfo file:    
        print LOGINFO "$loginfo_cmd";    
        close(LOGINFO) 
d147 1
a147 1
    
d152 1
a152 1
    
d157 1
@


1.7
log
@Minor flow changes
@
text
@d51 1
a51 1
# $Id: cvs-module-add,v 1.6 2000/09/05 22:57:48 kmaples Exp $
d61 1
a61 1
my $sandbox            = $ARGV[0] || '';
d68 1
a68 1
my $is_web             = $ARGV[7] || ''; 
d78 1
a78 1
my $cvsroot       = "$sandbox/$tigris_rep";
d94 1
a94 1
	. "(sleep 2; cd $htdoc_root/$project_name/$module_name; $cvs_bin -q update -d) &\n";
d105 1
a105 1
	print "$script_name: module '$module_name' exists\n";
d108 7
a114 7
	# Create the module directory:
	print "$script_name: adding dir $module_dir\n";
	mkdir($module_dir, 0775) or die "$script_name: mkdir $module_dir failed: $!\n";
	## 'cvs add dir', or some such.
	chdir("$module_dir/..") or die "$script_name: couldn't chdir to $module_dir../:$!\n";
	system($cvs_bin,'add',$module_name) == 0 
		or die "$script_name: couldn't perform cvs add: $!\n";
d120 3
a122 3
	# This could be improved ... there are two passes at the file
	# here; the first reads it in to check for the reference, and 
	# the second opens it for appending (if necessary).
d132 1
a132 1
    	print "$script_name: previous entry in $loginfo_file found\n";
d134 15
a148 13
    	print "$script_name: creating entry for $htdoc_root/$project_name/$module_name\n";
    	
		open(LOGINFO, ">> $loginfo_dir/$loginfo_file")
        	or die "$script_name: unable to open $loginfo_dir/$loginfo_file for append: $!";

	    # Print command to the loginfo file:    
    	print LOGINFO "$loginfo_cmd";    	
   		close(LOGINFO) or die "$script_name: unable to close $loginfo_dir/$loginfo_file: $!";
	}
# Currently trying to work out what this operation should really do:	
#	chdir($module_dir) or die "$script_name: unable to chdir to $module_dir:$!\n";
#	system($cvs_bin,) == 0
		 or die "$script_name: unable to perform :$!\n";
a153 1

@


1.6
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-add,v 1.5 2000/08/16 23:58:25 kmaples Exp $
d107 8
a114 1
    exit 0;
d143 4
a146 1

a148 6

# Finally, create the module directory:
print "$script_name: adding dir $module_dir\n";
mkdir($module_dir, 0775) or die "$script_name: mkdir $module_dir failed: $!\n";
    

@


1.5
log
@Extensive rewrites and modifications to standarize interface with caller
@
text
@d51 1
a51 1
# $Id: $
d77 1
a77 1
my $tigris_rep    = 'tigrisc/repository';      # static portion off sbx
@


1.4
log
@Minor syntax corrections.
@
text
@d51 1
a51 1
# $Id: cvs-module-add,v 1.3 2000/05/01 08:51:32 manoj Exp $
d53 4
a56 1
# Provide operations for CVS as past of Tigris
a59 1

d61 46
a106 22
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 $is_private         = $ARGV[7];

# my $cvsroot = $db->config('cvs_cvsroot');
my $cvsroot = "$sandbox/tigrisc/repository";

# my $htdocs = $db->config('apache_htdocs');
my $htdocs = "$sandbox/html";

# my $cvs_bin = $db-config('cvs_cvsbin') . "/cvs";
my $cvs_bin = "/usr/bin/cvs";

my $dir = "$cvsroot/$project_name/$module_name";

if ( -d $dir) {
    print "Module named \"$module_name\" already added\n";
d110 9
a118 7
if ($is_web == 1) {
    print "add a line to loginfo file in web cvs root.\n";
    open(LOGINFO, ">>$cvsroot/CVSROOT/loginfo")
        or die "open >>$cvsroot/CVSROOT/loginfo failed: $!";
    print LOGINFO "^$project_name/$module_name ";
    print LOGINFO "(sleep 2; cd $htdocs/$project_name/$module_name; ";
    print LOGINFO "$cvs_bin -q update -d) &\n";
d120 18
d140 3
a142 3
print "cvs: add a directory: " . $project_name . "/" . $module_name .
    " in cvs root for domain " . $domain_name . "\n";
mkdir($dir, 0775) or die " mkdir $dir failed: $!";
d144 6
@


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-add,v 1.2 2000/05/01 08:28:01 manoj Exp $
d75 3
a77 1
$cvs_bin = "/usr/bin/cvs";
d88 3
a90 3
    print(LOGINFO, "^$project_name/$module_name ");
    print(LOGINFO, "(sleep 2; cd $htdocs/$project_name/$module_name; ");
    print(LOGINFO, "$cvs_bin -q update -d) &\n");
a95 1
my $dir = "$cvsroot/$project_name/$module_name";
@


1.2
log
@Initial untested versions of Perl code for CVS module management.
@
text
@d51 1
a51 1
# $Id: cvs-module-add,v 1.1 2000/04/29 00:04:10 jrobbins Exp $
d77 5
a81 4
print "cvs: add a directory: " . $project_name . "/" . $module_name .
    " in cvs root for domain " . $domain_name . "\n";
my $dir = "$cvsroot/$project_name/$module_name";
mkdir($dir, 0775) or die " mkdir $dir failed: $!";
d91 5
@


1.1
log
@initial checkin
@
text
@d51 1
a51 1
# $Id: cvs.pm,v 1.1 2000/03/24 20:33:58 jrobbins Exp $
d68 13
a80 4
if ($is_web == 0) {
    print "cvs: add a directory: " . $project_name . "/" . $module_name .
	" in main cvs root for domain " . $domain_name . "\n";
}
a81 2
    print "cvs: add a directory: " . $project_name . "/" . $module_name .
	" in web cvs root for domain " . $domain_name . "\n";
d83 6
a88 1
    
@


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-add,v 1.3 2000/11/09 22:13:14 kmaples Exp $
d53 1
a53 1
# Provide operations for CVS as part of Tigris
d55 1
a55 7
# 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);
a57 2
use strict;

d59 12
a70 48
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";
my $module_dir    = "$cvsroot/$project_name/$module_name";

# 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;

my $loginfo_dir   = "$cvsroot/CVSROOT";
my $loginfo_file  = 'loginfo';

# This is the directive which get written out to the loginfo file:
my $loginfo_cmd   = "^$project_name/$module_name " 
    . "(sleep 2; if [ -d $htdoc_root/$project_name/$module_name ]; then cd $htdoc_root/$project_name/$module_name; $cvs_bin -q update -d; fi) &\n";

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

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

# Assume that if the directory exists, that the module has already
# been added:
if ( -d $module_dir) {
    print "$script_name: module '$module_name' exists\n";
} else {
    # Create the module directory:
    print "$script_name: adding dir $module_dir\n";
    mkdir($module_dir, 0775) or die "$script_name: mkdir $module_dir failed: $!\n";
d72 5
a76 67


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/' . $module_name;

    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";

    # Now go check out what we've just committed:
    chdir($htdoc_root) or die "$script_name: Couldn't chdir to $htdoc_root: $!\n";
    # Create the project dir if it doesn't already exist:
    mkdir($project_name, 0755) unless -d $project_name;
    chdir($project_name) or die "$script_name: Couldn't chdir /tmp: $!\n";
    system("$cvs_bin",'-d',"$cvsroot",'co','-d',"$module_name","$project_name/$module_name") == 0
        or die "$script_name: Couldn't perform cvs co: $!\n";

d78 1
a78 61

if($is_web){
    print "$script_name: adding line to loginfo file in web cvs root.\n";   
    my @@tmp = ();    ## Temp array for file contents
    # This could be improved ... there are two passes at the file
    # here; the first reads it in to check for the reference, and
    # the second opens it for appending (if necessary).
    if(open(LOGINFO, "<$loginfo_dir/$loginfo_file")){
        @@tmp = <LOGINFO>;
        close(LOGINFO);
    } else {
        print "$script_name: unable to open $loginfo_dir/$loginfo_file for read; will create\n";
    }

    # check to see if an entry for this particular mod already exists.
    # Note that we haven't checked for the actual dir yet, so if
    # success here should not indicate overall success:
    if(grep m/\b$project_name\/$module_name\b/, @@tmp){
        print "$script_name: previous entry in $loginfo_file found\n";
    } else {
        print "$script_name: creating entry for $htdoc_root/$project_name/$module_name\n";
        
        # This is the first time this is getting opened for writing,
        # and it's possible that it came out 444.  So we'll try to change
        # this for future generations: 
        unless(-w "$loginfo_dir/$loginfo_file"){     
            chmod(0644, "$loginfo_dir/$loginfo_file")
                or die "$script_name: unable to set permissions on $loginfo_dir/$loginfo_file: $!\n";
        }  
        open(LOGINFO, ">> $loginfo_dir/$loginfo_file")
            or die "$script_name: unable to open $loginfo_dir/$loginfo_file for append: $!";

        # Print command to the loginfo file:
        print LOGINFO "$loginfo_cmd";
        close(LOGINFO)
            or die "$script_name: unable to close $loginfo_dir/$loginfo_file: $!";
    }
}

#---------------------------------------------------------------
# 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.1.1.2
log
@Replacing the HEAD with the HELM_PEER_PORT_BRANCH.
@
text
@d51 1
a51 1
# $Id: cvs-module-add,v 1.28 2000/11/12 22:57:33 dlr Exp $
d244 1
@


