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