#! /bin/ksh # env ######################################################################## ######################################################################## # ENVIRONMENT SUBSHELL # # This program sets up all standard ClearCase Environment variables # (start with CCENV_*), the standard Unix variables, and the # ClearCase variables (start with CCASE_* or CLEARCASE_*) needed for # this project. The project then sets "ENV" to point to the ClearCase # Environement file that defines all the functions and aliases. # # Once this is done, Kornshell is called. Since all environment variables # are exported, they are sent to subshell environments, and the ENV # file reintroduces the aliases and functions that were previously # defined. # ######################################################################## ######################################################################## # CONSTANTS TO SET # # These are constants used in the "environment" shell script. You # set the project name (which might be different from the "user" # ID. Everything else should be set more or less automatically, although # it might vary from site to site more than project to project. # directory this script is in. # #----------------------------------------------------------------------- # # CCENV_PROJ: Name of the Project. This must be set for each # project. This is the used as the VOB mount point, # and for the shell prompt. # # CCENV_HOME: Home directory of the ClearCase Administrator for # this project. It should be the directory where this # shell script is stored. # # CCENV_ROOT: This is the root directory where the project VOB # directory mountpoint is actually attached. This only # needs to be set once for the entire site. This is NOT # the actual VOB mount point, but just the place where the # mount point mounts. I usually simply have this set as # "" so if my project is called foo, all of foo's VOBS # would be mounted off of "/foo". Some sites might want # something like "/vobs" so all of foo's VOBS will mount # off of "/vobs/foo". # # CCENV_VIEWRDIR: The directory were all views are stored. Views # shouldn't be stored in the user's HOME directory, but # in a subdirectory off of a View Server which should # be a fairly fast and reliable machine that no one # ever logs onto. In many cases, it is the ClearCase # VOB server. # # id: User's id. Used to create separate subdirectories for # user's views. Might vary how to find from system to system # #----------------------------------------------------------------------- # # export CCENV_PROJ="tek" export CCENV_ROOT="" export CCENV_HOME=$(dirname $0) [ "." = "$CCENV_HOME" ] && CCENV_HOME=$PWD id="$(id | sed 's/[^(]*(\([^(]*\)).*/\1/')" export CCENV_VIEWDIR=$CCENV_HOME/views/$id # ######################################################################## ######################################################################## # SETUP BASIC CLEARCASE ENVIRONMENT VARIABLES # # These are all self setting environment variables. # #----------------------------------------------------------------------- # # # CCENV_VOB_ROOT: This is the root directory where the VOBS are actually # attached. I take the CCENV_ROOT, and append the project # name on it. # # HOSTNAME: Name of current machine. It is set in some Kornshells # but not others. Since people depend upon it, I set it. # # ATRIAHOME: Home directory where ClearCase is loaded. Should always # be /usr/atria, but who knows... # # CCENV_PROMPT: Part of the Unix Prompt. Uppercase of project's name # # BOLD/OBOLD: Used in various Shell Scripts to turn bold prompting on # and off. Actually Standout Mode. # # cleartool: Where the cleartool command is located. Should be # $ATRIAHOME/bin/cleartool aka /usr/atria/bin/cleartool. # #----------------------------------------------------------------------- # # export CCENV_VOB_ROOT="$CCENV_ROOT/${CCENV_PROJ}" export CCENV_ADMINVOB="$CCENV_VOB_ROOT/AdminVOB" export HOSTNAME=$(uname -n) export ATRIAHOME=/usr/atria typeset -u CCENV_PROMPT="$CCENV_PROJ" export BOLD="$(tput smso 2> /dev/null)" export OBOLD="$(tput rmso 2> /dev/null)" export cleartool="$ATRIAHOME/bin/cleartool" # ######################################################################## ######################################################################## # FIND OUT IF YOU'RE SUN OR SOLARIS # # I store ClearCase scripts and binaries that all users should have # direct access to under the $CCENV_HOME/bin directory. In a # muli-system environment, there are some binaries that are machine # specific. This part of this script figures out the type of system # you're # on using the "uname -r" command. I need to know whether a # system is Solaris or SunOS. This will have to be modified from site # to get all the various possibilities. # typeset -L1 x_release=$(uname -r) if [ "$x_release" = "5" ] then export CCENV_SYSTEM=solaris else export CCENV_SYSTEM=sun4 fi export CCENV_SYSBIN=$CCENV_HOME/bin/$CCENV_SYSTEM # ######################################################################## ######################################################################## # IF SUNOS AND XTERM: CHANGE TO VT100 # # Due to a "feature" in the SunOS Xterm termdef, ClearStart doesn't # show a menu when run. To get around this problem, I change # the term on Sun4 systems to "vt100". # [ "sun4" = "$CCENV_SYSTEM" -a "xterm" = "$TERM" ] && export TERM="vt100" # ######################################################################## ######################################################################## # SET PATH # # Setup of standard PATH for ClearCase. I merely prepend the ClearCase # paths upon the user's path variables. I would prefer setting up # the path from scratch so all users have the exact same environment, # but too many users have their own favorite scripts. At least I # make sure they execute something related to ClearCase or this # environment before checking their own PATH # PATH="$CCENV_SYSBIN:$PATH" PATH="$ATRIAHOME/bin:$PATH" PATH="$CCENV_HOME/bin:$PATH" PATH="$ATRIAHOME/bugtrack:$PATH" export PATH # ######################################################################## ######################################################################## # SET MANPATH # # Setup of standard MANPATH for ClearCase. I merely prepend the ClearCase # paths upon the user's manpath variables. # MANPATH="$ATRIAHOME/doc/man:$MANPATH" # ######################################################################## ######################################################################## # SHELL MUST BE KORNSHELL # # I make all users use the Kornshell for their ClearCase shell. Even # Sun Systems now come with it. It is easier to have a single standard # shell for your development environment. The best all around purpose # shell is Kornshell. It has all the "must haves" that C shell uses, # and runs the standard Bourne syntax. It is now standard on almost # all Unix systems, and if not, is available free from AT&T. # # Best of all, Kornshell allows me to redefine the user's environment file # (which is usually $HOME/.kshrc) to whatever I want, and I use this # feature. In Bourne shell, you have to run "bash -posix" to get this # option to work. In Z-shell, you have to redefine "ZDOTDIR", and rename # the "environment file to ".zshrc". # # BASH is a close second as a default shell, but has some problems # with certain features. For example, BASH executes all for and while # loops in a subshell. This means variables set there won't be set once # you leave the loop which will cause havoc with the way CLEARCASE_AVOBS # is set. It might be possible to modify this behavior, but I personally # don't know how to do this. # # Becareful with PD-KSH. Various versions have various problems # with what should be normal Kornshell behavior. For example, # # OLDIFS="$IFS" # IFS=":" # echo "ennie:menie:minie:moe" | read one two three # IFS="$OLDIFS" # # in Kornshell will set one="ennie", two="menie", and three="minie:moe". # This doesn't work with some versions of PD-KSH. However, there is # nothing in the "env" file or the "environment" file that causes # any known version of pdksh any problems. # # Z-Shell is too unstable and bloated to use as a default shell, but # these script will work with Z-Shell if that is your site's preference. # Many sites like Z-Shell because Z-shell accepts a lot of the Csh # syntax and makes it a bit easier for a Csh user to convert over to # Z-Shell. # if [ -f /bin/ksh ] then export SHELL="/bin/ksh" else export SHELL="/usr/local/bin/ksh" fi # ######################################################################## ######################################################################## # STANDARD CLEARCASE ENVIRONMENT VARIABLES # # All of these are taken from the ClearCase Reference Manual in the # env_ccase section. Most are commented out because I don't want # to change them. However, the ones which I do set, I decomment # the line and edit it. # #ATRIA_LICENSE_HOST= #HP-UX Only #ATRIA_LINK_HOME= #HP-UX Only #ATRIA_RGY_HOST= #HP-UX Only #ATRIA_RGY_REGION= #HP-UX Only # #ATRIA_NO_BOLD=0 #Allow Bold character output #BITMAP_PATH="$HOME/.bitmaps:$ATRIA_CONFIG_DIR/ui/bitmaps" CLEARAUDIT_SHELL="$SHELL" #CCASE_AUDIT_TMPDIR="/tmp" #Abe Temporary Files #CLEARCASE_ABE_PN="$ATRIAHOME/etc/abe" #Audit Build Executor Location #CCASE_BLD_NOWAIT #Wait for VOB locks on build #CCASE_BLD_VOBS #Vobs to check for locks CCASE_BLD_UMASK="2" #Umask for Derived Objects #CLEARCASE_BLD_CONC="" #ClearCase Concurrency Level #CLEARCASE_CXX_COMP_INST #CLEARCASE_CMSAFE_CXX_LINK_INST #CLEARCASE_INCREMENTAL_CXX_LINK_INST #CLEARCASE_BLD_HOST_TYPE #CLEARCASE_DEBUG_GROUP="0" #Print debugging info in xclearcase #CLEARCASE_MAKE_CONFIG_DIR=$ATRIAHOME/config/clearmake #CLEARCASE_MAKE_COMPAT #CLEARCASE_BLD_OPTIONS_SPECS #CLEARCASE_BLD_SHELL_FLAGS="-e" #CLEARCASE_BLD_VERBOSITY=0 #CLEARCASE_MSG_PROTO #Who to talk to ToolTalk, SoftBench CLEARCASE_OBSO_SYN_EV="WARN" #Warn of Obsolete Syntax Usage #CLEARCASE_REMOTE_USER #clearexport_dsee Variable #CLEARCASE_ROOT #Auto Set For View Path Extend Naming #CLEARCASE_CMNT_PN= #Comment Caching File #CLEARCASE_TAB_SIZE="8" #Tab Size for xcleardiff, etc. #CLEARCASE_TRACE_TRIGGERS="0" #For Trigger Debugging #EXPORT_REPLACE_CHAR="." #Invalid Chars in clearexport_* files #EXPORT_REPLACE_COMM="made from flat file." #clearexport_ffile comment #EXPORT_REPLACE_STRING="REPLACED" #For clearexport_* #GRP_PATH="$HOME/grp:$ATRIAHOME/config/ui/grp" #Files xclearcase uses #ICON_PATH="$HOME/.icon:$ATRIAHOME/config/ui/icon" #Icons used by xclearcase MAGIC_PATH=$CCENV_HOME/magic:$ATRIAHOME/config/magic #Magic File #MAKEFLAGS="" #WINEDITOR="" #SCHEMESEARCHPATH=/usr/lib/X11/%T/%N%:$ATRIAHOME/config/ui/%T/%N%S # # ####ClearStart "HOME" Directory # export CLEARSTART_HOME="$CCENV_HOME/clearstart" # ######################################################################## ######################################################################## # SET CLEARCASE_AVOBS VARIABLE # # Sets up the -avobs switch in various commands to only include the # VOBs in the current project. This is done by seeing what other VOBs # are linked to the Administration VOB. This is done with a cleartool # describe command. The -fmt prevents printing of a "header" line, # and the -ahlink AdminVOB only lists AdminVOB hyperlinks. The # awk command simply strips out the VOB names. This will not work # with the standard BASH shell since CLEARCASE_AVOBs is being # set within the for loop. Should work with PD-KSH. # # I know I have personally rampaged against using the "for var in list" # in many shell scripts, but this only applies if you don't know the # size of the list being returned. The command buffer in Kornshell is # guaranteed to be at least 65,000 characters, which will allow for # over 1000 VOBs to be used in the for statement without over running # the command buffer. # CLEARCASE_AVOBS="$CCENV_ADMINVOB" CCENV_VOBLIST=$($cleartool desc -fmt "" -ahlink AdminVOB vob:$CCENV_ADMINVOB \ | awk -F: '/AdminVOB/ {print $2}') for vob in $CCENV_VOBLIST do CLEARCASE_AVOBS="$CLEARCASE_AVOBS:$vob" done # ######################################################################## ######################################################################## # EXPORT ENVIRONMENT FILE IF NEEDED # # Tricky stuff. I need to set the ClearCase Environment File, yet # I want to avoid infinite recursion too. To do this, I have to # make sure that $OLDENV != $ENV. If it does, null out $OLDENV. # if [ "" = "$OLDENV" ] then export OLDENV="$ENV" fi export ENV=$CCENV_HOME/environment [ "$ENV" = "$OLDENV" ] && OLDENV="" # ######################################################################## ######################################################################## # START THE SUBSHELL # # Starting this subshell will automatically source in the ClearCase # $ENV file. # ksh # ########################################################################