All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
build-larsoft-with-spack.sh
Go to the documentation of this file.
1 #!/bin/bash
2 
3 # pull source code in ${working_dir}/source
4 # build in ${working_dir}/build
5 # copyback directory is ${working_dir}/copyBack
6 
8 {
9  cat 1>&2 <<EOF
10 Usage: $(basename ${0}) [-h]
11  env WORKSPACE=<workspace> LARVER=<larsoft version> QUAL=<qualifier> BUILDTYPE=<debug|prof> $(basename ${0})
12 
13 Options:
14 
15  -h This help.
16 
17 EOF
18 }
19 
21  for label in "${labels[@]}"; do
22  for wanted in "$@"; do
23  [[ "${label}" == "${wanted}" ]] && return 0
24  done
25  done
26  return 1
27 }
28 
29 
30 while getopts :h OPT; do
31  case ${OPT} in
32  h)
33  usage
34  exit 1
35  ;;
36  *)
37  usage
38  exit 1
39  esac
40 done
41 shift `expr $OPTIND - 1`
43 
44 working_dir="${WORKSPACE:-$(pwd)}"
45 version="${1:-${LARVER}}"
46 qual_set="${2:-${QUAL}}"
47 oIFS=${IFS}; IFS=:; quals=(${qual_set//-/:}); IFS=$oIFS; unset oIFS
48 build_type="${3:-${BUILDTYPE}}"
49 
50 labels=()
51 for onequal in "${quals[@]}"; do
52  if [[ "${onequal}" =~ ^([ec])([0-9]+)$ ]]; then
53  basequal=${onequal}
54  elif [[ "${onequal}" =~ ^(s)([1-9][0-9]+)$ ]]; then
55  squal=${onequal}
56  else
57  labels+=${onequal}
58  fi
59 done
60 
61 echo "basequal ${basequal} squal ${squal} labels ${labels}"
62 
63 case ${build_type} in
64  debug) ;;
65  prof) ;;
66  *)
67  usage
68  exit 1
69 esac
70 
71 # create copyBack so artifact copy does not fail on early exit
72 rm -rf "${working_dir}/copyBack"
73 mkdir -p "${working_dir}/copyBack" || exit 1
74 
75 # Find platform flavor.
76 OS=`uname`
77 if [ "${OS}" = "Linux" ]
78 then
79  id=`lsb_release -is`
80  if [ "${id}" = "Ubuntu" ]
81  then
82  flvr=u`lsb_release -r | sed -e 's/[[:space:]]//g' | cut -f2 -d":" | cut -f1 -d"."`
83  else
84  flvr=slf`lsb_release -r | sed -e 's/[[:space:]]//g' | cut -f2 -d":" | cut -f1 -d"."`
85  fi
86 elif [ "${OS}" = "Darwin" ]
87 then
88  flvr=d`uname -r | cut -f1 -d"."`
89  # set locale
90  echo
91  locale
92  echo
93  export LANG=C
94  export LC_ALL=$LANG
95  locale
96  echo
97 else
98  echo "ERROR: unrecognized operating system ${OS}"
99  exit 1
100 fi
101 
102 # Check supported builds.
103 if [[ `uname -s` == Darwin ]]; then
104  OSnum=`uname -r | cut -f1 -d"."`
105  xver=`xcodebuild -version | grep Xcode | cut -f2 -d" " | cut -f1 -d"."`
106  xcver=`xcodebuild -version | grep Xcode`
107  if { [[ ${basequal} =~ ^e(9$|[1-9][0-9]) ]] && \
108  [[ ${xver} < 7 ]] && \
109  [[ ${OSnum} > 13 ]]; }; then
110  # XCode too old on this platform.
111  echo "${basequal} build not supported on `uname -s`${OSnum} with ${xcver}"
112  echo "${basequal} build not supported on `uname -s`${OSnum} with ${xcver}" > \
113  "${working_dir}/copyBack/skipping_build"
114  exit 0
115  elif { [[ "$basequal" == e* ]] || \
116  { [[ "$basequal" == c* ]] && (( $OSnum < 15 )); }; }; then
117  if want_unsupported; then
118  echo "Building unsupported ${basequal} on `uname -s`${OSnum} due to \$CET_BUILD_UNSUPPORTED=${CET_BUILD_UNSUPPORTED}"
119  else
120  # Don't normally support GCC builds on MacOS.
121  msg="${basequal} build not supported on `uname -s`${OSnum} -- export CET_BUILD_UNSUPPORTED=1 to override."
122  echo "$msg"
123  echo "$msg" > "${working_dir}/copyBack/skipping_build"
124  exit 0
125  fi
126  fi
127  if have_label py2; then
128  msg="We are not building for Python2 on Darwin."
129  echo "${msg}"
130  echo "${msg}" > "${working_dir}/copyBack/skipping_build"
131  exit 0
132  fi
133 elif [[ "${flvr}" == slf6 ]]; then
134  if have_label py2; then
135  echo "Building for supported Python2 on SLF6"
136  else
137  if [[ "$basequal" != e17 ]] && [[ "$basequal" != c2 ]]; then
138  msg="Python3 builds not supported on SLF6."
139  echo "${msg}"
140  echo "${msg}" > "${working_dir}/copyBack/skipping_build"
141  exit 0
142  fi
143  fi
144 fi
145 
146 dotver=`echo ${version} | sed -e 's/_/./g' | sed -e 's/^v//'`
147 
148 echo "building the larsoft distribution for ${version} ${dotver} ${qual_set} ${build_type}"
149 echo "build flavor is ${flvr}"
150 echo ""
151 
152 qualdir=`echo ${qual_set} | sed -e 's%:%-%'`
153 
154 set -x
155 
156 blddir=${working_dir}/build
157 srcdir=${working_dir}/source
158 # start with clean directories
159 rm -rf ${blddir}
160 rm -rf ${srcdir}
161 # now make the dfirectories
162 mkdir -p ${srcdir} || exit 1
163 mkdir -p ${blddir} || exit 1
164 mkdir -p ${blddir}/packages || exit 1
165 
166 buildFW="${working_dir}/artutilscripts/tools/buildFW"
167 tensorflow_spack_install="${working_dir}/artutilscripts/tools/tensorflow_spack_install.sh"
168 
169 cd ${blddir} || exit 1
170 
171 if [ -z "${buildFW}" ]; then
172  curl --fail --silent --location --insecure -O http://scisoft.fnal.gov/scisoft/bundles/tools/buildFW || exit 1
173  chmod +x buildFW
174  buildFW="${blddir}/buildFW"
175 fi
176 
177 cd ${blddir} || exit 1
178 echo
179 echo "begin build"
180 echo
181 if [ -d ${blddir}/packages/spack ]; then
182  echo "spack packages already exist"
183 else
184  "${tensorflow_spack_install}" packages
185 fi
186 export PRODUCTS=${blddir}:${blddir}/packages
187 (( ${#labels[@]} > 0 )) && lopt=-l
188 ${buildFW} -t -b ${basequal} \
189  ${lopt} $(IFS=:; printf '%s' "${labels[*]}") \
190  ${blddir} ${build_type} lar_product_stack-${version} || \
191  { mv ${blddir}/*.log "${working_dir}/copyBack/"
192  exit 1
193  }
194 ${buildFW} -t -b ${basequal} -s ${squal} \
195  ${lopt} $(IFS=:; printf '%s' "${labels[*]}") \
196  ${blddir} ${build_type} larbase-${version} || \
197  { mv ${blddir}/*.log "${working_dir}/copyBack/"
198  exit 1
199  }
200 ${buildFW} -t -b ${basequal} -s ${squal} \
201  ${lopt} $(IFS=:; printf '%s' "${labels[*]}") \
202  ${blddir} ${build_type} larsoft-${version} || \
203  { mv ${blddir}/*.log "${working_dir}/copyBack/"
204  exit 1
205  }
206 # larsoftobj
207 objver=`ls larsoftobj-cfg* | cut -f3 -d"-" | sed -e 's/\./_/g'`
208 ${buildFW} -t -b ${basequal} \
209  ${lopt} $(IFS=:; printf '%s' "${labels[*]}") \
210  ${blddir} ${build_type} larsoftobj-${objver} || \
211  { mv ${blddir}/*.log "${working_dir}/copyBack/"
212  exit 1
213  }
214 # larwire
215 wirever=`grep larwirecell larsoft-cfg-${dotver} | cut -f5 -d" "`
216 wiredotver=`echo ${wirever} | sed -e 's/_/./g' | sed -e 's/^v//'`
217 have_wirecfg="yes"
218 cfgfile=http://scisoft.fnal.gov/scisoft/bundles/larwire/${wirever}/buildcfg/larwire-cfg-${wiredotver}
219 echo "looking for ${cfgfile}"
220 curl --fail --silent --location --insecure -O ${cfgfile} || have_wirecfg="no"
221 echo "have_wirecfg is ${have_wirecfg}"
222 if [[ ${have_wirecfg} == "yes" ]]; then
223  echo "building larwire ${wirever}"
224  ${buildFW} -t -b ${basequal} -s ${squal} \
225  ${lopt} $(IFS=:; printf '%s' "${labels[*]}") \
226  ${blddir} ${build_type} larwire-${wirever} || \
227  { mv ${blddir}/*.log "${working_dir}/copyBack/"
228  exit 1
229  }
230 else
231  echo "skipping larwire build"
232 fi
233 
234 echo
235 echo "move files"
236 echo
237 # get these out of the way
238 mv ${blddir}/*source* ${srcdir}/
239 mv ${blddir}/g*noarch* ${srcdir}/
240 mv ${blddir}/larsoft_data*.bz2 ${srcdir}/
241 #
242 mv ${blddir}/*.bz2 "${working_dir}/copyBack/"
243 mv ${blddir}/*.txt "${working_dir}/copyBack/"
244 rm -rf ${srcdir}
245 rm -rf ${blddir}
246 
247 exit 0
process_name opflash particleana ie ie ie z
* labels
*usage exit esac done shift expr $OPTIND OPTIND
process_name opflash particleana ie x
then cvmfs grid cern ch util cvmfs uptodate cvmfs uboone opensciencegrid org products fi source cvmfs uboone opensciencegrid org products setup_uboone sh exit else echo No setup file found exit fi if!uname grep q Darwin
Definition: build_larcv.sh:51
do source
pdgs p
Definition: selectors.fcl:22
then source cvmfs dune opensciencegrid org products dune setup_dune sh exit elif[-f/grid/fermiapp/products/dune/setup_dune_fermiapp.sh]
have_label()
shift
Definition: fcl_checks.sh:26
usage
Definition: doGit.sh:21
then flvr
Definition: buildSBND.sh:128
while getopts
while getopts h
then shift fi
do cd
then basequal
Definition: buildUboone2.sh:26
do case in h help echo Usage
Definition: file_to_url.sh:42
then QUAL
if &&[-z"$BASH_VERSION"] then echo Attempting to switch to bash bash shellSwitch exit fi &&["$1"= 'shellSwitch'] shift declare a IncludeDirectives for Dir in
then echo File list $list not found else cat $list while read file do echo $file sed s
Definition: file_to_url.sh:60
do i e
T copy(T const &v)
s7[0-9] s8[0-9] s9[0-9] squal
esac echo uname r