All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
build-larsoftobj.sh
Go to the documentation of this file.
1 #!/bin/bash
2 
3 # pull source code in ${working_dir}/source
4 # build in ${working_dir}/build
5 # copyback directory is ${working_dir}/copyBack
6 
8 {
9  cat 1>&2 <<EOF
10 Usage: $(basename ${0}) [-h]
11  env WORKSPACE=<workspace> LVER=<larsoftobj version> QUAL=<qualifier> BUILDTYPE=<debug|prof> $(basename ${0})
12  $(basename ${0}) <version> <qual_set> <build_type>
13 
14 Options:
15 
16  -h This help.
17 
18 EOF
19 }
20 
22  for label in "${labels[@]}"; do
23  for wanted in "$@"; do
24  [[ "${label}" == "${wanted}" ]] && return 0
25  done
26  done
27  return 1
28 }
29 
30 
31 while getopts :h OPT; do
32  case ${OPT} in
33  h)
34  usage
35  exit 1
36  ;;
37  *)
38  usage
39  exit 1
40  esac
41 done
42 shift `expr $OPTIND - 1`
44 
45 working_dir="${WORKSPACE:-$(pwd)}"
46 version="${1:-${LVER}}"
47 qual_set="${2:-${QUAL}}"
48 oIFS=${IFS}; IFS=:; quals=(${qual_set//-/:}); IFS=$oIFS; unset oIFS
49 build_type="${3:-${BUILDTYPE}}"
50 
51 labels=()
52 for onequal in "${quals[@]}"; do
53  if [[ "${onequal}" =~ ^([ec])([0-9]+)$ ]]; then
54  basequal=${onequal}
55  elif [[ "${onequal}" =~ ^(s)([1-9][0-9]+)$ ]]; then
56  squal=${onequal}
57  else
58  labels+=${onequal}
59  fi
60 done
61 
62 case ${build_type} in
63  debug) qflag="-d" ;;
64  prof) qflag="-p" ;;
65  *)
66  usage
67  exit 1
68 esac
69 
70 # create copyBack so artifact copy does not fail on early exit
71 rm -rf "${working_dir}/copyBack"
72 mkdir -p "${working_dir}/copyBack" || exit 1
73 
74 # Find platform flavor.
75 OS=`uname`
76 if [ "${OS}" = "Linux" ]
77 then
78  id=`lsb_release -is`
79  if [ "${id}" = "Ubuntu" ]
80  then
81  flvr=u`lsb_release -r | sed -e 's/[[:space:]]//g' | cut -f2 -d":" | cut -f1 -d"."`
82  else
83  flvr=slf`lsb_release -r | sed -e 's/[[:space:]]//g' | cut -f2 -d":" | cut -f1 -d"."`
84  fi
85 elif [ "${OS}" = "Darwin" ]
86 then
87  flvr=d`uname -r | cut -f1 -d"."`
88  # set locale
89  echo
90  locale
91  echo
92  export LANG=C
93  export LC_ALL=$LANG
94  locale
95  echo
96 else
97  echo "ERROR: unrecognized operating system ${OS}"
98  exit 1
99 fi
100 
101 # Check supported builds.
102 if [[ `uname -s` == Darwin ]]; then
103  OSnum=`uname -r | cut -f1 -d"."`
104  xver=`xcodebuild -version | grep Xcode | cut -f2 -d" " | cut -f1 -d"."`
105  xcver=`xcodebuild -version | grep Xcode`
106  if { [[ ${basequal} =~ ^e(9$|[1-9][0-9]) ]] && \
107  [[ ${xver} < 7 ]] && \
108  [[ ${OSnum} > 13 ]]; }; then
109  # XCode too old on this platform.
110  echo "${basequal} build not supported on `uname -s`${OSnum} with ${xcver}"
111  echo "${basequal} build not supported on `uname -s`${OSnum} with ${xcver}" > \
112  "${working_dir}/copyBack/skipping_build"
113  exit 0
114  elif { [[ "$basequal" == e* ]] || \
115  { [[ "$basequal" == c* ]] && (( $OSnum < 15 )); }; }; then
116  if want_unsupported; then
117  echo "Building unsupported ${basequal} on `uname -s`${OSnum} due to \$CET_BUILD_UNSUPPORTED=${CET_BUILD_UNSUPPORTED}"
118  else
119  # Don't normally support GCC builds on MacOS.
120  msg="${basequal} build not supported on `uname -s`${OSnum} -- export CET_BUILD_UNSUPPORTED=1 to override."
121  echo "$msg"
122  echo "$msg" > "${working_dir}/copyBack/skipping_build"
123  exit 0
124  fi
125  fi
126  if have_label py2; then
127  msg="We are not building for Python2 on Darwin."
128  echo "${msg}"
129  echo "${msg}" > "${working_dir}/copyBack/skipping_build"
130  exit 0
131  fi
132 elif [[ "${flvr}" == slf6 ]]; then
133  if have_label py2; then
134  echo "Building for supported Python2 on SLF6"
135  else
136  msg="Python3 builds not supported on SLF6."
137  echo "${msg}"
138  echo "${msg}" > "${working_dir}/copyBack/skipping_build"
139  exit 0
140  fi
141 fi
142 
143 dotver=`echo ${version} | sed -e 's/_/./g' | sed -e 's/^v//'`
144 
145 echo "building the larsoftobj distribution for ${version} ${dotver} ${qual_set} ${build_type}"
146 echo "build flavor is ${flvr}"
147 echo ""
148 
149 qualdir=`echo ${qual_set} | sed -e 's%:%-%'`
150 
151 set -x
152 
153 blddir=${working_dir}/build
154 srcdir=${working_dir}/source
155 # start with clean directories
156 rm -rf ${blddir}
157 rm -rf ${srcdir}
158 # now make the dfirectories
159 mkdir -p ${srcdir} || exit 1
160 mkdir -p ${blddir} || exit 1
161 
162 cd ${blddir} || exit 1
163 curl --fail --silent --location --insecure -O http://scisoft.fnal.gov/scisoft/bundles/tools/buildFW || exit 1
164 chmod +x buildFW
165 
166 cd ${blddir} || exit 1
167 echo
168 echo "begin build"
169 echo
170 (( ${#labels[@]} > 0 )) && lopt=-l
171 ./buildFW -t -b ${basequal} \
172  ${lopt} $(IFS=:; printf '%s' "${labels[*]}") \
173  ${blddir} ${build_type} larsoftobj-${version} || \
174  { mv ${blddir}/*.log "${working_dir}/copyBack/"
175  exit 1
176  }
177 
178 echo
179 echo "move files"
180 echo
181 # get these out of the way
182 mv ${blddir}/*source* ${srcdir}/
183 #
184 mv ${blddir}/*.bz2 $WORKSPACE/copyBack/
185 mv ${blddir}/*.txt $WORKSPACE/copyBack/
186 rm -rf ${srcdir}
187 rm -rf ${blddir}
188 
189 exit 0
* labels
*usage exit esac done shift expr $OPTIND OPTIND
process_name opflash particleana ie x
then cvmfs grid cern ch util cvmfs uptodate cvmfs uboone opensciencegrid org products fi source cvmfs uboone opensciencegrid org products setup_uboone sh exit else echo No setup file found exit fi if!uname grep q Darwin
Definition: build_larcv.sh:51
do source
pdgs p
Definition: selectors.fcl:22
then source cvmfs dune opensciencegrid org products dune setup_dune sh exit elif[-f/grid/fermiapp/products/dune/setup_dune_fermiapp.sh]
have_label()
shift
Definition: fcl_checks.sh:26
usage
Definition: doGit.sh:21
then flvr
Definition: buildSBND.sh:128
while getopts
while getopts h
prof qflag
then shift fi
do cd
then basequal
Definition: buildUboone2.sh:26
do case in h help echo Usage
Definition: file_to_url.sh:42
then QUAL
if &&[-z"$BASH_VERSION"] then echo Attempting to switch to bash bash shellSwitch exit fi &&["$1"= 'shellSwitch'] shift declare a IncludeDirectives for Dir in
then echo File list $list not found else cat $list while read file do echo $file sed s
Definition: file_to_url.sh:60
do i e
T copy(T const &v)
s7[0-9] s8[0-9] s9[0-9] squal
esac echo uname r