5 # designed to work on Jenkins
7 echo "dunetpc version: $DUNE"
8 echo "base qualifiers: $QUAL"
9 QUAL=`echo ${QUAL} | sed -e "s/-/:/g"`
10 echo "modified base qualifiers: $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. Just use cvmfs. larsoft builds are not supported on /grid/fermiapp anymore
39 echo "ls /cvmfs/dune.opensciencegrid.org/products/dune/"
40 ls /cvmfs/dune.opensciencegrid.org/products/dune/
43 if [ `uname` = Darwin -a -f /grid/fermiapp/products/dune/setup_dune_fermiapp.sh ]; then
44 source /grid/fermiapp/products/dune/setup_dune_fermiapp.sh || exit 1
45 elif [ -f /cvmfs/dune.opensciencegrid.org/products/dune/setup_dune.sh ]; then
46 if [ -x /cvmfs/grid.cern.ch/util/cvmfs-uptodate ]; then
47 /cvmfs/grid.cern.ch/util/cvmfs-uptodate /cvmfs/dune.opensciencegrid.org/products
49 source /cvmfs/dune.opensciencegrid.org/products/dune/setup_dune.sh || exit 1
51 echo "No setup file found."
55 # Use git out of ups except use the system git on macos
57 if ! uname | grep -q Darwin; then
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 setup gitflow || exit 1
71 export MRB_PROJECT=dune
75 # make the timeouts longer and accept low-speed transfers
77 export GIT_HTTP_LOW_SPEED_LIMIT=1000
78 export GIT_HTTP_LOW_SPEED_TIME=600
81 rm -rf $WORKSPACE/temp || exit 1
82 mkdir -p $WORKSPACE/temp || exit 1
83 mkdir -p $WORKSPACE/copyBack || exit 1
84 rm -f $WORKSPACE/copyBack/* || exit 1
85 cd $WORKSPACE/temp || exit 1
86 mrb newDev -v $DUNE -q $QUAL:$BUILDTYPE || exit 1
89 source localProducts*/setup || exit 1
91 # some shenanigans so we can use getopt v1_1_6
92 if [ `uname` = Darwin ]; then
94 # 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 || \
96 #ERROR: pull of http://scisoft.fnal.gov/scisoft/packages/getopt/v1_1_6/getopt-1.1.6-d13-x86_64.tar.bz2 failed
100 # tar xf getopt-1.1.6-d13-x86_64.tar.bz2 || exit 1
101 setup getopt v1_1_6 || exit 1
106 cd $MRB_SOURCE || exit 1
107 # make sure we get a read-only copy
108 # put some retry logic here instead
112 until [ $ntries -ge $maxtries ]
115 mrb g -r -t $DUNE dunetpc && break
119 if [ $ntries = $maxtries ]; then
120 echo "Could not clone dunetpc using mrb g. Quitting."
124 ## Extract duneutil version from dunetpc product_deps
125 #duneutil_version=`grep duneutil $MRB_SOURCE/dunetpc/ups/product_deps | grep -v qualifier | awk '{print $2}'`
126 #echo "duneutil version: $duneutil_version"
127 #mrb g -r -t $duneutil_version duneutil || exit 1
130 cd $MRB_BUILDDIR || exit 1
132 mrb b -j$ncores || exit 1
133 mrb mp -n dune -- -j$ncores || exit 1
139 if uname | grep -q Darwin; then
146 manifest=`ls dune-*_MANIFEST.txt`
148 # add flavor and qualifier to the dunetpc line
150 dtline=`grep dunetpc $manifest`
151 dtmodline="${dtline} -f ${flvr} -q ${QUAL}:${BUILDTYPE}"
153 echo $dtmodline > ${manifest}
155 # add dune_pardata to the manifest
157 dune_pardata_version=`grep dune_pardata $MRB_SOURCE/dunetpc/ups/product_deps | grep -v qualifier | awk '{print $2}'`
158 dune_pardata_dot_version=`echo ${dune_pardata_version} | sed -e 's/_/./g' | sed -e 's/^v//'`
159 echo "dune_pardata ${dune_pardata_version} dune_pardata-${dune_pardata_dot_version}-noarch.tar.bz2 -f NULL" >> $manifest
165 PLATFORM=$(uname -r | grep -o "el[0-9]"|sed s'/el/slf/')
168 PLATFORM=$(uname -r | awk -F. '{print "d"$1}')
172 cd $MRB_SOURCE || exit 1
174 # find our set qualifier from artdaq_core's qualifier
176 SQUAL=`ups active | grep artdaq_core | tr : '\n' | grep ^s | awk '{print $1}'`
177 echo "Set qualifier from artdaq_core: $SQUAL"
179 DQTMP=${QUAL}-${SQUAL}
180 DASHQUAL=`echo ${DQTMP} | sed -e "s/:/-/g" | sed -e "s/-/-nu-/"`
181 DASHQUAL2=`echo ${QUAL} | sed -e "s/:/-/g"`
183 fci=`expr index "$QUAL" :`
186 if [[ $fci != 0 ]]; then
187 COMPILER=${QUAL:0:$fct}
189 echo "Compiler is: $COMPILER"
193 # add dune_raw_data to the manifest
195 dune_raw_data_version=`ups active | grep dune_raw_data | awk '{print $2}'`
196 echo "dune_raw_data version: $dune_raw_data_version"
197 dune_raw_data_flavor=`ups active | grep dune_raw_data | awk '{print $4}'`
198 echo "dune_raw_data flavor: $dune_raw_data_flavor"
199 dune_raw_data_quals=`ups active | grep dune_raw_data | awk '{print $6}'`
200 echo "dune_raw_data quals: $dune_raw_data_quals"
201 dune_raw_data_dot_version=`echo ${dune_raw_data_version} | sed -e 's/_/./g' | sed -e 's/^v//'`
202 echo "dune_raw_data ${dune_raw_data_version} dune_raw_data-${dune_raw_data_dot_version}-${PLATFORM}-x86_64-${DASHQUAL}-${BUILDTYPE}.tar.bz2 -f ${dune_raw_data_flavor} -q ${dune_raw_data_quals}" >> $manifest
205 # add dunepdsprce to the manifest
207 dunepdsprce_version=`ups active | grep dunepdsprce | awk '{print $2}'`
208 echo "dunepdsprce version: $dunepdsprce_version"
209 dunepdsprce_flavor=`ups active | grep dunepdsprce | awk '{print $4}'`
210 echo "dunepdsprce flavor: $dunepdsprce_flavor"
211 dunepdsprce_quals=`ups active | grep dunepdsprce | awk '{print $6}'`
212 echo "dunepdsprce quals: $dunepdsprce_quals"
213 dunepdsprce_dot_version=`echo ${dunepdsprce_version} | sed -e 's/_/./g' | sed -e 's/^v//'`
214 echo "dunepdsprce ${dunepdsprce_version} dunepdsprce-${dunepdsprce_dot_version}-${PLATFORM}-x86_64-${COMPILER}-gen-${BUILDTYPE}.tar.bz2 -f ${dunepdsprce_flavor} -q ${dunepdsprce_quals}" >> $manifest
216 # add dune_oslibs to the manifest
218 dune_oslibs_version=`ups active | grep dune_oslibs | awk '{print $2}'`
219 echo "dune_oslibs version: $dune_oslibs_version"
220 dune_oslibs_flavor=`ups active | grep dune_oslibs | awk '{print $4}'`
221 echo "dune_oslibs flavor: $dune_oslibs_flavor"
222 dune_oslibs_dot_version=`echo ${dune_oslibs_version} | sed -e 's/_/./g' | sed -e 's/^v//'`
223 echo "dune_oslibs ${dune_oslibs_version} dune_oslibs-${dune_oslibs_dot_version}-${PLATFORM}-x86_64.tar.bz2 -f ${dune_oslibs_flavor}" >> $manifest
225 # add dunedetdataformats to the manifest
227 dunedetdataformats_version=`ups active | grep dunedetdataformats | awk '{print $2}'`
228 echo "dunedetdataformats version: $dunedetdataformats_version"
229 dunedetdataformats_flavor=`ups active | grep dunedetdataformats | awk '{print $4}'`
230 echo "dunedetdataformats flavor: $dunedetdataformats_flavor"
231 dunedetdataformats_dot_version=`echo ${dunedetdataformats_version} | sed -e 's/_/./g' | sed -e 's/^v//'`
232 echo "dunedetdataformats ${dunedetdataformats_version} dunedetdataformats-${dunedetdataformats_dot_version}-noarch.tar.bz2 -f ${dunedetdataformats_flavor}" >> $manifest
234 # add dunedaqdataformats to the manifest
236 dunedaqdataformats_version=`ups active | grep dunedaqdataformats | awk '{print $2}'`
237 echo "dunedaqdataformats version: $dunedaqdataformats_version"
238 dunedaqdataformats_flavor=`ups active | grep dunedaqdataformats | awk '{print $4}'`
239 echo "dunedaqdataformats flavor: $dunedaqdataformats_flavor"
240 dunedaqdataformats_dot_version=`echo ${dunedaqdataformats_version} | sed -e 's/_/./g' | sed -e 's/^v//'`
241 echo "dunedaqdataformats ${dunedaqdataformats_version} dunedaqdataformats-${dunedaqdataformats_dot_version}-noarch.tar.bz2 -f ${dunedaqdataformats_flavor}" >> $manifest
244 # Extract larsoft version from product_deps.
246 larsoft_version=`grep larsoft $MRB_SOURCE/dunetpc/ups/product_deps | grep -v qualifier | awk '{print $2}'`
247 larsoft_dot_version=`echo ${larsoft_version} | sed -e 's/_/./g' | sed -e 's/^v//'`
249 # Construct name of larsoft manifest.
251 larsoft_manifest=larsoft-${larsoft_dot_version}-${flvr}-${SQUAL}-${DASHQUAL2}-${BUILDTYPE}_MANIFEST.txt
252 echo "Larsoft manifest:"
253 echo $larsoft_manifest
256 # Fetch laraoft manifest from scisoft and append to dunetpc manifest.
258 echo "curl --fail --silent --location --insecure http://scisoft.fnal.gov/scisoft/bundles/larsoft/${larsoft_version}/manifest/${larsoft_manifest} >> $manifest || exit 1"
260 curl --fail --silent --location --insecure http://scisoft.fnal.gov/scisoft/bundles/larsoft/${larsoft_version}/manifest/${larsoft_manifest} >> $manifest || exit 1
262 echo "Done with the curl command."
264 # Special handling of noifdh builds goes here.
266 if echo $QUAL | grep -q noifdh; then
268 if uname | grep -q Darwin; then
270 # If this is a macos build, then rename the manifest to remove noifdh qualifier in the name
272 noifdh_manifest=`echo $manifest | sed 's/-noifdh//'`
273 mv $manifest $noifdh_manifest
277 # Otherwise (for slf builds), delete the manifest entirely.
284 # edit the manifest's artdaq_core version
286 # version of artdaq_core with underscores
287 ARDC_UVERSION=`ups active | grep artdaq_core | awk '{print $2}'`
289 # version of artdaq_core with dots
290 ARDC_DVERSION=`echo $ARDC_UVERSION | sed -e 's/_/./g' | sed -e 's/^v//'`
292 # we're assuming the qualifiers match up between what we want and what we have for artdaq_core
293 # replace artdaq_core line in manifest with our new version
295 if [ `grep artdaq_core $manifest | wc -l` = 0 ]; then
296 echo "LArSoft manifest lacks an artdaq_core line"
300 ARDCLINE=`grep artdaq_core $manifest | head -1`
301 ARDCOLDVER=`echo $ARDCLINE | awk '{print $2}'`
302 ARDCOLDVERD=`echo $ARDCOLDVER | sed -e 's/_/\\\./g' | sed -e 's/^v//'`
303 ARDCNEWLINE=`echo $ARDCLINE | sed -e "s/${ARDCOLDVER}/${ARDC_UVERSION}/g" | sed -e "s/${ARDCOLDVERD}/${ARDC_DVERSION}/g"`
305 echo "Replacing artdaq_core line the manifest:"
307 echo "with this one:"
309 echo "and deleting others."
311 touch newmanifest.txt || exit 1
312 rm newmanifest.txt || exit 1
313 grep -v artdaq_core $manifest > newmanifest.txt || exit 1
314 echo $ARDCNEWLINE >> newmanifest.txt
315 mv newmanifest.txt $manifest || exit 1
319 echo "Moving tarballs to copyBack"
321 mv *.bz2 $WORKSPACE/copyBack/ || exit 1
323 echo "Moving manifest to copyBack"
325 manifest=dune-*_MANIFEST.txt
326 if [ -f $manifest ]; then
327 mv $manifest $WORKSPACE/copyBack/ || exit 1
329 #cp $MRB_BUILDDIR/dunetpc/releaseDB/*.html $WORKSPACE/copyBack/
330 ls -l $WORKSPACE/copyBack/
331 cd $WORKSPACE || exit 1
332 rm -rf $WORKSPACE/temp || exit 1