1 # this script must be sourced
5 echo "USAGE: source grid_setup.sh <product_dir>"
6 echo " sets up all ups products found in <product_dir>"
8 echo " This script is designed to be used when copying a localProducts directory"
9 echo " to the grid for testing."
10 echo " DO NOT setup mrb when using this script."
16 ( cd / ; /bin/pwd -P ) >/dev/null 2>&1
17 if (( $? == 0 )); then
20 echo "bash source $BASH_SOURCE"
21 reldir=`dirname "$BASH_SOURCE"`
22 thisdir=`cd ${reldir} && /bin/pwd ${pwd_P_arg}`
27 test $?shell = 1 && set ss=csh || ss=sh
28 echo Shell type is $ss.
30 if [ -z ${MRB_INSTALL} ]
32 echo "ERROR: please specify the product directory"
37 if [ -n "${MRB_BUILDDIR}" ]; then
38 echo "ERROR: the mrb development environment is enabled."
39 echo "ERROR: please run this script in a clean environment."
42 if [ -n "${MRB_SOURCE}" ]; then
43 echo "ERROR: the mrb development environment is enabled."
44 echo "ERROR: please run this script in a clean environment."
48 if [ ! -d ${MRB_INSTALL} ]
50 echo "ERROR: cannot find ${MRB_INSTALL}"
59 echo "ERROR: please setup ups"
62 source `${UPS_DIR}/bin/ups setup ${SETUP_UPS}`
70 tmpfl=/tmp/`basename $localP`_setup_$$$$
73 echo "## checking $localP for products" >> $tmpfl
74 echo "source \`${UPS_DIR}/bin/ups setup ${SETUP_UPS}\`" >> $tmpfl
76 # deal with UPS_OVERRIDE
77 echo "# incoming UPS_OVERRIDE $UPS_OVERRIDE" >> $tmpfl
78 if [ -z "${UPS_OVERRIDE}" ]; then
81 tempover=`echo ${UPS_OVERRIDE} | sed -e 's/\-B//'`
82 new_override="-B ${tempover}"
84 echo "export UPS_OVERRIDE=\"${new_override}\"" >> $tmpfl
86 ups list -aK+ -z $localP | while read line
88 ##echo "got line: $line"
89 words=($(echo $line | tr " " "\n"))
90 ##echo "split into ${#words[@]} pieces"
91 product=$(echo ${words[0]} | tr "\"" " ")
92 version=$(echo ${words[1]} | tr "\"" " ")
93 quals=$(echo ${words[3]} | tr "\"" " ")
94 product_uc=$(echo ${product} | tr '[a-z]' '[A-z]')
95 echo "product_setup=\$(printenv | grep SETUP_${product_uc} | wc -l)" >> $tmpfl
96 echo "if [[ \"\${product_setup}\" > 0 ]]; then" >> $tmpfl
97 echo "unsetup -j $product" >> $tmpfl
101 cmd="setup -B $product $version"
103 pq=+`echo ${quals} | sed -e 's/:/:+/g'`
104 cmd="setup -B $product $version -q $pq"
106 echo "$cmd -z $localP:${PRODUCTS}" >> $tmpfl
109 echo "ready to source $tmpfl"