5 # designed to work on Jenkins
6 # this is a proof of concept script
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"
18 # Get number of cores to use.
20 ncores=`cat /proc/cpuinfo 2>/dev/null | grep -c -e '^processor'`
22 if [ $ncores -lt 1 ]; then
25 echo "Building using $ncores cores."
27 # Environment setup, uses cvmfs.
29 echo "ls /cvmfs/larsoft.opensciencegrid.org"
30 ls /cvmfs/larsoft.opensciencegrid.org
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
37 source /cvmfs/larsoft.opensciencegrid.org/products/setup || exit 1
39 echo "No larsoft setup file found."
43 echo "ls /cvmfs/sbn.opensciencegrid.org"
44 ls /cvmfs/sbn.opensciencegrid.org
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
51 echo "Setting up sbn cvmfs"
52 source /cvmfs/sbn.opensciencegrid.org/products/sbn/setup || exit 1
54 echo "No sbn setup file found."
61 # Use system git on macos.
62 if ! uname | grep -q Darwin; then
65 setup gitflow || exit 1
66 export MRB_PROJECT=sbn
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
79 source localProducts*/setup || exit 1
82 cd $MRB_SOURCE || exit 1
83 # make sure we get a read-only copy
84 mrb g -r sbncode@$SBN || exit 1
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}'`
90 echo "sbnobj version: $SBNOBJ"
91 mrb g -r sbnobj@$SBNOBJ || exit 1
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}'`
97 echo "sbnanaobj version: $SBNANAOBJ"
98 mrb g -r sbnanaobj@$SBNANAOBJ || exit 1
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}'`
104 echo "sbndaq_artdaq_core version: $SBNDAQ_ARTDAQ_CORE"
105 mrb g -r sbndaq_artdaq_core@$SBNDAQ_ARTDAQ_CORE || exit 1
107 cd $MRB_BUILDDIR || 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
113 mrb mp -n sbn -- -j$ncores || exit 1
115 manifest=sbn-*_MANIFEST.txt
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//'`
124 # Construct name of larsoft manifest.
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
132 # Fetch larsoft manifest from scisoft and append to sbncode manifest.
134 curl --fail --silent --location --insecure http://scisoft.fnal.gov/scisoft/bundles/larsoft/${larsoft_version}/manifest/${larsoft_manifest} >> $manifest || exit 1
136 if echo $QUAL | grep -q noifdh; then
137 # Delete the manifest entirely.
143 mv *.bz2 $WORKSPACE/copyBack/ || exit 1
144 manifest=sbn-*_MANIFEST.txt
145 if [ -f $manifest ]; then
146 mv $manifest $WORKSPACE/copyBack/ || exit 1
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