All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
buildSBND.sh
Go to the documentation of this file.
1 #!/bin/bash
2 
3 # build sbndcode and sbndutil
4 # use mrb
5 # designed to work on Jenkins
6 # this is a proof of concept script
7 
8 echo "sbndcode version: $SBND_VERSION"
9 echo "base qualifiers: $QUAL"
10 echo "larsoft qualifiers: $SQUAL"
11 echo "build type: $BUILDTYPE"
12 echo "workspace: $WORKSPACE"
13 
14 # Get number of cores to use.
15 
16 if [ `uname` = Darwin ]; then
17  #ncores=`sysctl -n hw.ncpu`
18  #ncores=$(( $ncores / 4 ))
20 else
21  ncores=`cat /proc/cpuinfo 2>/dev/null | grep -c -e '^processor'`
22 fi
23 if [ $ncores -lt 1 ]; then
24  ncores=1
25 fi
26 echo "Building using $ncores cores."
27 
28 # Environment setup, uses /grid/fermiapp or cvmfs.
29 
30 echo "ls /cvmfs/sbnd.opensciencegrid.org"
31 ls /cvmfs/sbnd.opensciencegrid.org
32 echo
33 
34 if [ -f /grid/fermiapp/products/sbnd/setup_sbnd.sh ]; then
35  source /grid/fermiapp/products/sbnd/setup_sbnd.sh || exit 1
36 elif [ -f /cvmfs/sbnd.opensciencegrid.org/products/setup_sbnd.sh ]; then
37  if [ -x /cvmfs/grid.cern.ch/util/cvmfs-uptodate ]; then
38  /cvmfs/grid.cern.ch/util/cvmfs-uptodate /cvmfs/sbnd.opensciencegrid.org/products
39  fi
40  source /cvmfs/sbnd.opensciencegrid.org/products/setup_sbnd.sh || exit 1
41 else
42  echo "No setup file found."
43  exit 1
44 fi
45 # skip around a version of mrb that does not work on macOS
46 
47 if [ `uname` = Darwin ]; then
48  if [[ x`which mrb | grep v1_17_02` != x ]]; then
49  unsetup mrb || exit 1
50  setup mrb v1_16_02 || exit 1
51  fi
52 fi
53 
54 # Use system git on macos.
55 
56 if ! uname | grep -q Darwin; then
57  setup git || exit 1
58 fi
59 setup gitflow || exit 1
61 echo "Mrb path:"
62 which mrb
63 
64 set -x
65 rm -rf $WORKSPACE/temp || exit 1
66 mkdir -p $WORKSPACE/temp || exit 1
67 mkdir -p $WORKSPACE/copyBack || exit 1
68 rm -f $WORKSPACE/copyBack/* || exit 1
69 cd $WORKSPACE/temp || exit 1
70 mrb newDev -v $SBND_VERSION -q $QUAL:$BUILDTYPE || exit 1
71 
72 set +x
73 source localProducts*/setup || exit 1
74 
75 # some shenanigans so we can use getopt v1_1_6
76 if [ `uname` = Darwin ]; then
77 # cd $MRB_INSTALL
78 # 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 || \
79 # { cat 1>&2 <<EOF
80 #ERROR: pull of http://scisoft.fnal.gov/scisoft/packages/getopt/v1_1_6/getopt-1.1.6-d13-x86_64.tar.bz2 failed
81 #EOF
82 # exit 1
83 # }
84 # tar xf getopt-1.1.6-d13-x86_64.tar.bz2 || exit 1
85  setup getopt v1_1_6 || exit 1
86 # which getopt
87 fi
88 
89 set -x
90 cd $MRB_SOURCE || exit 1
91 # make sure we get a read-only copy
92 mrb g -r -b $SBND sbndcode || exit 1
93 
94 # get sbndutil, extracting version from sbndcode product_deps if not specified
95 if [ -z "$SBNDUTIL" ]; then
96  sbndutil_version=`grep sbndutil $MRB_SOURCE/sbndcode/ups/product_deps | grep -v qualifier | awk '{print $2}'`
97  echo "sbndutil version: $sbndutil_version"
98  mrb g -r -t $sbndutil_version sbndutil || exit 1
99 else
100  echo "sbndutil version: $SBNDUTIL"
101  mrb g -r -b $SBNDUTIL sbndutil || exit 1
102 fi
103 
104 cd $MRB_BUILDDIR || exit 1
105 mrbsetenv || exit 1
106 mrb b -j$ncores || exit 1
107 if uname | grep -q Linux; then
108  cp /usr/lib64/libXmu.so.6 sbndcode/lib
109 fi
110 mrb mp -n sbnd -- -j$ncores || exit 1
111 
112 # add sbnd_data to the manifest
113 
114 manifest=sbnd-*_MANIFEST.txt
115 sbnd_data_version=`grep sbnd_data $MRB_SOURCE/sbndcode/ups/product_deps | grep -v qualifier | awk '{print $2}'`
116 sbnd_data_dot_version=`echo ${sbnd_data_version} | sed -e 's/_/./g' | sed -e 's/^v//'`
117 echo "sbnd_data ${sbnd_data_version} sbnd_data-${sbnd_data_dot_version}-noarch.tar.bz2" >> $manifest
118 
119 # Extract sbncode version from product_deps.
120 sbncode_version=`grep sbncode $MRB_SOURCE/sbndcode/ups/product_deps | grep -v qualifier | awk '{print $2}'`
121 sbncode_dot_version=`echo ${sbncode_version} | sed -e 's/_/./g' | sed -e 's/^v//'`
122 
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 # Construct name of sbncode manifest.
134 
135 sbncode_hyphen_qual=`echo $QUAL | tr : - | sed 's/-noifdh//'`
136 sbncode_manifest=sbn-${sbncode_dot_version}-${flvr}-${sbncode_hyphen_qual}-${BUILDTYPE}_MANIFEST.txt
137 echo "sbncode manifest:"
138 echo $sbncode_manifest
139 echo
140 
141 # Fetch sbncode manifest from scisoft and append to sbndcode manifest.
142 
143 curl --fail --silent --location --insecure http://scisoft.fnal.gov/scisoft/bundles/sbn/${sbncode_version}/manifest/${sbncode_manifest} >> $manifest || exit 1
144 
145 if echo $QUAL | grep -q noifdh; then
146  if uname | grep -q Darwin; then
147  # If this is a macos build, then rename the manifest to remove noifdh qualifier in the name
148  noifdh_manifest=`echo $manifest | sed 's/-noifdh//'`
149  mv $manifest $noifdh_manifest
150  else
151  # Otherwise (for slf builds), delete the manifest entirely.
152  rm -f $manifest
153  fi
154 fi
155 
156 # Save artifacts.
157 
158 mv *.bz2 $WORKSPACE/copyBack/ || exit 1
159 manifest=sbnd-*_MANIFEST.txt
160 if [ -f $manifest ]; then
161  mv $manifest $WORKSPACE/copyBack/ || exit 1
162 fi
163 cp $MRB_BUILDDIR/sbndcode/releaseDB/*.html $WORKSPACE/copyBack/
164 ls -l $WORKSPACE/copyBack/
165 cd $WORKSPACE || exit 1
166 rm -rf $WORKSPACE/temp || exit 1
167 set +x
168 
169 exit 0
process_name opflash particleana ie ie ie z
then source grid fermiapp products dune setup_dune_fermiapp sh exit else echo No setup file found exit fi setup
process_name opflash particleana ie x
then cvmfs grid cern ch util cvmfs uptodate cvmfs uboone opensciencegrid org products fi source cvmfs uboone opensciencegrid org products setup_uboone sh exit else echo No setup file found exit fi if!uname grep q Darwin
Definition: build_larcv.sh:51
then setup git exit fi setup gitflow exit export MRB_PROJECT
then sbndutil_version
Definition: buildSBND.sh:96
do source
pdgs p
Definition: selectors.fcl:22
then source cvmfs dune opensciencegrid org products dune setup_dune sh exit elif[-f/grid/fermiapp/products/dune/setup_dune_fermiapp.sh]
then echo Invalid dCache scratch not copying back else ifdh ls
Definition: run_job.sh:111
BEGIN_PROLOG g
then flvr
Definition: buildSBND.sh:128
then noifdh_manifest
Definition: buildSBND.sh:148
then cp usr lib64 libXmu so sbncode lib fi mrb mp n sbn j $ncores exit manifest
Definition: buildSBN.sh:115
then ncores
Definition: build_larcv.sh:26
then shift fi
do cd
g grid
do i e
stream1 can override from command line with o or output services user sbnd
esac echo uname r
then echo echo For Linux