3 # build sbndcode and sbndutil
5 # designed to work on Jenkins
6 # this is a proof of concept script
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"
14 # Get number of cores to use.
16 if [ `uname` = Darwin ]; then
17 #ncores=`sysctl -n hw.ncpu`
18 #ncores=$(( $ncores / 4 ))
21 ncores=`cat /proc/cpuinfo 2>/dev/null | grep -c -e '^processor'`
23 if [ $ncores -lt 1 ]; then
26 echo "Building using $ncores cores."
28 # Environment setup, uses /grid/fermiapp or cvmfs.
30 echo "ls /cvmfs/sbnd.opensciencegrid.org"
31 ls /cvmfs/sbnd.opensciencegrid.org
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
40 source /cvmfs/sbnd.opensciencegrid.org/products/setup_sbnd.sh || exit 1
42 echo "No setup file found."
45 # skip around a version of mrb that does not work on macOS
47 if [ `uname` = Darwin ]; then
48 if [[ x`which mrb | grep v1_17_02` != x ]]; then
50 setup mrb v1_16_02 || exit 1
54 # Use system git on macos.
56 if ! uname | grep -q Darwin; then
59 setup gitflow || exit 1
60 export MRB_PROJECT=sbnd
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
73 source localProducts*/setup || exit 1
75 # some shenanigans so we can use getopt v1_1_6
76 if [ `uname` = Darwin ]; then
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 || \
80 #ERROR: pull of http://scisoft.fnal.gov/scisoft/packages/getopt/v1_1_6/getopt-1.1.6-d13-x86_64.tar.bz2 failed
84 # tar xf getopt-1.1.6-d13-x86_64.tar.bz2 || exit 1
85 setup getopt v1_1_6 || exit 1
90 cd $MRB_SOURCE || exit 1
91 # make sure we get a read-only copy
92 mrb g -r -b $SBND sbndcode || exit 1
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
100 echo "sbndutil version: $SBNDUTIL"
101 mrb g -r -b $SBNDUTIL sbndutil || exit 1
104 cd $MRB_BUILDDIR || 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
110 mrb mp -n sbnd -- -j$ncores || exit 1
112 # add sbnd_data to the manifest
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
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//'`
127 if uname | grep -q Darwin; then
133 # Construct name of sbncode manifest.
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
141 # Fetch sbncode manifest from scisoft and append to sbndcode manifest.
143 curl --fail --silent --location --insecure http://scisoft.fnal.gov/scisoft/bundles/sbn/${sbncode_version}/manifest/${sbncode_manifest} >> $manifest || exit 1
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
151 # Otherwise (for slf builds), delete the manifest entirely.
158 mv *.bz2 $WORKSPACE/copyBack/ || exit 1
159 manifest=sbnd-*_MANIFEST.txt
160 if [ -f $manifest ]; then
161 mv $manifest $WORKSPACE/copyBack/ || exit 1
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