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