3 # build uboonecode and ubutil
5 # designed to work on Jenkins
6 # this is a proof of concept script
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"
14 # Don't do ifdh build on macos.
16 #if uname | grep -q Darwin; then
17 # if ! echo $QUAL | grep -q noifdh; then
18 # echo "Ifdh build requested on macos. Quitting."
23 # Get number of cores to use.
25 if [ `uname` = Darwin ]; then
26 #ncores=`sysctl -n hw.ncpu`
27 #ncores=$(( $ncores / 4 ))
30 ncores=`cat /proc/cpuinfo 2>/dev/null | grep -c -e '^processor'`
32 if [ $ncores -lt 1 ]; then
35 echo "Building using $ncores cores."
37 # Environment setup, uses /grid/fermiapp or cvmfs.
39 echo "ls /cvmfs/uboone.opensciencegrid.org"
40 ls /cvmfs/uboone.opensciencegrid.org
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
49 source /cvmfs/uboone.opensciencegrid.org/products/setup_uboone.sh || exit 1
51 echo "No setup file found."
55 # Use system git on macos.
57 if ! uname | grep -q Darwin; then
60 setup gitflow || exit 1
61 # skip around a version of mrb that does not work on macOS
63 if [ `uname` = Darwin ]; then
64 if [[ x`which mrb | grep v1_17_02` != x ]]; then
66 setup mrb v1_16_02 || exit 1
70 export MRB_PROJECT=uboone
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
83 source localProducts*/setup || exit 1
84 echo "PRODUCTS=$PRODUCTS"
86 # some shenanigans so we can use getopt v1_1_6
87 if [ `uname` = Darwin ]; then
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 || \
91 #ERROR: pull of http://scisoft.fnal.gov/scisoft/packages/getopt/v1_1_6/getopt-1.1.6-d13-x86_64.tar.bz2 failed
95 # tar xf getopt-1.1.6-d13-x86_64.tar.bz2 || exit 1
96 setup getopt v1_1_6 || exit 1
101 cd $MRB_SOURCE || exit 1
102 # make sure we get a read-only copy
103 mrb g -r -t $UBOONE uboonecode || exit 1
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
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
118 cd $MRB_BUILDDIR || 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
124 mrb mp -n uboone -- -j$ncores || exit 1
126 # add uboone_photon_propagation to the manifest.
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//'`
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
137 # add uboone_data to the manifest.
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
146 # add uboone_example_data to the manifest.
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
155 # add uboonedaq_datatypes to the manifest
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
167 # add swtrigger to the manifest
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
179 # add larlite to the manifest
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
191 # add larcv to the manifest
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
203 # add larbatch to the manifest.
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
212 # Extract larsoft version from product_deps.
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//'`
220 if uname | grep -q Darwin; then
226 # Construct name of larsoft manifest.
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
234 # Fetch laraoft manifest from scisoft and append to uboonecode manifest.
235 # Filter out larbatch because we already added that.
237 curl --fail --silent --location --insecure http://scisoft.fnal.gov/scisoft/bundles/larsoft/${larsoft_version}/manifest/${larsoft_manifest} | grep -v larbatch >> $manifest || exit 1
239 # Special handling of noifdh builds goes here.
241 if echo $QUAL | grep -q noifdh; then
243 if uname | grep -q Darwin; then
245 # If this is a macos build, then rename the manifest to remove noifdh qualifier in the name
247 noifdh_manifest=`echo $manifest | sed 's/-noifdh//'`
248 mv $manifest $noifdh_manifest
252 # Otherwise (for slf builds), delete the manifest entirely.
261 mv *.bz2 $WORKSPACE/copyBack/ || exit 1
262 manifest=uboone-*_MANIFEST.txt
263 if [ -f $manifest ]; then
264 mv $manifest $WORKSPACE/copyBack/ || exit 1
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