3 # pull source code in $WORKSPACE/source
     4 # build in $WORKSPACE/build
     5 # copyback directory is $WORKSPACE/copyBack
    10 Usage: $(basename ${0}) [-h]
    11        env WORKSPACE=<workspace> LARVER=<larsoft version> QUAL=<qualifier> BUILDTYPE=<debug|prof> $(basename ${0})
    21   for label in "${labels[@]}"; do
    22     for wanted in "$@"; do
    23       [[ "${label}" == "${wanted}" ]] && return 0
    29 while getopts :h OPT; do
    40 shift `expr $OPTIND - 1`
    43 working_dir="${WORKSPACE:-$(pwd)}"
    44 version="${1:-${LARVER}}"
    45 qual_set="${2:-${QUAL}}"
    46 build_type="${3:-${BUILDTYPE}}"
    48 oIFS=${IFS}; IFS=:; quals=(${qual_set//-/:}); IFS=$oIFS; unset oIFS
    50 for onequal in "${quals[@]}"; do
    52     e[679]|e1[0-9]|c[0-9])
    55     s7[0-9]|s8[0-9]|s9[0-9])
    71 # create copyBack so artifact copy does not fail on early exit
    72 rm -rf "${working_dir}/copyBack"
    73 mkdir -p "${working_dir}/copyBack" || exit 1
    75 # Find platform flavor.
    77 if [ "${OS}" = "Linux" ]
    80   if [ "${id}" = "Ubuntu" ]
    82     flvr=u`lsb_release -r | sed -e 's/[[:space:]]//g' | cut -f2 -d":" | cut -f1 -d"."`
    84     flvr=slf`lsb_release -r | sed -e 's/[[:space:]]//g' | cut -f2 -d":" | cut -f1 -d"."`
    86 elif [ "${OS}" = "Darwin" ]
    88   flvr=d`uname -r | cut -f1 -d"."`
    98   echo "ERROR: unrecognized operating system ${OS}"
   102 # Check supported builds.
   103 if [[ `uname -s` == Darwin ]]; then
   104   OSnum=`uname -r | cut -f1 -d"."`
   105   xver=`xcodebuild -version | grep Xcode | cut -f2 -d" " | cut -f1 -d"."`
   106   xcver=`xcodebuild -version | grep Xcode`
   107   if { [[ ${basequal} =~ ^e(9$|[1-9][0-9]) ]] && \
   108     [[ ${xver} < 7 ]] && \
   109     [[ ${OSnum} > 13 ]]; }; then
   110     # XCode too old on this platform.
   111     echo "${basequal} build not supported on `uname -s`${OSnum} with ${xcver}"
   112     echo "${basequal} build not supported on `uname -s`${OSnum} with ${xcver}" > \
   113       "${working_dir}/copyBack/skipping_build"
   115   elif { [[ "$basequal" == e* ]] || \
   116     { [[ "$basequal" == c* ]] && (( $OSnum < 15 )); }; }; then
   117     if want_unsupported; then
   118       echo "Building unsupported ${basequal} on `uname -s`${OSnum} due to \$CET_BUILD_UNSUPPORTED=${CET_BUILD_UNSUPPORTED}"
   120       # Don't normally support GCC builds on MacOS.
   121       msg="${basequal} build not supported on `uname -s`${OSnum} -- export CET_BUILD_UNSUPPORTED=1 to override."
   123       echo "$msg" > "${working_dir}/copyBack/skipping_build"
   127   if have_label py2; then
   128     msg="We are not building for Python2 on Darwin."
   130     echo "${msg}" > "${working_dir}/copyBack/skipping_build"
   133 elif [[ "${flvr}" == slf6 ]]; then
   134   if have_label py2; then
   135        echo "Building supported Python2 build on SLF6"
   137     msg="Python3 builds not supported on SLF6."
   139     echo "${msg}" > "${working_dir}/copyBack/skipping_build"
   144 dotver=`echo ${version} | sed -e 's/_/./g' | sed -e 's/^v//'`
   146 echo "building the larbase base distribution for ${version} ${dotver} ${qual_set} ${build_type}"
   148 echo "build flavor is ${flvr}"
   151 qualdir=`echo ${qual_set} | sed -e 's%:%-%'`
   155 blddir=${working_dir}/build
   156 srcdir=${working_dir}/source
   157 # start with clean directories
   160 # now make the dfirectories
   161 mkdir -p ${srcdir} || exit 1
   162 mkdir -p ${blddir} || exit 1
   164 cd ${blddir} || exit 1
   165 curl --fail --silent --location --insecure -O http://scisoft.fnal.gov/scisoft/bundles/tools/buildFW || exit 1
   171 (( ${#labels[@]} > 0 )) && lopt=-l
   172 ./buildFW -t -b ${basequal} \
   173   ${lopt} $(IFS=:; printf '%s' "${labels[*]}") \
   174   ${blddir} ${build_type} lar_product_stack-${version} || \
   175  { mv ${blddir}/*.log  "${working_dir}/copyBack/"
   178 ./buildFW -t -b ${basequal} -s ${squal} \
   179   ${lopt} $(IFS=:; printf '%s' "${labels[*]}") \
   180   ${blddir} ${build_type} larbase-${version} || \
   181  { mv ${blddir}/*.log  "${working_dir}/copyBack/"
   188 # get these out of the way
   189 mv ${blddir}/*source* ${srcdir}/
   190 mv ${blddir}/g*noarch* ${srcdir}/
   191 mv ${blddir}/larsoft_data*.bz2 ${srcdir}/
   193 mv ${blddir}/*.bz2  $WORKSPACE/copyBack/
   194 mv ${blddir}/*.txt  $WORKSPACE/copyBack/