build-garsoft.sh
Go to the documentation of this file.
1 #!/bin/bash
2 
3 # build garsoft
4 # use mrb
5 # designed to work on Jenkins
6 # this is a proof of concept script
7 
8 # Tom Junk, August 22, 2018
9 # copied from the dune_raw_data build script in dune's artdaq_utilities repository
10 
11 echo "garsoft version: $GARSOFT_VERSION"
12 echo "target qualifier: $QUAL"
13 echo "build type: $BUILDTYPE"
14 echo "workspace: $WORKSPACE"
15 
16 # Don't do ifdh build on macos.
17 
18 #if uname | grep -q Darwin; then
19 # if ! echo $QUAL | grep -q noifdh; then
20 # echo "Ifdh build requested on macos. Quitting."
21 # exit
22 # fi
23 #fi
24 
25 # Get number of cores to use.
26 
27 if [ `uname` = Darwin ]; then
28  #ncores=`sysctl -n hw.ncpu`
29  #ncores=$(( $ncores / 4 ))
30  ncores=4
31 else
32  ncores=`cat /proc/cpuinfo 2>/dev/null | grep -c -e '^processor'`
33 fi
34 if [ $ncores -lt 1 ]; then
35  ncores=1
36 fi
37 echo "Building using $ncores cores."
38 
39 # Environment setup, uses cvmfs.
40 
41 echo "ls /cvmfs/dune.opensciencegrid.org/products/dune/"
42 ls /cvmfs/dune.opensciencegrid.org/products/dune/
43 echo
44 
45 echo "ls /cvmfs/larsoft.opensciencegrid.org/products/"
46 ls /cvmfs/larsoft.opensciencegrid.org/products/
47 echo
48 
49 echo "ls /cvmfs/fermilab.opensciencegrid.org/products/common/db"
50 ls /cvmfs/fermilab.opensciencegrid.org/products/common/db
51 echo
52 
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
58  fi
59  source /cvmfs/dune.opensciencegrid.org/products/dune/setup_dune.sh || exit 1
60 else
61  echo "No setup file found."
62  exit 1
63 fi
64 
65 # skip around a version of mrb that does not work on macOS
66 
67 if [ `uname` = Darwin ]; then
68  if [[ x`which mrb | grep v1_17_02` != x ]]; then
69  unsetup mrb || exit 1
70  setup mrb v1_16_02 || exit 1
71  fi
72 fi
73 
74 # Use system git on macos.
75 
76 if ! uname | grep -q Darwin; then
77  setup git || exit 1
78 fi
79 setup gitflow || exit 1
80 export MRB_PROJECT=dune
81 echo "Mrb path:"
82 which mrb
83 
84 #dla set -x
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
90 
91 FQUAL=${QUAL}:${BUILDTYPE}
92 
93 mrb newDev -v $GARSOFT_VERSION -q $FQUAL || exit 1
94 
95 #dla set +x
96 source localProducts*/setup || exit 1
97 
98 # some shenanigans so we can use getopt v1_1_6
99 if [ `uname` = Darwin ]; then
100 # cd $MRB_INSTALL
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 || \
102 # { cat 1>&2 <<EOF
103 #ERROR: pull of http://scisoft.fnal.gov/scisoft/packages/getopt/v1_1_6/getopt-1.1.6-d13-x86_64.tar.bz2 failed
104 #EOF
105 # exit 1
106 # }
107 # tar xf getopt-1.1.6-d13-x86_64.tar.bz2 || exit 1
108  setup getopt v1_1_6 || exit 1
109 # which getopt
110 fi
111 
112 #dla set -x
113 cd $MRB_SOURCE || exit 1
114 # check out a readonly version
115 mrb g -b develop --repo-type github --github-org dune -r -t $GARSOFT_VERSION garsoft || exit 1
116 
117 cd $MRB_BUILDDIR || exit 1
118 mrbsetenv || exit 1
119 mrb b -j$ncores || exit 1
120 mrb mp -n garsoft -- -j$ncores || exit 1
121 
122 # Extract flavor.
123 
124 flvr=''
125 if uname | grep -q Darwin; then
126  flvr=`ups flavor -2`
127 else
128  flvr=`ups flavor -4`
129 fi
130 
131 
132 # Save artifacts.
133 
134 mv *.bz2 $WORKSPACE/copyBack/ || exit 1
135 
136 ls -l $WORKSPACE/copyBack/
137 cd $WORKSPACE || exit 1
138 rm -rf $WORKSPACE/temp || exit 1
139 
140 #dla set +x
141 
142 exit 0