buildUboone.sh
Go to the documentation of this file.
1 #!/bin/bash
2 
3 # build uboonecode and ubutil
4 # use mrb
5 # designed to work on Jenkins
6 # this is a proof of concept script
7 
8 echo "uboonecode version: $UBOONE"
9 echo "base qualifiers: $QUAL"
10 echo "larsoft qualifiers: $LARSOFT_QUAL"
11 echo "build type: $BUILDTYPE"
12 echo "workspace: $WORKSPACE"
13 
14 # Don't do ifdh build on macos.
15 
16 #if uname | grep -q Darwin; then
17 # if ! echo $QUAL | grep -q noifdh; then
18 # echo "Ifdh build requested on macos. Quitting."
19 # exit
20 # fi
21 #fi
22 
23 # Get number of cores to use.
24 
25 if [ `uname` = Darwin ]; then
26  #ncores=`sysctl -n hw.ncpu`
27  #ncores=$(( $ncores / 4 ))
28  ncores=1
29 else
30  ncores=`cat /proc/cpuinfo 2>/dev/null | grep -c -e '^processor'`
31 fi
32 if [ $ncores -lt 1 ]; then
33  ncores=1
34 fi
35 echo "Building using $ncores cores."
36 
37 # Environment setup, uses /grid/fermiapp or cvmfs.
38 
39 echo "ls /cvmfs/uboone.opensciencegrid.org"
40 ls /cvmfs/uboone.opensciencegrid.org
41 echo
42 
43 if [ `uname` = Darwin -a -f /grid/fermiapp/products/uboone/setup_uboone_bluearc.sh ]; then
44  source /grid/fermiapp/products/uboone/setup_uboone_bluearc.sh || exit 1
45 elif [ -f /cvmfs/uboone.opensciencegrid.org/products/setup_uboone.sh ]; then
46  if [ -x /cvmfs/grid.cern.ch/util/cvmfs-uptodate ]; then
47  /cvmfs/grid.cern.ch/util/cvmfs-uptodate /cvmfs/uboone.opensciencegrid.org/products
48  fi
49  source /cvmfs/uboone.opensciencegrid.org/products/setup_uboone.sh || exit 1
50 else
51  echo "No setup file found."
52  exit 1
53 fi
54 
55 # Use system git on macos.
56 
57 if ! uname | grep -q Darwin; then
58  setup git || exit 1
59 fi
60 setup gitflow || exit 1
61 # skip around a version of mrb that does not work on macOS
62 
63 if [ `uname` = Darwin ]; then
64  if [[ x`which mrb | grep v1_17_02` != x ]]; then
65  unsetup mrb || exit 1
66  setup mrb v1_16_02 || exit 1
67  fi
68 fi
69 
70 export MRB_PROJECT=uboone
71 echo "Mrb path:"
72 which mrb
73 
74 set -x
75 rm -rf $WORKSPACE/temp || exit 1
76 mkdir -p $WORKSPACE/temp || exit 1
77 mkdir -p $WORKSPACE/copyBack || exit 1
78 rm -f $WORKSPACE/copyBack/* || exit 1
79 cd $WORKSPACE/temp || exit 1
80 mrb newDev -v $UBOONE -q $QUAL:$BUILDTYPE || exit 1
81 
82 set +x
83 source localProducts*/setup || exit 1
84 echo "PRODUCTS=$PRODUCTS"
85 
86 # some shenanigans so we can use getopt v1_1_6
87 if [ `uname` = Darwin ]; then
88 # cd $MRB_INSTALL
89 # curl --fail --silent --location --insecure -O http://scisoft.fnal.gov/scisoft/packages/getopt/v1_1_6/getopt-1.1.6-d13-x86_64.tar.bz2 || \
90 # { cat 1>&2 <<EOF
91 #ERROR: pull of http://scisoft.fnal.gov/scisoft/packages/getopt/v1_1_6/getopt-1.1.6-d13-x86_64.tar.bz2 failed
92 #EOF
93 # exit 1
94 # }
95 # tar xf getopt-1.1.6-d13-x86_64.tar.bz2 || exit 1
96  setup getopt v1_1_6 || exit 1
97 # which getopt
98 fi
99 
100 #set -x
101 cd $MRB_SOURCE || exit 1
102 # make sure we get a read-only copy
103 mrb g -r -t $UBOONE uboonecode || exit 1
104 
105 # Extract ubutil version from uboonecode product_deps
106 ubutil_version=`grep ubutil $MRB_SOURCE/uboonecode/ups/product_deps | grep -v qualifier | awk '{print $2}'`
107 echo "ubuitil version: $ubutil_version"
108 mrb g -r -t $ubutil_version ubutil || exit 1
109 
110 # Extract uboonedata version from uboonecode product_deps (if any).
111 uboonedata_version=`grep uboonedata $MRB_SOURCE/uboonecode/ups/product_deps | grep -v qualifier | awk '{print $2}'`
112 echo "uboonedata version: $uboonedata_version"
113 if [ x$uboonedata_version != x ]; then
114  mrb g -r -t $uboonedata_version uboonedata || exit 1
115 fi
116 
117 
118 cd $MRB_BUILDDIR || exit 1
119 mrbsetenv || exit 1
120 mrb b -j$ncores || exit 1
121 if uname | grep -q Linux; then
122  cp /usr/lib64/libXmu.so.6 uboonecode/lib
123 fi
124 mrb mp -n uboone -- -j$ncores || exit 1
125 
126 # add uboone_photon_propagation to the manifest.
127 
128 manifest=uboone-*_MANIFEST.txt
129 if [ x$uboonedata_version != x ]; then
130  uboone_photon_propagation_version=`grep uboone_photon_propagation $MRB_SOURCE/uboonedata/ups/product_deps | grep -v qualifier | awk '{print $2}'`
131  uboone_photon_propagation_dot_version=`echo ${uboone_photon_propagation_version} | sed -e 's/_/./g' | sed -e 's/^v//'`
132 fi
133 if [ x$uboone_photon_propagation_version != x ]; then
134  echo "uboone_photon_propagation ${uboone_photon_propagation_version} uboone_photon_propagation-${uboone_photon_propagation_dot_version}-noarch.tar.bz2" >> $manifest
135 fi
136 
137 # add uboone_data to the manifest.
138 
139 manifest=uboone-*_MANIFEST.txt
140 uboone_data_version=`grep uboone_data $MRB_SOURCE/uboonecode/ups/product_deps | grep -v qualifier | awk '{print $2}'`
141 uboone_data_dot_version=`echo ${uboone_data_version} | sed -e 's/_/./g' | sed -e 's/^v//'`
142 if [ x$uboone_data_version != x ]; then
143  echo "uboone_data ${uboone_data_version} uboone_data-${uboone_data_dot_version}-noarch.tar.bz2" >> $manifest
144 fi
145 
146 # add uboone_example_data to the manifest.
147 
148 manifest=uboone-*_MANIFEST.txt
149 uboone_example_data_version=`grep ^uboone_example_data $MRB_SOURCE/uboonecode/ups/product_deps | grep -v qualifier | awk '{print $2}'`
150 uboone_example_data_dot_version=`echo ${uboone_example_data_version} | sed -e 's/_/./g' | sed -e 's/^v//'`
151 if [ x$uboone_example_data_version != x ]; then
152  echo "uboone_example_data ${uboone_example_data_version} uboone_example_data-${uboone_example_data_dot_version}-noarch.tar.bz2" >> $manifest
153 fi
154 
155 # add uboonedaq_datatypes to the manifest
156 
157 manifest=uboone-*_MANIFEST.txt
158 uboonedaq_datatypes_version=`grep uboonedaq_datatypes $MRB_SOURCE/uboonecode/ups/product_deps | grep -v qualifier | awk '{print $2}'`
159 uboonedaq_datatypes_dot_version=`echo ${uboonedaq_datatypes_version} | sed -e 's/_/./g' | sed -e 's/^v//'`
160 os=`get-directory-name os`
161 plat=`get-directory-name platform`
162 qual=`echo $QUAL | sed 's/:*noifdh:*//'`
163 if [ x$uboonedaq_datatypes_version != x ]; then
164  echo "uboonedaq_datatypes ${uboonedaq_datatypes_version} uboonedaq_datatypes-${uboonedaq_datatypes_dot_version}-${os}-${plat}-${qual}-${BUILDTYPE}.tar.bz2" >> $manifest
165 fi
166 
167 # add swtrigger to the manifest
168 
169 manifest=uboone-*_MANIFEST.txt
170 swtrigger_version=`grep swtrigger $MRB_SOURCE/uboonecode/ups/product_deps | grep -v qualifier | awk '{print $2}'`
171 swtrigger_dot_version=`echo ${swtrigger_version} | sed -e 's/_/./g' | sed -e 's/^v//'`
172 os=`get-directory-name os`
173 plat=`get-directory-name platform`
174 qual=`echo $QUAL | sed 's/:*noifdh:*//'`
175 if [ x$swtrigger_version != x ]; then
176  echo "swtrigger ${swtrigger_version} swtrigger-${swtrigger_dot_version}-${os}-${plat}-${qual}-${BUILDTYPE}.tar.bz2" >> $manifest
177 fi
178 
179 # add larlite to the manifest
180 
181 manifest=uboone-*_MANIFEST.txt
182 larlite_version=`grep larlite $MRB_SOURCE/uboonecode/ups/product_deps | grep -v qualifier | awk '{print $2}'`
183 larlite_dot_version=`echo ${larlite_version} | sed -e 's/_/./g' | sed -e 's/^v//'`
184 os=`get-directory-name os`
185 plat=`get-directory-name platform`
186 qual=`echo $QUAL | sed 's/:*noifdh:*//'`
187 if [ x$larlite_version != x ]; then
188  echo "larlite ${larlite_version} larlite-${larlite_dot_version}-${os}-${plat}-${qual}-${BUILDTYPE}.tar.bz2" >> $manifest
189 fi
190 
191 # add larcv to the manifest
192 
193 manifest=uboone-*_MANIFEST.txt
194 larcv_version=`grep larcv $MRB_SOURCE/uboonecode/ups/product_deps | grep -v qualifier | awk '{print $2}'`
195 larcv_dot_version=`echo ${larcv_version} | sed -e 's/_/./g' | sed -e 's/^v//'`
196 os=`get-directory-name os`
197 plat=`get-directory-name platform`
198 qual=`echo $QUAL | sed 's/:*noifdh:*//'`
199 if [ x$larcv_version != x ]; then
200  echo "larcv ${larcv_version} larcv-${larcv_dot_version}-${os}-${plat}-${qual}-${BUILDTYPE}.tar.bz2" >> $manifest
201 fi
202 
203 # add larbatch to the manifest.
204 
205 manifest=uboone-*_MANIFEST.txt
206 larbatch_version=`grep larbatch $MRB_SOURCE/ubutil/ups/product_deps | grep -v qualifier | awk '{print $2}'`
207 larbatch_dot_version=`echo ${larbatch_version} | sed -e 's/_/./g' | sed -e 's/^v//'`
208 if [ x$larbatch_version != x ]; then
209  echo "larbatch ${larbatch_version} larbatch-${larbatch_dot_version}-noarch.tar.bz2" >> $manifest
210 fi
211 
212 # Extract larsoft version from product_deps.
213 
214 larsoft_version=`grep larsoft $MRB_SOURCE/uboonecode/ups/product_deps | grep -v qualifier | awk '{print $2}'`
215 larsoft_dot_version=`echo ${larsoft_version} | sed -e 's/_/./g' | sed -e 's/^v//'`
216 
217 # Extract flavor.
218 
219 flvr=''
220 if uname | grep -q Darwin; then
221  flvr=`ups flavor -2`
222 else
223  flvr=`ups flavor -4`
224 fi
225 
226 # Construct name of larsoft manifest.
227 
228 larsoft_hyphen_qual=`echo $LARSOFT_QUAL | tr : - | sed 's/-noifdh//'`
229 larsoft_manifest=larsoft-${larsoft_dot_version}-${flvr}-${larsoft_hyphen_qual}-${BUILDTYPE}_MANIFEST.txt
230 echo "Larsoft manifest:"
231 echo $larsoft_manifest
232 echo
233 
234 # Fetch laraoft manifest from scisoft and append to uboonecode manifest.
235 # Filter out larbatch because we already added that.
236 
237 curl --fail --silent --location --insecure http://scisoft.fnal.gov/scisoft/bundles/larsoft/${larsoft_version}/manifest/${larsoft_manifest} | grep -v larbatch >> $manifest || exit 1
238 
239 # Special handling of noifdh builds goes here.
240 
241 if echo $QUAL | grep -q noifdh; then
242 
243  if uname | grep -q Darwin; then
244 
245  # If this is a macos build, then rename the manifest to remove noifdh qualifier in the name
246 
247  noifdh_manifest=`echo $manifest | sed 's/-noifdh//'`
248  mv $manifest $noifdh_manifest
249 
250  else
251 
252  # Otherwise (for slf builds), delete the manifest entirely.
253 
254  rm -f $manifest
255 
256  fi
257 fi
258 
259 # Save artifacts.
260 
261 mv *.bz2 $WORKSPACE/copyBack/ || exit 1
262 manifest=uboone-*_MANIFEST.txt
263 if [ -f $manifest ]; then
264  mv $manifest $WORKSPACE/copyBack/ || exit 1
265 fi
266 cp $MRB_BUILDDIR/uboonecode/releaseDB/*.html $WORKSPACE/copyBack/
267 ls -l $WORKSPACE/copyBack/
268 cd $WORKSPACE || exit 1
269 rm -rf $WORKSPACE/temp || exit 1
270 set +x
271 
272 exit 0