(file) Return to jsoc_sync.pl CVS log (file) (dir) Up to [Development] / JSOC

File: [Development] / JSOC / Attic / jsoc_sync.pl (download)
Revision: 1.10, Wed Feb 2 19:39:51 2011 UTC (7 years, 8 months ago) by arta
Branch: MAIN
CVS Tags: HEAD
Changes since 1.9: +0 -0 lines
FILE REMOVED
Moved this file to proj/util/scripts.

#!/usr/bin/perl -w 

# script for synchronizing your CVS working directory with the CVS JSOC module (new tree)

# must run from root of JSOC tree (not necessarily from $JSOCROOT)

# run this on each machine to be used.
#    n02 - for linux_X86_64 machines
#    n00 - for linux4 machines such as n00, phil, etc.
# 
#    n12 formerly used for AMD x86-64 can also be used instead of n02
#    lws Itaniam processors no longer supported for JSOC

# This just in:
#   The cvs update "-d" flag will cause files outside of the CVS module
#   originally checked out to be downloaded.  This is bad, because
#   if a user checks out DRMS, then does a 'cvs update -d .', the
#   user then has the JSOC-module files in their working directory.
#   BUT, as long as the "-d" flag is not used, cvs update respects
#   boundaries of the module originally checked out: so 'cvs checkout DRMS'
#   followed by 'cvs update DRMS' will not result in any new files being 
#   downloaded that are outside of the DRMS module.  But new files
#   within the DRMS module WILL be downloaded.
#
#   So, this script should use 'cvs update' not 'cvs checkout'.  checkout
#   doesn't know how to remove files from the working directory that
#   have been deleted from the repository.  Since this script uses
#   'cvs update', there is no need to look at the 'modulespec.txt' file.
#
#   This just in.  If a cvs user adds a new directory to the repository, 
#   then the only way to get that new directory is to use the "-d" flag.
#   But we can't use the "-d" flag because this causes files outside of the
#   CVS module to be downloaded.  To work around the preposterous lameness of CVS
#   first call cvs update (no "-d" flag), then call cvs checkout.  The first call
#   will add/remove/update all files that are already in the user's 
#   working directory.  The second call will add files WITHIN THE CORRECT CVS 
#   MODULE that the user doesn't have.

$LATESTREL = "Ver_LATEST";
$CVSLOG = "cvsupdate.log";

my($aidx) = 0;
my($arg);
my($pos);
my($rev) = "";
my($line);
my($cvsmod);

while ($arg = shift(@ARGV))
{
    if ($arg eq "-R")
    {
	$rev = "-r $LATESTREL";
    }
    elsif (($pos = index($arg, "-l", 0)) == 0)
    {
	$CVSLOG = substr($arg, 2);
    }

    $aidx++;
}

if (-e "suflag.txt")
{
    $cvsmod = "JSOC";
}
else
{
    $cvsmod = "DRMS";
}

# remove old log file
if (-e $CVSLOG)
{
    unlink $CVSLOG;
}

CallCVS($rev);

print "JSOC synchronization finished.\n";

sub CallCVS
{
    my($rev) = @_;
    my($updatecmd);
    my($checkoutcmd);
    my($date);

    # The following command updates the files within the user's working directory and 
    # subdirectories - it doesn't add new directories that exist in the repository
    # but not in the user's working directory.
    # Can't use the -d flag to the update command, because this will cause CVS to 
    # update (download) files that belong to other modules. Otherwise, the -d
    # flag will add the new directories that exist in the repository, but not in the
    # user's working directory.
    # $updatecmd = "cvs update -AP $rev \.";

    # The following command WILL add new directories THAT EXIST ONLY IN THE CVS 
    # MODULE OF INTEREST. But of course CVS can't do anything completely right.
    # Whenever you have CVS modules, CVS will always print out spurious 
    # "cvs checkout: move away <file>; it is in the way" warnings if you 
    # call cvs checkout -AP JSOC, regardless if the above update command 
    # was first issued or not or if performing a fresh checkout.
    # Curiously, if you remove the -P flag, you won't see these problems.
    # $checkoutcmd = "cvs checkout -AP $rev $cvsmod";

    # But, there may be hope! If you run the checkout command first, without the
    # -P flag, then run the update flag with the -P flag, the update command
    # will remove the empty directories downloaded by the checkout command.
    # So, give this a go:
    $checkoutcmd = "cvs checkout -A $rev $cvsmod";
    $updatecmd = "cvs update -AP $rev \.";

    #Things that didn't really work:
    #$updatecmd = "(cd ..; $updatecmd | sed 's/^/STDOUT:/') 2>&1 |";
    #$updatecmd = "(cd $parent; $updatecmd) |";

    $date = `"date"`;

    open(CVSLOG, ">>$CVSLOG");
    print CVSLOG "$date\n";
    print CVSLOG "Calling '$checkoutcmd'.\n";
    close(CVSLOG);
    $checkoutcmd = "(cd ..; $checkoutcmd) 1>>$CVSLOG 2>&1";
    print "Calling '$checkoutcmd'.\n";
    system($checkoutcmd);

    open(CVSLOG, ">>$CVSLOG");
    print CVSLOG "Calling '$updatecmd'.\n";
    close(CVSLOG);
    $updatecmd = "($updatecmd) 1>>$CVSLOG 2>&1";
    print "Calling '$updatecmd'.\n";
    system($updatecmd);
}

Karen Tian
Powered by
ViewCVS 0.9.4