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