buildProtoDUNEana.sh
Go to the documentation of this file.
1 #!/bin/bash
2 
3 # build protoduneana
4 # trj Oct 31, 2019
5 # use mrb
6 # designed to work on Jenkins
7 
8 echo "protoduneana version: $VERSION"
9 echo "base qualifiers: $QUAL"
10 QUAL=`echo ${QUAL} | sed -e "s/-/:/g"`
11 echo "modified base qualifiers: $QUAL"
12 echo "build type: $BUILDTYPE"
13 echo "workspace: $WORKSPACE"
14 
15 # Don't do ifdh build on macos.
16 
17 #if uname | grep -q Darwin; then
18 # if ! echo $QUAL | grep -q noifdh; then
19 # echo "Ifdh build requested on macos. Quitting."
20 # exit
21 # fi
22 #fi
23 
24 # Get number of cores to use.
25 
26 if [ `uname` = Darwin ]; then
27  #ncores=`sysctl -n hw.ncpu`
28  #ncores=$(( $ncores / 4 ))
29  ncores=4
30 else
31  ncores=`cat /proc/cpuinfo 2>/dev/null | grep -c -e '^processor'`
32 fi
33 if [ $ncores -lt 1 ]; then
34  ncores=1
35 fi
36 echo "Building using $ncores cores."
37 
38 # use /grid/fermiapp for macOS builds and cvmfs for Linux
39 
40 echo "ls /cvmfs/dune.opensciencegrid.org/products/dune/"
41 ls /cvmfs/dune.opensciencegrid.org/products/dune/
42 echo
43 
44 if [ `uname` = Darwin -a -f /grid/fermiapp/products/dune/setup_dune_fermiapp.sh ]; then
45  source /grid/fermiapp/products/dune/setup_dune_fermiapp.sh || exit 1
46 elif [ -f /cvmfs/dune.opensciencegrid.org/products/dune/setup_dune.sh ]; then
47  if [ -x /cvmfs/grid.cern.ch/util/cvmfs-uptodate ]; then
48  /cvmfs/grid.cern.ch/util/cvmfs-uptodate /cvmfs/dune.opensciencegrid.org/products
49  fi
50  source /cvmfs/dune.opensciencegrid.org/products/dune/setup_dune.sh || exit 1
51 else
52  echo "No setup file found."
53  exit 1
54 fi
55 
56 # Use git out of ups except use the system git on macos
57 
58 if ! uname | grep -q Darwin; then
59  setup git || exit 1
60 fi
61 
62 # skip around a version of mrb that does not work on macOS
63 
64 if [ `uname` = Darwin ]; then
65  if [[ x`which mrb | grep v1_17_02` != x ]]; then
66  unsetup mrb || exit 1
67  setup mrb v1_16_02 || exit 1
68  fi
69 fi
70 
71 setup gitflow || exit 1
72 export MRB_PROJECT=dune
73 echo "Mrb path:"
74 which mrb
75 
76 rm -rf $WORKSPACE/temp || exit 1
77 mkdir -p $WORKSPACE/temp || exit 1
78 mkdir -p $WORKSPACE/copyBack || exit 1
79 rm -f $WORKSPACE/copyBack/* || exit 1
80 cd $WORKSPACE/temp || exit 1
81 mrb newDev -v $VERSION -q $QUAL:$BUILDTYPE || exit 1
82 source localProducts*/setup || exit 1
83 
84 if [ `uname` = Darwin ]; then
85  setup getopt v1_1_6 || exit 1
86 fi
87 
88 cd $MRB_SOURCE || exit 1
89 maxtries=20
90 ntries=0
91 until [ $ntries -ge $maxtries ]
92 do
93  date
94  mrb g -r -t $VERSION --repo-type github -g DUNE protoduneana && break
95  ntries=$[$ntries+1]
96  sleep 60
97 done
98 if [ $ntries = $maxtries ]; then
99  echo "Could not clone protoduneana using mrb g. Quitting."
100  exit 1
101 fi
102 
103 
104 cd $MRB_BUILDDIR || exit 1
105 mrbsetenv || exit 1
106 mrb b -j$ncores || exit 1
107 mrb mp -n protoduneana -- -j$ncores || exit 1
108 
109 # add dune_pardata to the manifest
110 
111 manifest=protoduneana-*_MANIFEST.txt
112 
113 # get platform
114 OS=$(uname)
115 case $OS in
116  Linux)
117  PLATFORM=$(uname -r | grep -o "el[0-9]"|sed s'/el/slf/')
118  ;;
119  Darwin)
120  PLATFORM=$(uname -r | awk -F. '{print "d"$1}')
121  ;;
122 esac
123 
124 cd $MRB_SOURCE || exit 1
125 
126 # Extract flavor.
127 
128 flvr=''
129 if uname | grep -q Darwin; then
130  flvr=`ups flavor -2`
131 else
132  flvr=`ups flavor -4`
133 fi
134 
135 # find our set qualifier from artdaq_core's qualifier
136 
137 SQUAL=`ups active | grep artdaq_core | tr : '\n' | grep ^s | awk '{print $1}'`
138 echo "Set qualifier from artdaq_core: $SQUAL"
139 
140 # Save artifacts.
141 
142 echo "Moving tarballs to copyBack"
143 
144 cd $MRB_BUILDDIR || exit 1
145 
146 mv *.bz2 $WORKSPACE/copyBack/ || exit 1
147 
148 echo "Moving manifest to copyBack"
149 
150 manifest=protoduneana-*_MANIFEST.txt
151 if [ -f $manifest ]; then
152  mv $manifest $WORKSPACE/copyBack/ || exit 1
153 fi
154 ls -l $WORKSPACE/copyBack/
155 cd $WORKSPACE || exit 1
156 rm -rf $WORKSPACE/temp || exit 1
157 
158 exit 0