install_garsoft_mrb.sh
Go to the documentation of this file.
1 #!/bin/sh
2 
3 # install_garsoft_mrb.sh
4 # Install the ups products needed by novasoft
5 # Created by Brian Rebel on 9/15/16.
6 
7 if [ "$#" -ne 5 ]; then
8  echo "Usage: install_garsoft_mrb.sh <external ups directory> <garsoft base version> <garsoft qualifiers> <buildtype> <garsoft destination directory>"
9  echo " For example: install_garsoft_mrb.sh $HOME/gar/products vXX_YY_ZZ sJJ:eII <debug | prof> $HOME/gar/"
10  #echo " the lastest version of the garsoft bundle can be found at http://scisoft.fnal.gov/scisoft/bundles/garsoft/"
11  echo " use the lastest version of the larsoft bundle to get external products, the bundle can be found at http://scisoft.fnal.gov/scisoft/bundles/larsoft/"
12  echo " If running on Fermilab dunegpvm nodes, set the <external ups directory> to be /cvmfs/fermilab.opensciencegrid.org/products/larsoft"
13  exit
14 fi
15 
16 PRODDIR=${1}
17 BASEV=${2}
18 QUALS=${3}
19 BUILDTYPE=${4}
20 GARDIR=${5}
21 
22 BUNDLEQUALS=`echo ${QUALS} | sed -e 's/:/-/g'`
23 
24 echo "Check inputs: "
25 echo " External UPS destination: ${PRODUCTS}"
26 echo " GArSoft Base version: ${BASEV}"
27 echo " GArSoft Qualifiers: ${QUALS}"
28 echo " Build type: ${BUILDTYPE}"
29 echo " GArSoft destination: ${GARDIR}"
30 
31 # determine the OS
32 OS=`uname`
33 if [ "${OS}" = "Linux" ]
34 then
35  flvr=slf`lsb_release -r | sed -e 's/[[:space:]]//g' | cut -f2 -d":" | cut -f1 -d"."`
36 elif [ "${OS}" = "Darwin" ]
37 then
38  flvr=d`uname -r | cut -f1 -d"."`
39  QUALS="${QUALS}:osx"
40 else
41  echo "ERROR: unrecognized operating system ${OS}"
42  exit 1
43 fi
44 
45 # check the product directory to see if we are wanting to use the gpvm node
46 # product installation or not
47 
48 if [[ ${PRODDIR} != *"fermilab"* ]] ; then
49  cd ${PRODDIR}
50  curl -O http://scisoft.fnal.gov/scisoft/bundles/tools/pullProducts
51  chmod +x pullProducts
52  ./pullProducts ${PRODDIR} ${flvr} garsoft-${BASEV} ${BUNDLEQUALS} ${BUILDTYPE}
53 
54  echo "NB the bundle may not yet be available. If that is the case, try developing on the dunegpvm nodes at FNAL"
55 fi
56 
57 # source the ups products setup
58 source ${PRODDIR}/setup
59 
60 # setup mrb and create the project
61 echo "setting up the mrb working area"
62 
63 if [ ! -d "${GARDIR}" ]; then
64  echo "GArSoft destination directory not found, make it"
65  mkdir ${GARDIR}
66 fi
67 
68 cd ${GARDIR}
69 
70 setup mrb
71 
72 export MRB_PROJECT=garsoft
73 
74 mrb newDev -v develop -q ${QUALS}:${BUILDTYPE}
75 
76 # make the local products directory name a bit more generic
77 BUNDLEQUALS=`echo ${QUALS} | sed -e 's/:/_/g'`
78 
79 mv localProducts_${MRB_PROJECT}_develop_${BUNDLEQUALS}_${BUILDTYPE} localProducts_${MRB_PROJECT}
80 
81 sed -i~ 's/localProducts_'"${MRB_PROJECT}"'_develop_'"${BUNDLEQUALS}_${BUILDTYPE}"'/localProducts_'"${MRB_PROJECT}"'/g' localProducts_${MRB_PROJECT}/setup
82 
83 rm localProducts_${MRB_PROJECT}/*~
84 
85 source localProducts_${MRB_PROJECT}/setup
86 
87 echo "checking out the garsoft code"
88 
89 cd ${MRB_SOURCE}
90 mrb g -d garsoft garsoft-garsoft
91 mrb uc
92 
93 echo "set the build environment"
94 cd ${MRB_BUILDDIR}
95 mrbsetenv
96 
97 echo "If no errors were reported, you are good to go"
98 echo " "
99 echo "Here is an example function you can add to your $HOME/.bash_profile to setup for garsoft development:"
100 echo " "
101 echo "develop_gar ()"
102 echo "{"
103 echo " "
104 echo " source ${PRODDIR}/setup"
105 echo " setup mrb"
106 echo " setup ninja v1_6_0b #optional if using ninja to build the code, requires mrb i --generator ninja"
107 echo " source ${GARDIR}/localProducts_${MRB_PROJECT}/setup"
108 echo " cd ${MRB_BUILDDIR}"
109 echo " mrbsetenv"
110 echo " echo ready to build in ${PWD} "
111 echo "}"
112 
113 echo " "
114 echo "Here is an example function you can add to your $HOME/.bash_profile to setup garsoft for running:"
115 echo " "
116 echo "setup_gar ()"
117 echo "{"
118 echo " "
119 echo " source ${PRODDIR}/setup"
120 echo " export PRODUCTS=/grid/fermiapp/products/common/db:${PRODUCTS}"
121 echo " export PRODUCTS=${GARDIR}/localProducts_${MRB_PROJECT}/:${PRODUCTS}"
122 echo " "
123 echo " # setup sam to be able to find files"
124 echo " #kx509"
125 echo " #kxlist -p"
126 echo " #voms-proxy-init --rfc --voms=fermilab:/fermilab/gar/Role=Analysis --noregen"
127 echo " #export X509_USER_PROXY=/tmp/x509up_u`id -u`"
128 echo " "
129 echo " #setup the garsoft ups product"
130 echo " setup garsoft develop -q ${QUALS}:${BUILDTYPE}"
131 echo " cd ${GARDIR}"
132 echo " "
133 echo " echo ready to run gar in ${GARDIR} "
134 echo "}"
135