build-garana.sh
Go to the documentation of this file.
1 #!/bin/bash
2 
3 # build garana
4 # use mrb
5 # designed to work on Jenkins
6 # this is a proof of concept script
7 
8 # Chris Hilgenberg 8 April 2021
9 # copied from garsoft build script, originally written by Tom Junk
10 
11 echo "garana version: $GARANA_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 $GARANA_VERSION -q $FQUAL || exit 1
94 
95 #dla set +x
96 source localProducts*/setup || exit 1
97 
98 #echo "Chris MRB_SOURCE: ${MRB_SOURCE}"
99 #echo "Chris MRB_BUILDDIR: ${MRB_BUILDDIR}"
100 
101 # some shenanigans so we can use getopt v1_1_6
102 if [ `uname` = Darwin ]; then
103 # cd $MRB_INSTALL
104 # 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 || \
105 # { cat 1>&2 <<EOF
106 #ERROR: pull of http://scisoft.fnal.gov/scisoft/packages/getopt/v1_1_6/getopt-1.1.6-d13-x86_64.tar.bz2 failed
107 #EOF
108 # exit 1
109 # }
110 # tar xf getopt-1.1.6-d13-x86_64.tar.bz2 || exit 1
111  setup getopt v1_1_6 || exit 1
112 # which getopt
113 fi
114 
115 #dla set -x
116 cd $MRB_SOURCE || exit 1
117 # check out a readonly version
118 #mrb g -r -t $GARANA_VERSION -d garana garana-garana || exit 1
119 #mrb g -r -t $GARANA_VERSION garana || exit 1
120 mrb g -r -t $GARANA_VERSION https://www.github.com/DUNE/garana || exit
121 cd $MRB_BUILDDIR || exit 1
122 ls
123 mrbsetenv || exit 1
124 mrb b -D BUILD_W_CET=ON -j$ncores || exit 1
125 mrb mp -n garana -- -j$ncores || exit 1
126 
127 # Extract flavor.
128 
129 flvr=''
130 if uname | grep -q Darwin; then
131  flvr=`ups flavor -2`
132 else
133  flvr=`ups flavor -4`
134 fi
135 
136 
137 # Save artifacts.
138 
139 mv *.bz2 $WORKSPACE/copyBack/ || exit 1
140 
141 ls -l $WORKSPACE/copyBack/
142 cd $WORKSPACE || exit 1
143 rm -rf $WORKSPACE/temp || exit 1
144 
145 #dla set +x
146 
147 exit 0