build_uboonedata.sh
Go to the documentation of this file.
1 #!/bin/bash
2 
3 # build uboonedata
4 # use mrb
5 # designed to work on Jenkins
6 
7 echo "uboonedata version: $UBOONEDATA"
8 echo "larsoft qualifiers: $QUAL"
9 echo "build type: $BUILDTYPE"
10 echo "workspace: $WORKSPACE"
11 
12 # Don't do ifdh build on macos.
13 
14 #if uname | grep -q Darwin; then
15 # if ! echo $QUAL | grep -q noifdh; then
16 # echo "Ifdh build requested on macos. Quitting."
17 # exit
18 # fi
19 #fi
20 
21 # Get number of cores to use.
22 
23 if [ `uname` = Darwin ]; then
24  #ncores=`sysctl -n hw.ncpu`
25  #ncores=$(( $ncores / 4 ))
26  ncores=1
27 else
28  ncores=`cat /proc/cpuinfo 2>/dev/null | grep -c -e '^processor'`
29 fi
30 if [ $ncores -lt 1 ]; then
31  ncores=1
32 fi
33 echo "Building using $ncores cores."
34 
35 # Environment setup, uses /grid/fermiapp or cvmfs.
36 
37 echo "ls /cvmfs/uboone.opensciencegrid.org"
38 ls /cvmfs/uboone.opensciencegrid.org
39 echo
40 
41 if [ -f /grid/fermiapp/products/uboone/setup_uboone_bluearc.sh ]; then
42  source /grid/fermiapp/products/uboone/setup_uboone_bluearc.sh || exit 1
43 elif [ -f /cvmfs/uboone.opensciencegrid.org/products/setup_uboone.sh ]; then
44  if [ -x /cvmfs/grid.cern.ch/util/cvmfs-uptodate ]; then
45  /cvmfs/grid.cern.ch/util/cvmfs-uptodate /cvmfs/uboone.opensciencegrid.org/products
46  fi
47  source /cvmfs/uboone.opensciencegrid.org/products/setup_uboone.sh || exit 1
48 else
49  echo "No setup file found."
50  exit 1
51 fi
52 
53 # Use system git on macos.
54 
55 if ! uname | grep -q Darwin; then
56  setup git || exit 1
57 fi
58 setup gitflow || exit 1
59 # skip around a version of mrb that does not work on macOS
60 
61 if [ `uname` = Darwin ]; then
62  if [[ x`which mrb | grep v1_17_02` != x ]]; then
63  unsetup mrb || exit 1
64  setup mrb v1_16_02 || exit 1
65  fi
66 fi
67 
68 export MRB_PROJECT=uboone
69 echo "Mrb path:"
70 which mrb
71 
72 set -x
73 rm -rf $WORKSPACE/temp || exit 1
74 mkdir -p $WORKSPACE/temp || exit 1
75 mkdir -p $WORKSPACE/copyBack || exit 1
76 rm -f $WORKSPACE/copyBack/* || exit 1
77 cd $WORKSPACE/temp || exit 1
78 mrb newDev -q $QUAL:$BUILDTYPE || exit 1
79 
80 set +x
81 source localProducts*/setup || exit 1
82 echo "PRODUCTS=$PRODUCTS"
83 
84 # some shenanigans so we can use getopt v1_1_6
85 if [ `uname` = Darwin ]; then
86 # cd $MRB_INSTALL
87 # 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 || \
88 # { cat 1>&2 <<EOF
89 #ERROR: pull of http://scisoft.fnal.gov/scisoft/packages/getopt/v1_1_6/getopt-1.1.6-d13-x86_64.tar.bz2 failed
90 #EOF
91 # exit 1
92 # }
93 # tar xf getopt-1.1.6-d13-x86_64.tar.bz2 || exit 1
94  setup getopt v1_1_6 || exit 1
95 # which getopt
96 fi
97 
98 #set -x
99 cd $MRB_SOURCE || exit 1
100 # make sure we get a read-only copy
101 mrb g -r -t $UBOONEDATA uboonedata || exit 1
102 
103 cd $MRB_BUILDDIR || exit 1
104 mrbsetenv || exit 1
105 mrb b -j$ncores || exit 1
106 mrb mp -n uboonedata -- -j$ncores || exit 1
107 
108 # Save artifacts.
109 
110 mv *.bz2 $WORKSPACE/copyBack/ || exit 1
111 ls -l $WORKSPACE/copyBack/
112 cd $WORKSPACE || exit 1
113 rm -rf $WORKSPACE/temp || exit 1
114 set +x
115 
116 exit 0