2 # Downloads and installs dune-raw-data as an MRB-controlled repository
4 # THIS WILL INSTALL THE OFFLINE, I.E., nu-QUALIFIED VERSION OF dune-raw-data
9 git_status=`git status 2>/dev/null`
11 if [ $git_sts -eq 0 ];then
12 echo "This script is designed to be run in a fresh install directory!"
18 test -d products || mkdir products
19 test -d download || mkdir download
20 test -d log || mkdir log
22 if $bad_network ; then
23 echo "\"bad_network\" parameter is set; therefore quick-mrb-start.sh makes the following assumptions: "
24 echo "-All needed products are on the host, and the setup for those products has been sourced"
25 echo "-The git repos for artdaq, etc., are already in this directory"
26 echo "-There's a file already existing called $Base/download/product_deps which will tell this script what version of artdaq, etc., to expect"
27 echo "-Your host has the SLF7 operating system"
28 echo "-You've deleted the directories which look like localProducts_dune_raw_data_* and build_slf7.x86_64 (though the versions may have changed since this instruction was written)"
34 env_opts_var=`basename $0 | sed 's/\.sh$//' | tr 'a-z-' 'A-Z_'`_OPTS
36 usage: `basename $0` [options]
37 examples: `basename $0`
38 `basename $0` --debug --dune-raw-data-developer --dune-raw-data-develop-branch
39 --debug perform a debug build
40 --dune-raw-data-develop-branch Install the current \"develop\" version of dune-raw-data (may be unstable!)
41 --dune-raw-data-developer use if you have (and want to use) write access to the dune-raw-data repository
44 # Process script arguments and options
45 eval env_opts=\${$env_opts_var-} # can be args too
46 eval "set -- $env_opts \"\$@\""
47 op1chr='rest=`expr "$op" : "[^-]\(.*\)"` && set -- "-$rest" "$@"'
48 op1arg='rest=`expr "$op" : "[^-]\(.*\)"` && set -- "$rest" "$@"'
49 reqarg="$op1arg;"'test -z "${1+1}" &&echo opt -$op requires arg. &&echo "$USAGE" &&exit'
50 args= do_help= opt_v=0; opt_lrd_w=0; opt_lrd_develop=0; opt_la_nw=0;
51 while [ -n "${1-}" ];do
52 if expr "x${1-}" : 'x-' >/dev/null;then
53 op=`expr "x$1" : 'x-\(.*\)'`; shift # done with $1
54 leq=`expr "x$op" : 'x-[^=]*\(=\)'` lev=`expr "x$op" : 'x-[^=]*=\(.*\)'`
55 test -n "$leq"&&eval "set -- \"\$lev\" \"\$@\""&&op=`expr "x$op" : 'x\([^=]*\)'`
57 \?*|h*) eval $op1chr; do_help=1;;
58 -debug) opt_debug=--debug;;
59 -dune-raw-data-develop-branch) opt_lrd_develop=1;;
60 -dune-raw-data-developer) opt_lrd_w=1;;
61 *) echo "Unknown option -$op"; do_help=1;;
64 aa=`echo "$1" | sed -e"s/'/'\"'\"'/g"` args="$args '$aa'"; shift
67 eval "set -- $args \"\$@\""; unset args aa
69 set -u # complain about uninitialed shell variables - helps development
71 if [[ $opt_lrd_develop -eq 0 ]]; then
72 echo "JCF, May-12-2017: currently there isn't an official cut release of dune-raw-data; therefore you need to supply the --dune-raw-data-develop-branch argument to this script" >&2
76 dune_repo=/cvmfs/dune.opensciencegrid.org/products/dune
78 if [[ ! -e $dune_repo ]]; then
79 echo "This installation needs access to the CVMFS mount point for the dune repo, ${dune_repo}, in order to obtain the dunepdsprce packages. Aborting..." >&2
83 source $dune_repo/setup
85 larsoft_repo=/cvmfs/fermilab.opensciencegrid.org/products/larsoft
87 if [[ -e $larsoft_repo ]]; then
88 source $larsoft_repo/setup
91 test -n "${do_help-}" -o $# -ge 2 && echo "$USAGE" && exit
94 # Save all output from this script (stdout + stderr) in a file with a
95 # name that looks like "quick-start.sh_Fri_Jan_16_13:58:27.script" as
96 # well as all stderr in a file with a name that looks like
97 # "quick-start.sh_Fri_Jan_16_13:58:27_stderr.script"
98 alloutput_file=$( date | awk -v "SCRIPTNAME=$(basename $0)" '{print SCRIPTNAME"_"$1"_"$2"_"$3"_"$4".script"}' )
99 stderr_file=$( date | awk -v "SCRIPTNAME=$(basename $0)" '{print SCRIPTNAME"_"$1"_"$2"_"$3"_"$4"_stderr.script"}' )
100 exec > >(tee "$Base/log/$alloutput_file")
101 exec 2> >(tee "$Base/log/$stderr_file")
103 function detectAndPull() {
113 local packageVersion=$4
115 local packageVersion=`curl http://scisoft.fnal.gov/scisoft/packages/${packageName}/ 2>/dev/null|grep ${packageName}|grep "id=\"v"|tail -1|sed 's/.* id="\(v.*\)".*/\1/'`
117 local packageDotVersion=`echo $packageVersion|sed 's/_/\./g'|sed 's/v//'`
119 if [[ "$packageOs" != "noarch" ]]; then
120 local upsflavor=`ups flavor`
121 local packageQualifiers="-`echo $qualifiers|sed 's/:/-/g'`"
122 local packageUPSString="-f $upsflavor -q$qualifiers"
124 local packageInstalled=`ups list -aK+ $packageName $packageVersion ${packageUPSString-}|grep -c "$packageName"`
125 if [ $packageInstalled -eq 0 ]; then
126 local packagePath="$packageName/$packageVersion/$packageName-$packageDotVersion-${packageOs}${packageQualifiers-}.tar.bz2"
127 echo wget http://scisoft.fnal.gov/scisoft/packages/$packagePath
128 wget http://scisoft.fnal.gov/scisoft/packages/$packagePath >/dev/null 2>&1
129 local packageFile=$( echo $packagePath | awk 'BEGIN { FS="/" } { print $NF }' )
131 if [[ ! -e $packageFile ]]; then
132 echo "Unable to download $packageName"
138 tar -xjf $Base/download/$packageFile
144 if $bad_network ; then
152 if [[ -z $os ]]; then
153 echo "Cloning cetpkgsupport to determine current OS"
154 git clone http://cdcvs.fnal.gov/projects/cetpkgsupport
155 os=`./cetpkgsupport/bin/get-directory-name os`
158 if [[ "$os" == "u14" ]]; then
159 echo "-H Linux64bit+3.19-2.19" >../products/ups_OVERRIDE.`hostname`
162 # Get all the information we'll need to decide which exact flavor of the software to install
163 if [ -z "${tag:-}" ]; then
167 if ! $bad_network; then
168 wget https://cdcvs.fnal.gov/redmine/projects/dune-raw-data/repository/revisions/$tag/raw/ups/product_deps
171 if [[ ! -e $Base/download/product_deps ]]; then
172 echo "You need to have a product_deps file in $Base/download" >&2
176 coredemo_version=`grep "parent dune_raw_data" $Base/download/product_deps|awk '{print $3}'`
178 default_quals=$( awk '/^defaultqual/ {print $2} ' $Base/download/product_deps )
179 default_quals=$( echo $default_quals | sed -r 's/online/nu/' )
183 defaultE=$( echo $quals | sed -r 's/.*(e[0-9]+).*/\1/' )
184 defaultS=$( echo $quals | sed -r 's/.*(s[0-9]+).*/\1/' )
186 if [ -n "${equalifier-}" ]; then
187 equalifier="e${equalifier}";
191 if [ -n "${squalifier-}" ]; then
192 squalifier="s${squalifier}"
196 if [[ -n "${opt_debug:-}" ]] ; then
202 artdaq_core_version=$( sed -r -n 's/artdaq_core\s+(.*)\s+nu.*/\1/p' $Base/download/product_deps )
203 art_version=$( sed -r -n 's/art\s+(.*)\s+nu.*/\1/p' $Base/download/product_deps)
204 TRACE_version=$( sed -r -n 's/TRACE\s+(.*)\s+nu.*/\1/p' $Base/download/product_deps)
205 cetbuildtools_version=$( sed -r -n 's/cetbuildtools\s+(.*)\s+nu.*/\1/p' $Base/download/product_deps)
208 artdaq_core_version_dot=$( echo $artdaq_core_version | sed -r 's/v//;s/_/./g' )
209 art_version_dot=$( echo $art_version | sed -r 's/v//;s/_/./g' )
210 TRACE_version_dot=$( echo $TRACE_version | sed -r 's/v//;s/_/./g' )
211 cetbuildtools_version_dot=$( echo $cetbuildtools_version | sed -r 's/v//;s/_/./g' )
213 # If we aren't connected to the outside world, you'll need to have
214 # previously scp'd or rsync'd the products to the host you're trying
215 # to install dune-artdaq on
217 if ! $bad_network; then
218 wget http://scisoft.fnal.gov/scisoft/bundles/tools/pullProducts
219 chmod +x pullProducts
221 ./pullProducts $Base/products ${os} art-${art_version} ${equalifier} ${build_type}
223 if [ $? -ne 0 ]; then
224 echo "Error in pullProducts. Please go to http://scisoft.fnal.gov/scisoft/bundles/art/${art_version}/manifest and make sure that a manifest for the specified qualifier (${equalifier}) exists."
228 detectAndPull mrb noarch
230 curl -O http://scisoft.fnal.gov/scisoft/packages/artdaq_core/$artdaq_core_version/artdaq_core-${artdaq_core_version_dot}-${os}-x86_64-${equalifier}-${squalifier}-${build_type}.tar.bz2
231 curl -O http://scisoft.fnal.gov/scisoft/packages/cetbuildtools/$cetbuildtools_version/cetbuildtools-${cetbuildtools_version_dot}-noarch.tar.bz2
232 curl -O http://scisoft.fnal.gov/scisoft/packages/TRACE/$TRACE_version/TRACE-${TRACE_version_dot}-${os}-x86_64.tar.bz2
237 echo "Unzipping downloaded archive files; this may take a while..."
239 for archivefile in $Base/download/*.bz2; do
240 echo tar xjf $archivefile
244 source $Base/products/setup
249 export MRB_PROJECT=dune_raw_data
251 mrb newDev -f -v $coredemo_version -q ${quals}:${build_type}
253 localproducts_setup=$Base/localProducts_dune_raw_data_${coredemo_version}_$( echo $quals | tr ':' '_' )_${build_type}/setup
254 source $localproducts_setup
259 if [[ $opt_lrd_develop -eq 1 ]]; then
260 dune_raw_data_checkout_arg="-d dune_raw_data"
262 dune_raw_data_checkout_arg="-t ${coredemo_version} -d dune_raw_data"
266 if [[ $opt_lrd_w -eq 1 ]]; then
267 dune_raw_data_repo="ssh://p-dune-raw-data@cdcvs.fnal.gov/cvs/projects/dune-raw-data"
269 dune_raw_data_repo="http://cdcvs.fnal.gov/projects/dune-raw-data"
272 if ! $bad_network; then
275 mrb gitCheckout $dune_raw_data_checkout_arg $dune_raw_data_repo
277 if [[ "$?" != "0" ]]; then
278 echo "Unable to perform checkout of $dune_raw_data_repo"
284 sed -i -r '/^defaultqual/s/online/nu/' $Base/srcs/dune_raw_data/ups/product_deps
286 ARTDAQ_DEMO_DIR=$Base/srcs/dune_raw_data
288 cat >setupDUNERAWDATA <<-EOF
289 echo # This script is intended to be sourced.
291 sh -c "[ \`ps \$\$ | grep bash | wc -l\` -gt 0 ] || { echo 'Please switch to the bash shell before running dune-raw-data.'; exit; }" || exit
292 source $Base/products/setup
293 source $dune_repo/setup
295 if [[ -e $larsoft_repo ]]; then
296 source $larsoft_repo/setup
300 source $localproducts_setup
303 export DAQ_INDATA_PATH=$ARTDAQ_DEMO_DIR/test/Generators:$ARTDAQ_DEMO_DIR/inputData
305 export DUNERAWDATA_BUILD=$MRB_BUILDDIR/dune_raw_data
306 export DUNERAWDATA_REPO="$ARTDAQ_DEMO_DIR"
307 setup TRACE $TRACE_version
308 setup art $art_version -q ${equalifier}:${build_type}
309 setup artdaq_core $artdaq_core_version -q ${equalifier}:${build_type}:${squalifier}
315 source $dune_repo/setup
316 source $Base/products/setup
322 setup TRACE $TRACE_version
323 setup art $art_version -q ${equalifier}:${build_type}
324 setup artdaq_core $artdaq_core_version -q ${equalifier}:${build_type}:${squalifier}
327 export CETPKG_J=$((`cat /proc/cpuinfo|grep processor|tail -1|awk '{print $3}'` + 1))
328 mrb build # VERBOSE=1
331 if [ $installStatus -eq 0 ]; then
332 echo "dune-raw-data has been installed correctly."
335 echo "Build error. If all else fails, try (A) logging into a new terminal and (B) creating a new directory out of which to run this script."
341 echo "Build start time: $starttime"
342 echo "Build end time: $endtime"