4 # trj Feb 23, 2018: skip building lbne_raw_data and dune_raw_data
5 # trj May 3, 2018: skip building duneutil
7 # designed to work on Jenkins
9 # ignores LARSOFT_QUAL now.
10 # Extract set qualifier from $LARSOFT_QUAL (we don't care about anything else in $LARSOFT_QUAL).
11 #SQUAL=`echo $LARSOFT_QUAL | tr : '\n' | grep ^s`
12 #echo "set qualifier: $SQUAL"
14 echo "dunetpc version: $DUNE"
15 echo "base qualifiers: $QUAL"
16 echo "build type: $BUILDTYPE"
17 echo "workspace: $WORKSPACE"
19 # Don't do ifdh build on macos.
21 #if uname | grep -q Darwin; then
22 # if ! echo $QUAL | grep -q noifdh; then
23 # echo "Ifdh build requested on macos. Quitting."
28 # Get number of cores to use.
30 if [ `uname` = Darwin ]; then
31 #ncores=`sysctl -n hw.ncpu`
32 #ncores=$(( $ncores / 4 ))
35 ncores=`cat /proc/cpuinfo 2>/dev/null | grep -c -e '^processor'`
37 if [ $ncores -lt 1 ]; then
40 echo "Building using $ncores cores."
42 # Environment setup. Just use cvmfs. larsoft builds are not supported on /grid/fermiapp anymore
44 echo "ls /cvmfs/dune.opensciencegrid.org/products/dune/"
45 ls /cvmfs/dune.opensciencegrid.org/products/dune/
48 if [ `uname` = Darwin -a -f /grid/fermiapp/products/dune/setup_dune_fermiapp.sh ]; then
49 source /grid/fermiapp/products/dune/setup_dune_fermiapp.sh || exit 1
50 elif [ -f /cvmfs/dune.opensciencegrid.org/products/dune/setup_dune.sh ]; then
51 if [ -x /cvmfs/grid.cern.ch/util/cvmfs-uptodate ]; then
52 /cvmfs/grid.cern.ch/util/cvmfs-uptodate /cvmfs/dune.opensciencegrid.org/products
54 source /cvmfs/dune.opensciencegrid.org/products/dune/setup_dune.sh || exit 1
56 echo "No setup file found."
60 # Use git out of ups except use the system git on macos
62 if ! uname | grep -q Darwin; then
66 # skip around a version of mrb that does not work on macOS
68 if [ `uname` = Darwin ]; then
69 if [[ x`which mrb | grep v1_17_02` != x ]]; then
71 setup mrb v1_16_02 || exit 1
75 setup gitflow || exit 1
76 export MRB_PROJECT=dune
80 # make the timeouts longer and accept low-speed transfers
82 export GIT_HTTP_LOW_SPEED_LIMIT=1000
83 export GIT_HTTP_LOW_SPEED_TIME=600
86 rm -rf $WORKSPACE/temp || exit 1
87 mkdir -p $WORKSPACE/temp || exit 1
88 mkdir -p $WORKSPACE/copyBack || exit 1
89 rm -f $WORKSPACE/copyBack/* || exit 1
90 cd $WORKSPACE/temp || exit 1
91 mrb newDev -v $DUNE -q $QUAL:$BUILDTYPE || exit 1
94 source localProducts*/setup || exit 1
96 # some shenanigans so we can use getopt v1_1_6
97 if [ `uname` = Darwin ]; then
99 # 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 || \
101 #ERROR: pull of http://scisoft.fnal.gov/scisoft/packages/getopt/v1_1_6/getopt-1.1.6-d13-x86_64.tar.bz2 failed
105 # tar xf getopt-1.1.6-d13-x86_64.tar.bz2 || exit 1
106 setup getopt v1_1_6 || exit 1
111 cd $MRB_SOURCE || exit 1
112 # make sure we get a read-only copy
113 # put some retry logic here instead
117 until [ $ntries -ge $maxtries ]
120 mrb g -r -t $DUNE dunetpc && break
124 if [ $ntries = $maxtries ]; then
125 echo "Could not clone dunetpc using mrb g. Quitting."
129 ## Extract duneutil version from dunetpc product_deps
130 #duneutil_version=`grep duneutil $MRB_SOURCE/dunetpc/ups/product_deps | grep -v qualifier | awk '{print $2}'`
131 #echo "duneutil version: $duneutil_version"
132 #mrb g -r -t $duneutil_version duneutil || exit 1
135 cd $MRB_BUILDDIR || exit 1
137 mrb b -j$ncores || exit 1
138 mrb mp -n dune -- -j$ncores || exit 1
140 # add dune_pardata to the manifest
142 manifest=dune-*_MANIFEST.txt
143 dune_pardata_version=`grep dune_pardata $MRB_SOURCE/dunetpc/ups/product_deps | grep -v qualifier | awk '{print $2}'`
144 dune_pardata_dot_version=`echo ${dune_pardata_version} | sed -e 's/_/./g' | sed -e 's/^v//'`
145 echo "dune_pardata ${dune_pardata_version} dune_pardata-${dune_pardata_dot_version}-noarch.tar.bz2" >> $manifest
151 PLATFORM=$(uname -r | grep -o "el[0-9]"|sed s'/el/slf/')
154 PLATFORM=$(uname -r | awk -F. '{print "d"$1}')
158 # need to check out dune_raw_data to get the dunepdsrpce version -- do it here, after the build
160 cd $MRB_SOURCE || exit 1
162 # Extract dune_raw_data version from our ups active list
164 dune_raw_data_version=`ups active | grep dune_raw_data | awk '{print $2}'`
165 echo "dune_raw_data version: $dune_raw_data_version"
166 artqual=`ups active | grep dune_raw_data | awk '{print $6}' | sed -e "s/${QUAL}//g" | sed -e "s/nu//g" | sed -e "s/://g" | sed -e "s/${BUILDTYPE}//g"`
167 lbne_raw_data_version=`ups active | grep lbne_raw_data | awk '{print $2}'`
168 echo "lbne_raw_data version: $lbne_raw_data_version"
172 # also add dune_raw_data and lbne_raw_data to the manifest
174 dune_raw_data_dot_version=`echo ${dune_raw_data_version} | sed -e 's/_/./g' | sed -e 's/^v//'`
175 echo "dune_raw_data ${dune_raw_data_version} dune_raw_data-${dune_raw_data_dot_version}-${PLATFORM}-x86_64-${QUAL}-nu-${artqual}-${BUILDTYPE}.tar.bz2" >> $manifest
176 lbne_raw_data_dot_version=`echo ${lbne_raw_data_version} | sed -e 's/_/./g' | sed -e 's/^v//'`
177 echo "lbne_raw_data ${lbne_raw_data_version} lbne_raw_data-${lbne_raw_data_dot_version}-${PLATFORM}-x86_64-${QUAL}-nu-${artqual}-${BUILDTYPE}.tar.bz2" >> $manifest
179 # add dunepdsprce to the manifest
181 dunepdsprce_version=`ups active | grep dunepdsprce | awk '{print $2}'`
182 echo "dunepdsprce version: $dunepdsprce_version"
183 dunepdsprce_dot_version=`echo ${dunepdsprce_version} | sed -e 's/_/./g' | sed -e 's/^v//'`
184 echo "dunepdsprce ${dunepdsprce_version} dunepdsprce-${dunepdsprce_dot_version}-${PLATFORM}-x86_64-gen-${QUAL}-${BUILDTYPE}.tar.bz2" >> $manifest
186 # add dune_oslibs to the manifest
188 dune_oslibs_version=`ups active | grep dune_oslibs | awk '{print $2}'`
189 echo "dune_oslibs version: $dune_oslibs_version"
190 dune_oslibs_dot_version=`echo ${dune_oslibs_version} | sed -e 's/_/./g' | sed -e 's/^v//'`
191 echo "dune_oslibs ${dune_oslibs_version} dune_oslibs-${dune_oslibs_dot_version}-${PLATFORM}-x86_64.tar.bz2" >> $manifest
193 # Extract larsoft version from product_deps.
195 larsoft_version=`grep larsoft $MRB_SOURCE/dunetpc/ups/product_deps | grep -v qualifier | awk '{print $2}'`
196 larsoft_dot_version=`echo ${larsoft_version} | sed -e 's/_/./g' | sed -e 's/^v//'`
201 if uname | grep -q Darwin; then
207 # find our set qualifier from artdaq_core's qualifier
209 SQUAL=`ups active | grep artdaq_core | tr : '\n' | grep ^s | awk '{print $1}'`
210 echo "Set qualifier from artdaq_core: $SQUAL"
212 # Construct name of larsoft manifest.
214 #larsoft_hyphen_qual=`echo $LARSOFT_QUAL | tr : - | sed 's/-noifdh//'`
215 larsoft_manifest=larsoft-${larsoft_dot_version}-${flvr}-${SQUAL}-${QUAL}-${BUILDTYPE}_MANIFEST.txt
216 echo "Larsoft manifest:"
217 echo $larsoft_manifest
220 # Fetch laraoft manifest from scisoft and append to dunetpc manifest.
222 echo "curl --fail --silent --location --insecure http://scisoft.fnal.gov/scisoft/bundles/larsoft/${larsoft_version}/manifest/${larsoft_manifest} >> $manifest || exit 1"
224 curl --fail --silent --location --insecure http://scisoft.fnal.gov/scisoft/bundles/larsoft/${larsoft_version}/manifest/${larsoft_manifest} >> $manifest || exit 1
226 echo "Done with the curl command."
228 # Special handling of noifdh builds goes here.
230 if echo $QUAL | grep -q noifdh; then
232 if uname | grep -q Darwin; then
234 # If this is a macos build, then rename the manifest to remove noifdh qualifier in the name
236 noifdh_manifest=`echo $manifest | sed 's/-noifdh//'`
237 mv $manifest $noifdh_manifest
241 # Otherwise (for slf builds), delete the manifest entirely.
248 # edit the manifest's artdaq_core version
250 # version of artdaq_core with underscores
251 ARDC_UVERSION=`ups active | grep artdaq_core | awk '{print $2}'`
253 # version of artdaq_core with dots
254 ARDC_DVERSION=`echo $ARDC_UVERSION | sed -e 's/_/./g' | sed -e 's/^v//'`
256 # we're assuming the qualifiers match up between what we want and what we have for artdaq_core
257 # replace artdaq_core line in manifest with our new version
259 if [ `grep artdaq_core $manifest | wc -l` = 0 ]; then
260 echo "LArSoft manifest lacks an artdaq_core line"
264 ARDCLINE=`grep artdaq_core $manifest | head -1`
265 ARDCOLDVER=`echo $ARDCLINE | awk '{print $2}'`
266 ARDCOLDVERD=`echo $ARDCOLDVER | sed -e 's/_/\\\./g' | sed -e 's/^v//'`
267 ARDCNEWLINE=`echo $ARDCLINE | sed -e "s/${ARDCOLDVER}/${ARDC_UVERSION}/g" | sed -e "s/${ARDCOLDVERD}/${ARDC_DVERSION}/g"`
269 echo "Replacing artdaq_core line the manifest:"
271 echo "with this one:"
273 echo "and deleting others."
275 touch newmanifest.txt || exit 1
276 rm newmanifest.txt || exit 1
277 grep -v artdaq_core $manifest > newmanifest.txt || exit 1
278 echo $ARDCNEWLINE >> newmanifest.txt
279 mv newmanifest.txt $manifest || exit 1
283 echo "Moving tarballs to copyBack"
285 mv *.bz2 $WORKSPACE/copyBack/ || exit 1
287 echo "Moving manifest to copyBack"
289 manifest=dune-*_MANIFEST.txt
290 if [ -f $manifest ]; then
291 mv $manifest $WORKSPACE/copyBack/ || exit 1
293 #cp $MRB_BUILDDIR/dunetpc/releaseDB/*.html $WORKSPACE/copyBack/
294 ls -l $WORKSPACE/copyBack/
295 cd $WORKSPACE || exit 1
296 rm -rf $WORKSPACE/temp || exit 1