head	1.2;
access;
symbols;
locks; strict;
comment	@# @;


1.2
date	2000.05.13.17.06.37;	author jrobbins;	state dead;
branches;
next	1.1;

1.1
date	2000.03.24.20.33.58;	author jrobbins;	state Exp;
branches;
next	;


desc
@@


1.2
log
@removed files that have been replaced with newer files in helm/perl/scripts
@
text
@# ================================================================
# 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.
#


# $Id: cvs.pm,v 1.1 2000/03/24 20:33:58 jrobbins Exp $
# --------------------
# Provide operations for CVS as past of Tigris

package Helm::cvs;

use Helm::ToolHook;
@@ISA = qw(Helm::ToolHook);

use strict;

sub projectAdd {
    my ($class, $project_name, $domain_name, $brand_name, $is_private) = @@_;
    print "cvs: make a top level module for project $project_name\n";
}

sub projectDelete {
    my ($class, $project_name, $domain_name, $brand_name) = @@_;
    print "cvs: mv to safe place the top level module for project $project_name\n";
}

sub projectEdit {
    print "cvs: do nothing, the project name cannot change\n";
}


################################################################

sub moduleAdd {
    my ($class, $project_name, $domain_name, $brand_name,
        $module_name, $module_description, $is_web, $is_private) = @@_;

    if ($is_web == 0) {
        print "cvs: add a directory: " . $project_name . "/" . $module_name .
            " in main cvs root for domain " . $domain_name . "\n";
    }
    if ($is_web == 1) {
        print "cvs: add a directory: " . $project_name . "/" . $module_name .
            " in web cvs root for domain " . $domain_name . "\n";
        print "add a line to loginfo file in web cvs root.\n";
        
    }
}    


sub moduleDelete {
    my ($class, $project_name, $domain_name, $brand_name, $module_name, $is_web) = @@_;
    if ($is_web == 0) {
	print "cvs: mv directory: " . $project_name . "/" . $module_name .
	    " in web cvs root for domain " . $domain_name . " to somewhere inaccessable\n";
    }
    if ($is_web == 1) {
	print "cvs: mv directory: " . $project_name . "/" . $module_name .
	    " in main cvs root for domain " . $domain_name . " to somewhere inaccessable\n";
    }
}



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


################################################################

sub projMailAdd {
}

sub projMailDelete {
}

sub projMailEdit {
}




################################################################


sub user {
    my ($class, $db) = @@_;
    return $db->config('cvs_user');
}

# update Helm::CVSUsers $db;
# We just process the list of modules and add them. Trivial, really.
sub update {
    my ($class, $db) = @@_;
    my $cvsroot = $db->config('cvs_cvsroot');

    my $ts = new Helm::TableSync($db, 'project_modules',
				   [qw(project module)],
				   "$cvsroot/tigris-modules",
				   \&_map_module);
    $ts->check($cvsroot, \&_add_module, \&_del_module, undef, []);
}

# Map the name of the module to the directory name
# $dir = _map_module($cvsroot, $db, [$project $module]);
sub _map_module {
    my ($cvsroot, $db, $cols) = @@_;
    my ($project, $module) = @@$cols;

    return "$cvsroot/$project/$module";
}

# Add a module by adding the project and module directories
# _add_module($cvsroot, $db, $cols, $dir);
sub _add_module {
    my ($cvsroot, $db, $cols, $dir) = @@_;
    my ($project, $module) = @@$cols;

    if (-e $dir) {
	die "$dir exists, but is not a directory\n" unless -d $dir;
    } else {
	my $pdir = "$cvsroot/$project";
	if (-e $pdir) {
	    die "$pdir exists, but is not a directory\n" unless -d $pdir;
	} else {
	    mkdir $pdir, 0775;
	}
	mkdir $dir, 0775;
    }
}

# Delete a module by removing its directory
# _del_module($cvsroot, $db, $cols, $dir)
sub _del_module {
    my ($cvsroot, $db, $cols, $dir) = @@_;

    if (-d $dir) {
	# See comment in QmailLists.pm - this is the easiest way
	system("rm -rf $dir");
    } elsif (-e $dir) {
	die "$dir exists, but is not a directory\n";
    }
}

# When adding a project, nothing need be done - the directories will
# be created by update()
sub add_project {
    print "CVSmodules add_project called, does nothing\n";
}

# However, when deleting a project, we need to remove the CVS files
# for that project. All of them. The GUI had darn well better have an
# "are-you-sure" button. And keep backups.
sub del_project {
    my ($db, $project) = @@_;
    my $cvsroot = $db->config('cvs_cvsroot');

    my $dir = "$cvsroot/$project";
    if (-d $dir) {
	system("/bin/rm -rf $dir");
    } elsif (-e $dir) {
	die "$dir exists, but is not a directory\n";
    }

    return undef;
}
@


1.1
log
@initial check in of new perl modules for more-direct config file updating
@
text
@d48 1
a48 1
# $Id$
@

