5 # designed to work on Jenkins
     6 # this is a proof of concept script
     8 # Tom Junk, August 22, 2018
     9 # copied from the dune_raw_data build script in dune's artdaq_utilities repository
    11 echo "garsoft version: $GARSOFT_VERSION"
    12 echo "target qualifier: $QUAL"
    13 echo "build type: $BUILDTYPE"
    14 echo "workspace: $WORKSPACE"
    16 # Don't do ifdh build on macos.
    18 #if uname | grep -q Darwin; then
    19 #  if ! echo $QUAL | grep -q noifdh; then
    20 #    echo "Ifdh build requested on macos.  Quitting."
    25 # Get number of cores to use.
    27 if [ `uname` = Darwin ]; then
    28   #ncores=`sysctl -n hw.ncpu`
    29   #ncores=$(( $ncores / 4 ))
    32   ncores=`cat /proc/cpuinfo 2>/dev/null | grep -c -e '^processor'`
    34 if [ $ncores -lt 1 ]; then
    37 echo "Building using $ncores cores."
    39 # Environment setup, uses cvmfs.
    41 echo "ls /cvmfs/dune.opensciencegrid.org/products/dune/"
    42 ls /cvmfs/dune.opensciencegrid.org/products/dune/
    45 echo "ls /cvmfs/larsoft.opensciencegrid.org/products/"
    46 ls /cvmfs/larsoft.opensciencegrid.org/products/
    49 echo "ls /cvmfs/fermilab.opensciencegrid.org/products/common/db"
    50 ls /cvmfs/fermilab.opensciencegrid.org/products/common/db
    53 if [ `uname` = Darwin -a -f /grid/fermiapp/products/dune/setup_dune_fermiapp.sh ]; then
    54   source /grid/fermiapp/products/dune/setup_dune_fermiapp.sh || exit 1
    55 elif [ -f /cvmfs/dune.opensciencegrid.org/products/dune/setup_dune.sh ]; then
    56   if [ -x /cvmfs/grid.cern.ch/util/cvmfs-uptodate ]; then
    57     /cvmfs/grid.cern.ch/util/cvmfs-uptodate /cvmfs/dune.opensciencegrid.org/products
    59   source /cvmfs/dune.opensciencegrid.org/products/dune/setup_dune.sh || exit 1
    61   echo "No setup file found."
    65 # skip around a version of mrb that does not work on macOS
    67 if [ `uname` = Darwin ]; then
    68   if [[ x`which mrb | grep v1_17_02` != x ]]; then
    70     setup mrb v1_16_02 || exit 1
    74 # Use system git on macos.
    76 if ! uname | grep -q Darwin; then
    79 setup gitflow || exit 1
    80 export MRB_PROJECT=dune
    85 rm -rf $WORKSPACE/temp || exit 1
    86 mkdir -p $WORKSPACE/temp || exit 1
    87 mkdir -p $WORKSPACE/copyBack || exit 1
    88 rm -f $WORKSPACE/copyBack/* || exit 1
    89 cd $WORKSPACE/temp || exit 1
    91 FQUAL=${QUAL}:${BUILDTYPE}
    93 mrb newDev -v $GARSOFT_VERSION -q $FQUAL || exit 1
    96 source localProducts*/setup || exit 1
    98 # some shenanigans so we can use getopt v1_1_6
    99 if [ `uname` = Darwin ]; then
   101 #  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 || \
   103 #ERROR: pull of http://scisoft.fnal.gov/scisoft/packages/getopt/v1_1_6/getopt-1.1.6-d13-x86_64.tar.bz2 failed
   107 #  tar xf getopt-1.1.6-d13-x86_64.tar.bz2 || exit 1
   108   setup getopt v1_1_6  || exit 1
   113 cd $MRB_SOURCE  || exit 1
   114 # check out a readonly version
   115 mrb g -r -t $GARSOFT_VERSION -d garsoft garsoft-garsoft || exit 1
   117 cd $MRB_BUILDDIR || exit 1
   119 mrb b -j$ncores || exit 1
   120 mrb mp -n garsoft -- -j$ncores || exit 1
   125 if uname | grep -q Darwin; then
   134 mv *.bz2  $WORKSPACE/copyBack/ || exit 1
   136 ls -l $WORKSPACE/copyBack/
   137 cd $WORKSPACE || exit 1
   138 rm -rf $WORKSPACE/temp || exit 1