#! /bin/csh -fb # PackageScript(.csh) # # This is the main script for starting packaged worlds. Things like # CommanderWorld and RawViewersWorld are front ends to this. This parses # the command line and then makes a local copy of the packaged world # before executing it. # Philip James, March 14, 1990 12:30:34 pm PST # Willie-Sue Orr, April 29, 1992 12:57:41 pm PDT # Brent Welch, June 28, 1990 1:31:43 pm PDT # JKF, May 20, 1991 12:55:40 pm PDT # # Usage: PackageScript package_name options ... # Valid options are # -localdir localdir # -localdirENV environ_var # -remotedir remotedir # -remotedirENV environ_var # -nocopy # -cirioPort number # -vp num_vps # -stdiop num_iops # -thread num_threads # -mem stack_memory ?? # -heap initial_heap_size # +Targs thread_arg_to_add # -Targs thread_arg_to_replace_defaults # +PCRargs pcr_arg_to_add # -PCRargs pcr_arg_to_replace_defaults # -rung~o set switch to load unoptomized code # # Obsolete options that are ignored are # -opt (all packages are optimized now) # -noOpt (ditto) # -nocirio (cirio is in all packages now) # -plain (I don't know what this meant) # -sv (Everything uses SysV shared memory now) # # # Sanity checks against the environment # if ( `/usr/ucb/printenv cedar10_1` == "" ) setenv cedar10_1 /project/cedar10.1/ if (! -d $cedar10_1) then echo 'Cannot find Cedar home ($cedar10_1): ' "$cedar10_1" exit 1 endif if (! -d $cedar10_1/bin) then echo 'Cannot find Cedar binaries: ($cedar10_1/bin): ' "$cedar10_1/bin" exit 1 endif if (! -d $cedar10_1/release) then echo 'Cannot find Cedar release ($cedar10_1/release): ' "$cedar10_1/release" exit 1 endif # # Set up default parameters: $1 is the package name # $package_name is all lowercase. # $installed_package is the latest version of the package from $remotedir # set local_package = $1 set initialCommand = $2 # setenv COMMANDER_INITIAL_COMMAND $2 set package_name = `/bin/echo $local_package | /bin/tr A-Z a-z` shift argv shift argv set remotedir = "" set mysteryArg = "" if ( ! $?TMPDIR) setenv TMPDIR /tmp if ( ! $?XR_HOME ) setenv XR_HOME /pseudo/xrhome if ( ! $?XR_CONFIG ) setenv XR_CONFIG Threads if ( ! $?XR_MACH ) setenv XR_MACH sparc if ( ! $?XR_VERSION ) setenv XR_VERSION INSTALLED if ( ! $?XR_XHOST ) setenv XR_XHOST `/bin/hostname` set threads_args = ( -slaveiop 1 -slave 1 ) set num_vp = 2 # -vp default set num_iop = 2 # -stdiop default set num_threads = 80 # -thread default set mem = 300000 # -mem default set shmtype = sv # -shmtype default set pcr_args = ( -t ) set heap = 5000000 # -h default set override_Targs = "no" set override_PCRargs = "no" set note = "no" set tcopy = `/usr/ucb/printenv NOCOPY` if ("$tcopy" != "") then set copy = "no" else set copy = "yes" endif set alwayscopy = `/usr/ucb/printenv ALWAYSCOPY` if ("$alwayscopy" != "") then set alwayscopy = "yes" else set alwayscopy = "no" endif # # Parse command line # top: if ( $#argv > 0 ) then switch ($argv[1]) case -localdir: shift argv if (! -d $argv[1]) then /bin/echo "Bad localdir: $argv[1]" exit 1 endif set localdir = $argv[1] shift argv goto top case -localdirENV: shift argv set DIR_VAR = $argv[1] # # One level of indirection to get the user's # preferred local directory from the environment. # The standard scripts use this method, even though # the user may not define the environment variable. # set localdir = `/usr/ucb/printenv $DIR_VAR` if ("$localdir" == "") then # # no pre-defined directory in the environment # unset localdir set note = "yes" else if (! -d $localdir) then /bin/echo "Bad $local_package directory from $DIR_VAR environment variable" exit 1 endif endif shift argv goto top case -remotedir: shift argv if (! -d $argv[1]) then /bin/echo "Bad remotedir: $argv[1]" exit 1 endif set remotedir = $argv[1] shift argv goto top case -remotedirENV: shift argv set DIR_VAR = $argv[1] # # One level of indirection to get the user's # preferred remote directory from the environment. # The standard scripts use this method, even though # the user may not define the environment variable. # set remotedir = `/usr/ucb/printenv $DIR_VAR` if ("$remotedir" != "") then if (! -d $localdir) then /bin/echo "Bad $local_package directory from $DIR_VAR environment variable" exit 1 endif endif shift argv goto top case -nocopy: shift argv set copy = "no" goto top case -alwayscopy: shift argv set alwayscopy = "yes" goto top case -cirioPort: shift argv setenv CirioPort $argv[1] shift argv goto top case -vp: shift argv set num_vp = ( $argv[1]:q ) shift argv goto top case -stdiop: shift argv set num_iop = ( $argv[1]:q ) shift argv goto top case -thread: shift argv set num_threads = ( $argv[1]:q ) shift argv goto top case -mem: shift argv set mem = ( $argv[1]:q ) shift argv goto top case -shmtype: shift argv set shmtype = ( $argv[1]:q ) shift argv goto top case -heap: shift argv set heap = ( $argv[1]:q ) shift argv goto top case -Targs: shift argv set threads_args = ( $argv[1]:q ) set override_Targs = "yes" shift argv goto top case +Targs: shift argv set threads_args = ( $threads_args:q $argv[1]:q ) shift argv goto top case -PCRargs: shift argv set pcr_args = ( $argv[1]:q ) set override_PCRargs = "yes" shift argv goto top case +PCRargs: shift argv set pcr_args = ( $pcr_args:q $argv[1]:q ) shift argv goto top case -rung~o: shift argv set initialCommand = ( "rung -~o; " $initialCommand ) goto top # # Old arguments # case -plain: /bin/echo "-plain is obsolete" shift argv goto top case -opt: /bin/echo "-opt is obsolete" shift argv goto top case -noOpt: /bin/echo 'All packages are optimized.' exit 1 case -sv: shift argv /bin/echo "-sv option is obsolete" goto top case -nocirio: /bin/echo "packaged world without Cirio no longer exists." shift argv goto top case -makedo: /bin/echo 'packaged world with language tools no longer exists.' shift argv goto top case -*: /bin/echo "argument { $argv[1] } not understood" exit 1 default: set mysteryArg = ( $argv[1]:q ) shift argv goto top endsw endif if ($override_Targs == "no") then set threads_args = ( $threads_args:q -vp $num_vp -stdiop $num_iop -thread $num_threads -mem $mem -shmtype $shmtype ) endif if ($override_PCRargs == "no") then set pcr_args = ( $pcr_args:q -h $heap ) endif if ($mysteryArg:q != "") then set initialCommand = ( $initialCommand:q \; $mysteryArg:q ) endif # echo $initialCommand:q setenv COMMANDER_INITIAL_COMMAND "$initialCommand:q" # # See if a remotedir has been set, or supply a default # if ($remotedir == "") then set remotedir = $cedar10_1/release/packagedworlds/sun4 endif # # Choose a local directory (/tmp or /usr/tmp) with lots of space. # if ($copy == "yes" && ! $?localdir) then # # Nothing specified explicitly. Look around for an existing package, # otherwise choose a directory with lots of room. # if (-e /tmp/$local_package) then set localdir = /tmp else if (-e /usr/tmp/$local_package) then set localdir = /usr/tmp else set spacetmp = `/bin/df /tmp | /bin/sed '/Filesystem/d' | /bin/awk '{print $4}'` set spaceusr = `/bin/df /usr/tmp | /bin/sed '/Filesystem/d' | /bin/awk '{print $4}'` if ($spaceusr > $spacetmp) then set localdir = "/usr/tmp" else set localdir = "/tmp" endif if ("$note" == "yes") then /bin/echo "Note: the $DIR_VAR env-var specifies a place for a copy of $local_package" /bin/echo "Otherwise, either /tmp or /usr/tmp is used, depending on space available" endif endif else if (! $?localdir) then set localdir # so if test doesn't fail below. copy == no here. endif # # get the latest version of the package from remotedir # set installed_package = `/bin/ls -t $remotedir/$package_name.~*~ | /usr/ucb/head -1` # # Decide if we should copy the installed version to the local copy # Need a CHANGED variable to distinquish between using no copy because # unchanged and no copy because we're using the remote file. # set CHANGED = $copy # yes if make local copy, no if use remote file if ($copy == "yes" && -e $localdir/$local_package ) then set x1 = `/bin/ls -lL $installed_package | /bin/awk '{ print $4, $5, $6, $7 }'` set x2 = `/bin/ls -lL $localdir/$local_package | /bin/awk '{ print $4, $5, $6, $7 }'` if ( "$x1" == "$x2" ) set CHANGED = "no" endif if ( $CHANGED == "yes" ) then if ( -e $localdir/$local_package) then if ( $alwayscopy == "yes" ) then set YES = "y" else /bin/echo "Your copy of $local_package is different than the installed one" /bin/echo -n "do you want to update ? " set YES = $< endif else set YES = "y" endif if ( $YES =~ y* ) then # # check disk space before copy # if ( -e $localdir/$local_package) rm -f $localdir/$local_package set size = `/bin/ls -lL $installed_package | /bin/awk '{printf "%d", $4 / 1024}'` set space = `/bin/df $localdir | /bin/sed '/Filesystem/d' | /bin/awk '{print $4}'` /bin/echo "$local_package kbytes $size, $localdir free kbytes $space" if ($size > $space) then /bin/echo "No space in $localdir for copy" set copy = "no" else /bin/echo "cp -p $installed_package $localdir/$local_package" cp -p $installed_package $localdir/$local_package chmod +w $localdir/$local_package endif endif endif # # Run the package # if ($copy == "yes") then set program = $localdir/$local_package else set program = $installed_package endif /bin/echo "Running $program" if ( $#argv > 0 ) then exec $program ${threads_args} -tmpdir $TMPDIR -- ${pcr_args} -@ $argv[1-] -@ else exec $program ${threads_args} -tmpdir $TMPDIR -- ${pcr_args} endif # eof