buildSBN.sh
Go to the documentation of this file.
1 #!/bin/bash
2 
3 # build sbncode
4 # use mrb
5 # designed to work on Jenkins
6 # this is a proof of concept script
7 
8 echo "sbncode version: $SBN_VERSION"
9 echo "sbncode tag: $SBN"
10 echo "sbnobj tag: $SBNOBJ"
11 echo "sbnanaobj tag: $SBNANAOBJ"
12 echo "sbndaq_artdaq_core tag: $SBNDAQ_ARTDAQ_CORE"
13 echo "base qualifiers: $QUAL"
14 echo "s qualifier: $SQUAL"
15 echo "build type: $BUILDTYPE"
16 echo "workspace: $WORKSPACE"
17 
18 # Get number of cores to use.
19 
20 ncores=`cat /proc/cpuinfo 2>/dev/null | grep -c -e '^processor'`
21 
22 if [ $ncores -lt 1 ]; then
23  ncores=1
24 fi
25 echo "Building using $ncores cores."
26 
27 # Environment setup, uses cvmfs.
28 
29 echo "ls /cvmfs/larsoft.opensciencegrid.org"
30 ls /cvmfs/larsoft.opensciencegrid.org
31 echo
32 
33 if [ -f /cvmfs/larsoft.opensciencegrid.org/products/setup ]; then
34  if [ -x /cvmfs/grid.cern.ch/util/cvmfs-uptodate ]; then
35  /cvmfs/grid.cern.ch/util/cvmfs-uptodate /cvmfs/larsoft.opensciencegrid.org/products
36  fi
37  source /cvmfs/larsoft.opensciencegrid.org/products/setup || exit 1
38 else
39  echo "No larsoft setup file found."
40  exit 1
41 fi
42 
43 echo "ls /cvmfs/sbn.opensciencegrid.org"
44 ls /cvmfs/sbn.opensciencegrid.org
45 echo
46 
47 if [ -f /cvmfs/sbn.opensciencegrid.org/products/sbn/setup ]; then
48  if [ -x /cvmfs/grid.cern.ch/util/cvmfs-uptodate ]; then
49  /cvmfs/grid.cern.ch/util/cvmfs-uptodate /cvmfs/sbn.opensciencegrid.org/products/sbn
50  fi
51  echo "Setting up sbn cvmfs"
52  source /cvmfs/sbn.opensciencegrid.org/products/sbn/setup || exit 1
53 else
54  echo "No sbn setup file found."
55  exit 1
56 fi
57 
58 #setup mrb
59 setup mrb || exit 1
60 
61 # Use system git on macos.
62 if ! uname | grep -q Darwin; then
63  setup git || exit 1
64 fi
65 setup gitflow || exit 1
66 export MRB_PROJECT=sbn
67 echo "Mrb path:"
68 which mrb
69 
70 set -x
71 rm -rf $WORKSPACE/temp || exit 1
72 mkdir -p $WORKSPACE/temp || exit 1
73 mkdir -p $WORKSPACE/copyBack || exit 1
74 rm -f $WORKSPACE/copyBack/* || exit 1
75 cd $WORKSPACE/temp || exit 1
76 mrb newDev -v $SBN_VERSION -q $QUAL:$BUILDTYPE || exit 1
77 
78 set +x
79 source localProducts*/setup || exit 1
80 
81 set -x
82 cd $MRB_SOURCE || exit 1
83 # make sure we get a read-only copy
84 mrb g -r sbncode@$SBN || exit 1
85 
86 if [ -z "$SBNOBJ" ]; then
87  # Extract sbnobj version from sbncode product_deps
88  SBNOBJ=`grep sbnobj $MRB_SOURCE/sbncode/ups/product_deps | grep -v qualifier | awk '{print $2}'`
89 fi
90 echo "sbnobj version: $SBNOBJ"
91 mrb g -r sbnobj@$SBNOBJ || exit 1
92 
93 if [ -z "$SBNANAOBJ" ]; then
94  # Extract sbnobj version from sbncode product_deps
95  SBNANAOBJ=`grep sbnanaobj $MRB_SOURCE/sbncode/ups/product_deps | grep -v qualifier | awk '{print $2}'`
96 fi
97 echo "sbnanaobj version: $SBNANAOBJ"
98 mrb g -r sbnanaobj@$SBNANAOBJ || exit 1
99 
100 if [ -z "$SBNDAQ_ARTDAQ_CORE" ]; then
101  # Extract sbndaq_artdaq_core version from sbncode product_deps
102  SBNDAQ_ARTDAQ_CORE=`grep sbndaq_artdaq_core $MRB_SOURCE/sbncode/ups/product_deps | grep -v qualifier | awk '{print $2}'`
103 fi
104 echo "sbndaq_artdaq_core version: $SBNDAQ_ARTDAQ_CORE"
105 mrb g -r sbndaq_artdaq_core@$SBNDAQ_ARTDAQ_CORE || exit 1
106 
107 cd $MRB_BUILDDIR || exit 1
108 mrbsetenv || exit 1
109 mrb b -j$ncores || exit 1
110 if uname | grep -q Linux; then
111  cp /usr/lib64/libXmu.so.6 sbncode/lib
112 fi
113 mrb mp -n sbn -- -j$ncores || exit 1
114 
115 manifest=sbn-*_MANIFEST.txt
116 
117 # Extract larsoft version from product_deps.
118 larsoft_version=`grep larsoft $MRB_SOURCE/sbncode/ups/product_deps | grep -v qualifier | awk '{print $2}'`
119 larsoft_dot_version=`echo ${larsoft_version} | sed -e 's/_/./g' | sed -e 's/^v//'`
120 
121 # Extract flavor.
122 flvr=`ups flavor -4`
123 
124 # Construct name of larsoft manifest.
125 
126 larsoft_hyphen_qual=`echo $SQUAL:$QUAL | tr : - | sed 's/-noifdh//'`
127 larsoft_manifest=larsoft-${larsoft_dot_version}-${flvr}-${larsoft_hyphen_qual}-${BUILDTYPE}_MANIFEST.txt
128 echo "Larsoft manifest:"
129 echo $larsoft_manifest
130 echo
131 
132 # Fetch larsoft manifest from scisoft and append to sbncode manifest.
133 
134 curl --fail --silent --location --insecure http://scisoft.fnal.gov/scisoft/bundles/larsoft/${larsoft_version}/manifest/${larsoft_manifest} >> $manifest || exit 1
135 
136 if echo $QUAL | grep -q noifdh; then
137  # Delete the manifest entirely.
138  rm -f $manifest
139 fi
140 
141 # Save artifacts.
142 
143 mv *.bz2 $WORKSPACE/copyBack/ || exit 1
144 manifest=sbn-*_MANIFEST.txt
145 if [ -f $manifest ]; then
146  mv $manifest $WORKSPACE/copyBack/ || exit 1
147 fi
148 cp $MRB_BUILDDIR/sbncode/releaseDB/*.html $WORKSPACE/copyBack/
149 ls -l $WORKSPACE/copyBack/
150 cd $WORKSPACE || exit 1
151 rm -rf $WORKSPACE/temp || exit 1
152 set +x
153 
154 exit 0