grid_setup.sh
Go to the documentation of this file.
1 # this script must be sourced
2 
3 usage()
4 {
5  echo "USAGE: source grid_setup.sh <product_dir>"
6  echo " sets up all ups products found in <product_dir>"
7  echo ""
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."
11  echo ""
12 }
13 
14 get_this_dir()
15 {
16  ( cd / ; /bin/pwd -P ) >/dev/null 2>&1
17  if (( $? == 0 )); then
18  pwd_P_arg="-P"
19  fi
20 echo "bash source $BASH_SOURCE"
21  reldir=`dirname "$BASH_SOURCE"`
22  thisdir=`cd ${reldir} && /bin/pwd ${pwd_P_arg}`
23 }
24 
25 MRB_INSTALL=${1}
26 
27 test $?shell = 1 && set ss=csh || ss=sh
28 echo Shell type is $ss.
29 
30 if [ -z ${MRB_INSTALL} ]
31 then
32  echo "ERROR: please specify the product directory"
33  usage
34  return 1
35 fi
36 
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."
40  return 1
41 fi
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."
45  return 1
46 fi
47 
48 if [ ! -d ${MRB_INSTALL} ]
49 then
50  echo "ERROR: cannot find ${MRB_INSTALL}"
51  usage
52  return 1
53 fi
54 
55 get_this_dir
56 
57 if [ -z ${UPS_DIR} ]
58 then
59  echo "ERROR: please setup ups"
60  return 1
61 fi
62 source `${UPS_DIR}/bin/ups setup ${SETUP_UPS}`
63 
64 localP=$MRB_INSTALL
65 
66 ##echo
67 ##ups active
68 ##echo
69 
70 tmpfl=/tmp/`basename $localP`_setup_$$$$
71 rm -f $tmpfl
72 echo > $tmpfl
73 echo "## checking $localP for products" >> $tmpfl
74 echo "source \`${UPS_DIR}/bin/ups setup ${SETUP_UPS}\`" >> $tmpfl
75 
76 # deal with UPS_OVERRIDE
77 echo "# incoming UPS_OVERRIDE $UPS_OVERRIDE" >> $tmpfl
78 if [ -z "${UPS_OVERRIDE}" ]; then
79  new_override="-B"
80 else
81  tempover=`echo ${UPS_OVERRIDE} | sed -e 's/\-B//'`
82  new_override="-B ${tempover}"
83 fi
84 echo "export UPS_OVERRIDE=\"${new_override}\"" >> $tmpfl
85 
86 ups list -aK+ -z $localP | while read line
87 do
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
98  echo "fi" >> $tmpfl
99  if [ -z $quals ]
100  then
101  cmd="setup -B $product $version"
102  else
103  pq=+`echo ${quals} | sed -e 's/:/:+/g'`
104  cmd="setup -B $product $version -q $pq"
105  fi
106  echo "$cmd -z $localP:${PRODUCTS}" >> $tmpfl
107 done
108 
109 echo "ready to source $tmpfl"
110 source $tmpfl
111 
112 
113 return 0