head	1.22;
access;
symbols
	TIGRIS_1_1_0RC2:1.19
	TIGRIS_1_1_0RC1:1.19
	TIGRIS_1_1:1.19.0.10
	TIGRIS_1_0_8:1.19
	TIGRIS_1_0_8RC3:1.19
	TIGRIS_1_0_8RC2:1.19
	TIGRIS_1_0_8RC1:1.19
	TIGRIS_1_0_7:1.19
	TIGRIS_1_0_7RC3:1.19
	TIGRIS_1_0_7RC2:1.19
	TIGRIS_1_0_7RC1:1.19
	TIGRIS_1_0_6:1.19
	TIGRIS_1_0_6RC5:1.19
	TIGRIS_1_0_6RC4:1.19
	TIGRIS_1_0_6RC3:1.19
	TIGRIS_1_0_6RC2:1.19
	TIGRIS_1_0_6RC1:1.19
	TIGRIS_1_0_5:1.19
	TIGRIS_1_0_5RC6:1.19
	TIGRIS_1_0_5RC5:1.19
	TIGRIS_1_0_5RC4:1.19
	TIGRIS_1_0_5RC3:1.19
	TIGRIS_1_0_5RC2:1.19
	TIGRIS_1_0_5RC1:1.19
	TIGRIS_1_0_4:1.19
	TIGRIS_1_0_3:1.19
	TIGRIS_1_0_2:1.19
	TIGRIS_1_0_1:1.19
	TIGRIS_1_0:1.19.0.12
	TIGRIS_1_0_0:1.19
	TIGRIS_1_0_0_RC1:1.19.0.8
	dlr:1.1.1
	TIGRIS_0_9_2_4:1.19
	TIGRIS_0_9_2_3:1.19
	HELM_PEER_PORT_BRANCH:1.1.1.2
	TURBINE_PEER:1.19
	TIGRIS_0_9_2_1:1.19
	TIGRIS_0_9_2:1.19.0.6
	TIGRIS_0_9_0:1.19.0.4
	TIGRIS_0_8_4:1.19.0.2
	NEWHELM:1.1.1.1
	TIGRIS_NOV_12_2000:1.1.1
	OLDHELM:1.17.0.2
	TIGRIS_NOV_11_2000:1.17
	TIGRIS_SEP_13_2000:1.10.0.2
	TIGRIS_BASELINE:1.17;
locks; strict;
comment	@# @;


1.22
date	2001.05.10.20.40.42;	author thom;	state Exp;
branches;
next	1.21;

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

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

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

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

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

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

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

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

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

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

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

1.10
date	2000.09.08.22.08.26;	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.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.16.23.58.25;	author kmaples;	state Exp;
branches;
next	1.5;

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

1.4
date	2000.05.01.09.10.31;	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.31;	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.22
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
@#!/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-delete
# $Id: cvs-module-delete,v 1.21 2001/04/18 02:02:58 kmaples 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 $is_web             = $ARGV[6] || ""; 

# 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';
my $tigris_del    = 'data/helm/cvs/deletedmodules';

my $cvsroot       = "$sandbox/$tigris_rep";
my $cvs_del_root  = "$sandbox/$tigris_del";

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

my $old_dir = "$cvsroot/$project_name/$module_name";
my $new_dir = "$cvs_del_root/$project_name/$module_name";

#---------------------------------------------------------------
# MAIN
#---------------------------------------------------------------
print "$script_name: beginning for $project_name\n";

# Remove the module dir from CVS:
if(-e $old_dir){
    # Old cvs directory exists, so we have to move it.
    # Check for the directory which should hold defunct projects:
    unless (-d $cvs_del_root) {
        mkdir($cvs_del_root, 0770) or die "$script_name: mkdir $cvs_del_root failed: $!\n";
    }
    
    # Check for directory to hold defunct modules:
    unless (-d "$cvs_del_root/$project_name"){
        mkdir("$cvs_del_root/$project_name", 0777)
            or die "$script_name: mkdir $cvs_del_root/$project_name failed: $!\n";
    }

    # If by some perversity of nature there's already a deleted
    # module dir, for god's sake, move it out of the way!
    if(-d $new_dir){
	print "$script_name: there's already a deleted module dir for $module_name.  Trying to move or delete.\n";
	system('mv',$new_dir,$new_dir .'.'. $$) == 0
	    or system('rm','-rf',$new_dir) == 0
	    or die "$script_name: unable to move or delete $new_dir: $!\n";
    }

    
    print "$script_name: moving $old_dir to $new_dir\n";
    
    # Note: rename() will fail here, because the directory will not
    # be empty (it'll have a CVS dir, at least).  Not worth the overhead
    # of File::Copy, so system it is:
    system('mv', $old_dir, $new_dir) == 0
        or die "$script_name: $old_dir -> $new_dir failed: $!\n";

} else {
    # No old cvs directory.
    print "$script_name: directory $old_dir not found\n";
}

# Remove the module dir from HTDOC_ROOT (if applicable):
if(-e "$htdoc_root/$project_name/$module_name"){
    # At this point, there's no danger of the module getting checked 
    # out of cvs again, so if the module had the 'is_web' flag set, 
    # go and delete its web component:
    
    chdir("$htdoc_root/$project_name") or die "$script_name: couldn't chdir to \n";
    print "$script_name: removing dir $module_name from $htdoc_root/$project_name\n";

    system('rm','-rf',$module_name) == 0 
        or die "$script_name: couldn't remove $module_name from $htdoc_root/$project_name: $!\n";
    
} else {
    # No old web directory.
    print "$script_name: directory $project_name/$module_name not found under htdoc root\n";
    print "$script_name: or 'is_web' not indicated\n";
}

## <thom> remove the deletion 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: looking for previous entry in loginfo file\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 deletion (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; exiting\n";
#              exit;
#          }
#        
#          if(grep m/\b$project_name\/$module_name\b/, @@tmp){
#              print "$script_name: previous entry in $loginfo_file found; removing\n";
#              @@tmp = grep !m/\b$project_name\/$module_name\b/, @@tmp;  
#            
#              open(LOGINFO, "> $loginfo_dir/$loginfo_file")
#                  or die "$script_name: unable to open $loginfo_dir/$loginfo_file for writing: $!";
#            
#              # Print command to the loginfo file:
#              print LOGINFO @@tmp;
#              close(LOGINFO)
#                  or die "$script_name: unable to close $loginfo_dir/$loginfo_file: $!";
#            
#           
#          } else {
#              print "$script_name: no entry found.";
#          }
#      }

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















@


1.21
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-delete,v 1.19 2000/11/21 21:33:30 kmaples Exp $
a151 2
if($is_web){
    print "$script_name: looking for previous entry in loginfo file\n";
d153 36
a188 23
    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 deletion (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; exiting\n";
	exit;
    }

    if(grep m/\b$project_name\/$module_name\b/, @@tmp){
        print "$script_name: previous entry in $loginfo_file found; removing\n";
        @@tmp = grep !m/\b$project_name\/$module_name\b/, @@tmp;  

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

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

    } else {
        print "$script_name: no entry found.";
    }
}
@


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

d96 1
a96 1
print_log(1, "$script_name: beginning for $project_name\n");
d115 1
a115 1
	print_log(1, "$script_name: there's already a deleted module dir for $module_name.  Trying to move or delete.\n");
d122 1
a122 1
    print_log(1, "$script_name: moving $old_dir to $new_dir\n");
d132 1
a132 1
    print_log(1, "$script_name: directory $old_dir not found\n");
d142 1
a142 1
    print_log(1, "$script_name: removing dir $module_name from $htdoc_root/$project_name\n");
d149 2
a150 2
    print_log(1, "$script_name: directory $project_name/$module_name not found under htdoc root\n");
    print_log(1, "$script_name: or 'is_web' not indicated\n");
d153 1
a153 1
    print_log(1, "$script_name: looking for previous entry in loginfo file\n");
d163 2
a164 2
        print_log(1, "$script_name: unable to open $loginfo_dir/$loginfo_file for read; exiting\n");
    	exit;
d168 1
a168 1
        print_log(1, "$script_name: previous entry in $loginfo_file found; removing\n");
d175 1
a175 1
        print_log LOGINFO @@tmp;
d181 1
a181 1
        print_log(1, "$script_name: no entry found.");
@


1.19
log
@Added removal of lines from loginfo file.
@
text
@d51 1
a51 1
# $Id: cvs-module-delete,v 1.18 2000/11/12 22:57:33 dlr Exp $
d55 5
d101 1
a101 1
print "$script_name: beginning for $project_name\n";
d120 1
a120 1
	print "$script_name: there's already a deleted module dir for $module_name.  Trying to move or delete.\n";
d127 1
a127 1
    print "$script_name: moving $old_dir to $new_dir\n";
d137 1
a137 1
    print "$script_name: directory $old_dir not found\n";
d147 1
a147 1
    print "$script_name: removing dir $module_name from $htdoc_root/$project_name\n";
d154 2
a155 2
    print "$script_name: directory $project_name/$module_name not found under htdoc root\n";
    print "$script_name: or 'is_web' not indicated\n";
d158 1
a158 1
    print "$script_name: looking for previous entry in loginfo file\n";
d168 2
a169 2
        print "$script_name: unable to open $loginfo_dir/$loginfo_file for read; exiting\n";
	exit;
d173 1
a173 1
        print "$script_name: previous entry in $loginfo_file found; removing\n";
d180 1
a180 1
        print LOGINFO @@tmp;
d186 1
a186 1
        print "$script_name: no entry found.";
@


1.18
log
@Resolved merge conflicts.
@
text
@d51 1
a51 1
# $Id: cvs-module-delete,v 1.1.1.1 2000/11/12 21:17:31 dlr Exp $
d87 3
d116 1
a116 1
	system('mv',$new_dir,$new_dir . $$) == 0
d136 1
a136 1
if($is_web && -e "$htdoc_root/$project_name/$module_name"){
d152 21
d174 10
@


1.17
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-delete,v 1.16 2000/09/19 17:30:38 kmaples Exp $
@


1.16
log
@Typo.
@
text
@d51 1
a51 1
# $Id: cvs-module-delete,v 1.15 2000/09/19 17:27:49 kmaples Exp $
d108 10
@


1.15
log
@Some pruning and changes to program flow; removed unnecessary references to
cvs binary; changed script to mirror actions of cvs-module-add.
@
text
@d51 1
a51 1
# $Id: cvs-module-delete,v 1.14 2000/09/15 03:51:10 kmaples Exp $
a138 6


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

@


1.14
log
@Fixed regex to display script name in logfiles.
@
text
@d51 1
a51 1
# $Id: cvs-module-delete,v 1.13 2000/09/14 19:02:22 kmaples Exp $
d68 2
a69 2
my $htdoc_root         = $ARGV[1] || ""; # unreferenced.
my $project_name       = $ARGV[2] || ""; 
d73 1
a73 1
my $is_web             = $ARGV[6] || ""; # unreferenced.
d75 1
a75 1
# Grab just the filename portion of this script to use as a 
a86 8
# 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;

d95 24
a118 3
# If the directory doesn't exist, assume that the module has
# already been deleted:
unless(-e $old_dir){
a119 7
    print "$script_name: exiting successful\n";
    exit 0;
}

# Check for the directory which should hold defunct projects:
unless (-d $cvs_del_root) {
    mkdir($cvs_del_root, 0770) or die "$script_name: mkdir $cvs_del_root failed: $!\n";
d122 16
a137 4
# Check for directory to hold defunct modules:
unless (-d "$cvs_del_root/$project_name"){
    mkdir("$cvs_del_root/$project_name", 0777)
        or die "$script_name: mkdir $cvs_del_root/$project_name failed: $!\n";
a139 1
print "$script_name: moving $old_dir to $new_dir\n";
d141 3
a143 5
# Note: rename() will fail here, because the directory will not
# be empty (it'll have a CVS dir, at least).  Not worth the overhead
# of File::Copy, so system it is:
system('mv', $old_dir, $new_dir) == 0 
    or die "$script_name: $old_dir -> $new_dir failed: $!\n";
@


1.13
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-delete,v 1.12 2000/09/13 22:33:46 kmaples Exp $
d78 1
a78 1
$script_name =~ s/^.*\/([\w]+)$/$1/;
@


1.12
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-delete,v 1.11 2000/09/13 21:55:36 kmaples Exp $
@


1.11
log
@Set PATH in child scripts to suppress -T warnings.
@
text
@d51 1
a51 1
# $Id: cvs-module-delete,v 1.10 2000/09/08 22:08:26 kmaples Exp $
d60 3
d135 16
@


1.10
log
@Changed 'rename' calls to system calls (dirs wouldn't be empty at time of
rename, and perl doesn't like that)
@
text
@d51 1
a51 1
# $Id: cvs-module-delete,v 1.9 2000/09/08 19:31:17 kmaples Exp $
d57 3
@


1.9
log
@Changing script interactions with cvs
@
text
@d51 1
a51 1
# $Id: cvs-module-delete,v 1.8 2000/09/05 22:57:48 kmaples Exp $
d117 6
a122 1
rename($old_dir, $new_dir) or die "$script_name: rename $old_dir -> $new_dir failed: $!\n";
@


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-delete,v 1.7 2000/09/05 03:20:09 kmaples Exp $
d111 2
a112 2
unless (-d $cvs_del_root/$project_name){
    mkdir($cvs_del_root/$project_name, 0777)
@


1.7
log
@Minor fixes; set some default values to ' || "";'
@
text
@d51 1
a51 1
# $Id: cvs-module-delete,v 1.6 2000/08/16 23:58:25 kmaples Exp $
d75 2
a76 2
my $tigris_rep    = 'tigrisc/repository';
my $tigris_del    = 'tigrisc/deletedmodules';
@


1.6
log
@Extensive rewrites and modifications to standarize interface with caller
@
text
@d51 1
a51 1
# $Id: cvs-module-delete,v 1.5 2000/08/02 18:37:57 kmaples Exp $
d61 7
a67 7
my $sandbox            = $ARGV[0];
my $htdoc_root         = $ARGV[1]; # unreferenced.
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]; # unreferenced.
@


1.5
log
@Minor syntax corrections.
@
text
@d51 1
a51 1
# $Id: cvs-module-delete,v 1.4 2000/05/01 09:10:31 manoj Exp $
d55 3
d61 27
a87 17
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 $is_web             = $ARGV[5];

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

my $cvs_del_root = "$sandbox/tigrisc/deletedmodules";

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

# my $cvs_bin = $db-config('cvs_cvsbin') . "/cvs";
my $cvs_bin = "/usr/bin/cvs";
d92 10
a101 2
if (! -e $old_dir) {
    print "Module named \"$module_name\" already deleted\n";
d105 4
a108 2
print "cvs: mv directory: " . $project_name . "/" . $module_name .
	" in web cvs root for domain " . $domain_name . " to somewhere inaccessable\n";
d110 1
a110 3
unless (-d $cvs_del_root){
    mkdir($cvs_del_root, 0777) or die "mkdir $cvs_del_root failed: $!";
}
d113 1
a113 1
        or die "mkdir $cvs_del_root/$project_name failed: $!";
d115 23
a137 1
rename("$old_dir", "$new_dir") or die "rename $old_dir -> $new_dir failed: $!";
@


1.4
log
@Protect some cases where it's okay for mkdir to fail.
@
text
@d51 1
a51 1
# $Id: cvs-module-delete,v 1.3 2000/05/01 08:51:32 manoj Exp $
d76 2
a77 2
my $old_dir = $cvsroot/$project_name/$module_name";
my $new_dir = $cvs_del_root/$project_name/$module_name";
d87 5
a91 4
unless (-d $cvs_del_root)
    mkdir($cvs_del_root) or die "mkdir $cvs_del_root failed: $!";
unless (-d $cvs_del_root/$project_name)
    mkdir($cvs_del_root/$project_name)
d93 1
@


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-delete,v 1.2 2000/05/01 08:28:01 manoj Exp $
d87 5
a91 3
mkdir("$cvs_del_root") or die "mkdir $cvs_del_root failed: $!";
mkdir("$cvs_del_root/$project_name")
    or die "mkdir $cvs_del_root/$project_name failed: $!";
@


1.2
log
@Initial untested versions of Perl code for CVS module management.
@
text
@d51 1
a51 1
# $Id: cvs-module-delete,v 1.1 2000/04/29 00:04:10 jrobbins Exp $
d74 9
a82 1
$cvs_bin = "/usr/bin/cvs";
d90 1
a90 4
rename("$cvsroot/$project_name/$module_name",
       "$cvs_del_root/$project_name/$module_name")
    or die "rename $cvsroot/$project_name/$module_name -> " .
           "$cvs_del_root/$project_name/$module_name failed: $!"
@


1.1
log
@initial checkin
@
text
@d51 1
a51 1
# $Id: cvs.pm,v 1.1 2000/03/24 20:33:58 jrobbins Exp $
d65 12
a76 2
if ($is_web == 0) {
    print "cvs: mv directory: " . $project_name . "/" . $module_name .
d78 8
a85 5
}
if ($is_web == 1) {
    print "cvs: mv directory: " . $project_name . "/" . $module_name .
	" in main cvs root for domain " . $domain_name . " to somewhere inaccessable\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-delete,v 1.1 2000/10/05 20:05:49 jrobbins 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);


d58 10
a67 63
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] || ""; 

# 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';
my $tigris_del    = 'data/helm/cvs/deletedmodules';

my $cvsroot       = "$sandbox/$tigris_rep";
my $cvs_del_root  = "$sandbox/$tigris_del";

my $old_dir = "$cvsroot/$project_name/$module_name";
my $new_dir = "$cvs_del_root/$project_name/$module_name";

#---------------------------------------------------------------
# MAIN
#---------------------------------------------------------------
print "$script_name: beginning for $project_name\n";

# Remove the module dir from CVS:
if(-e $old_dir){
    # Old cvs directory exists, so we have to move it.
    # Check for the directory which should hold defunct projects:
    unless (-d $cvs_del_root) {
        mkdir($cvs_del_root, 0770) or die "$script_name: mkdir $cvs_del_root failed: $!\n";
    }
    
    # Check for directory to hold defunct modules:
    unless (-d "$cvs_del_root/$project_name"){
        mkdir("$cvs_del_root/$project_name", 0777)
            or die "$script_name: mkdir $cvs_del_root/$project_name failed: $!\n";
    }

    # If by some perversity of nature there's already a deleted
    # module dir, for god's sake, move it out of the way!
    if(-d $new_dir){
	print "$script_name: there's already a deleted module dir for $module_name.  Trying to move or delete.\n";
	system('mv',$new_dir,$new_dir . $$) == 0
	    or system('rm','-rf',$new_dir) == 0
	    or die "$script_name: unable to move or delete $new_dir: $!\n";
    }

    
    print "$script_name: moving $old_dir to $new_dir\n";
    
    # Note: rename() will fail here, because the directory will not
    # be empty (it'll have a CVS dir, at least).  Not worth the overhead
    # of File::Copy, so system it is:
    system('mv', $old_dir, $new_dir) == 0
        or die "$script_name: $old_dir -> $new_dir failed: $!\n";

} else {
    # No old cvs directory.
    print "$script_name: directory $old_dir not found\n";
d69 3
a71 17

# Remove the module dir from HTDOC_ROOT (if applicable):
if($is_web && -e "$htdoc_root/$project_name/$module_name"){
    # At this point, there's no danger of the module getting checked 
    # out of cvs again, so if the module had the 'is_web' flag set, 
    # go and delete its web component:
    
    chdir("$htdoc_root/$project_name") or die "$script_name: couldn't chdir to \n";
    print "$script_name: removing dir $module_name from $htdoc_root/$project_name\n";

    system('rm','-rf',$module_name) == 0 
        or die "$script_name: couldn't remove $module_name from $htdoc_root/$project_name: $!\n";
    
} else {
    # No old web directory.
    print "$script_name: directory $project_name/$module_name not found under htdoc root\n";
    print "$script_name: or 'is_web' not indicated\n";
a72 35

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














@


1.1.1.2
log
@Replacing the HEAD with the HELM_PEER_PORT_BRANCH.
@
text
@d51 1
a51 1
# $Id: cvs-module-delete,v 1.19 2000/11/21 21:33:30 kmaples Exp $
a86 3
my $loginfo_dir   = "$cvsroot/CVSROOT";
my $loginfo_file  = 'loginfo';

d113 1
a113 1
	system('mv',$new_dir,$new_dir .'.'. $$) == 0
d133 1
a133 1
if(-e "$htdoc_root/$project_name/$module_name"){
a148 21
if($is_web){
    print "$script_name: looking for previous entry in loginfo file\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 deletion (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; exiting\n";
	exit;
    }

    if(grep m/\b$project_name\/$module_name\b/, @@tmp){
        print "$script_name: previous entry in $loginfo_file found; removing\n";
        @@tmp = grep !m/\b$project_name\/$module_name\b/, @@tmp;  

        open(LOGINFO, "> $loginfo_dir/$loginfo_file")
            or die "$script_name: unable to open $loginfo_dir/$loginfo_file for writing: $!";
a149 10
        # Print command to the loginfo file:
        print LOGINFO @@tmp;
        close(LOGINFO)
            or die "$script_name: unable to close $loginfo_dir/$loginfo_file: $!";


    } else {
        print "$script_name: no entry found.";
    }
}
@


