#!/usr/cs/bin/csh
#
# PROJECT: TCA
#
# (c) Copyright 1994. All rights reserved.
#
# ABSTRACT:
# This is a shell script to setup the initial directory structure for a
# member of the TCA software team.
#
# To use this script, put this directory in your search path.
# 
# Adapted from setupLRD used in the ratler project.
#
# $Source: /afs/cs.cmu.edu/project/TCA/Master/tcaV8/etc/setupTCA,v $ 
# $Revision: 1.2 $
# $Date: 1996/02/06 19:03:10 $
# $Author: rich $
#
# REVISION HISTORY:
#
# $Log: setupTCA,v $
# Revision 1.2  1996/02/06  19:03:10  rich
# ???
#
# Revision 1.1  1995/01/18  22:56:16  rich
# Now look for cvs in /usr/local before /usr/misc.
#
#

set ROOT = /afs/cs.cmu.edu/project/TCA/release/alpha

set ldir = $cwd

while ($ldir != "")
  if (($ldir == "/usr1/robocomp")) then
    echo "Making files group read/write in " $ldir
    umask 002
  endif
  set ldir = $ldir:h
end

echo "Is " `pwd` "the correct directory to put Xavier files in?"
echo "Y or N (n)" 
set ok = $<
if (($ok == "y") || ($ok == "Y")) then
# go ahead and set up the directory structure
# echo "Making sub directories.  Ignore error messages."
# Links are now made automatically by the makefiles.
# $ROOT/etc/makeLinks
# checkout the required cvs directories.
  set releaseDir = $ROOT
  echo "Release directory is " $releaseDir
  foreach module ($releaseDir/*) 
    if (-e $module/CVS) then
       echo "Checkout module" `cat $module/CVS/Repository` "?"
       echo "Y or N (n)" 
       set ok = $<
       if (( $ok == "y" ) || ( $ok == "Y" )) then
         set subdirs = "NO"
         foreach submodule ($module/*) 
           if (-e $submodule/CVS) then
             set subdirs = "YES"
             echo "Checkout module" `cat $submodule/CVS/Repository` "?"
             echo "Y or N (n)" 
             set ok = $<
             if (( $ok == "y" ) || ( $ok == "Y" )) then
               echo $releaseDir/etc/tcvs checkout `cat $submodule/CVS/Repository`
               $releaseDir/etc/tcvs checkout `cat $submodule/CVS/Repository`
             endif
           endif
         end
         if ($subdirs == "NO") then
           echo $releaseDir/etc/tcvs checkout `cat $module/CVS/Repository`
           $releaseDir/etc/tcvs checkout `cat $module/CVS/Repository`
         else
# there were some subdirectories, make sure we get this level
           set files = `awk 'BEGIN {FS="/"} {print $2}' $module/CVS/Entries`
           foreach file ($files) 
             echo $releaseDir/etc/tcvs checkout `cat $module/CVS/Repository`/$file
             $releaseDir/etc/tcvs checkout `cat $module/CVS/Repository`/$file
           end
         endif
      endif
    endif
  end
# there were some subdirectories, make sure we get this level
  set files = `awk 'BEGIN {FS="/"} {print $2}' $releaseDir/CVS/Entries`
  foreach file ($files) 
    echo $releaseDir/etc/tcvs checkout `cat $releaseDir/CVS/Repository`/$file
    $releaseDir/etc/tcvs checkout `cat $releaseDir/CVS/Repository`/$file
  end
endif

echo "done."
