3 # build lariatsoft, lariatutil and lbne_raw_data
     5 # designed to work on Jenkins
     6 # this is a proof of concept script
     8 echo "lariatsoft version: $LARIAT"
     9 echo "base qualifiers: $QUAL"
    10 echo "larsoft qualifiers: $LARSOFT_QUAL"
    11 echo "build type: $BUILDTYPE"
    12 echo "workspace: $WORKSPACE"
    14 # Don't do ifdh build on macos.
    16 #if uname | grep -q Darwin; then
    17 #  if ! echo $QUAL | grep -q noifdh; then
    18 #    echo "Ifdh build requested on macos.  Quitting."
    23 # Get number of cores to use.
    25 if [ `uname` = Darwin ]; then
    26   #ncores=`sysctl -n hw.ncpu`
    27   #ncores=$(( $ncores / 4 ))
    30   ncores=`cat /proc/cpuinfo 2>/dev/null | grep -c -e '^processor'`
    32 if [ $ncores -lt 1 ]; then
    35 echo "Building using $ncores cores."
    37 # Environment setup, uses /grid/fermiapp or cvmfs.
    39 #echo "ls /cvmfs/lariat.opensciencegrid.org/products/lariat/"
    40 #ls /cvmfs/lariat.opensciencegrid.org/products/lariat/
    43 if [ -f /grid/fermiapp/lariat/setup_lariat.sh ]; then
    44   source /grid/fermiapp/lariat/setup_lariat.sh || exit 1
    46   echo "No setup file found."
    49 # skip around a version of mrb that does not work on macOS
    51 if [ `uname` = Darwin ]; then
    52   if [[ x`which mrb | grep v1_17_02` != x ]]; then
    54     setup mrb v1_16_02 || exit 1
    58 # Use system git on macos.
    60 if ! uname | grep -q Darwin; then
    63 setup gitflow || exit 1
    64 export MRB_PROJECT=lariat
    69 rm -rf $WORKSPACE/temp || exit 1
    70 mkdir -p $WORKSPACE/temp || exit 1
    71 mkdir -p $WORKSPACE/copyBack || exit 1
    72 rm -f $WORKSPACE/copyBack/* || exit 1
    73 cd $WORKSPACE/temp || exit 1
    74 mrb newDev -v $LARIAT -q $QUAL:$BUILDTYPE || exit 1
    77 source localProducts*/setup || exit 1
    79 # some shenanigans so we can use getopt v1_1_6
    80 if [ `uname` = Darwin ]; then
    82 #  curl --fail --silent --location --insecure -O http://scisoft.fnal.gov/scisoft/packages/getopt/v1_1_6/getopt-1.1.6-d13-x86_64.tar.bz2 || \
    84 #ERROR: pull of http://scisoft.fnal.gov/scisoft/packages/getopt/v1_1_6/getopt-1.1.6-d13-x86_64.tar.bz2 failed
    88 #  tar xf getopt-1.1.6-d13-x86_64.tar.bz2 || exit 1
    89   setup getopt v1_1_6  || exit 1
    94 cd $MRB_SOURCE  || exit 1
    95 # make sure we get a read-only copy
    96 mrb g -r -t $LARIAT lariatsoft || exit 1
    98 # Extract lariatutil version from lariatsoft product_deps
    99 lariatutil_version=`grep lariatutil $MRB_SOURCE/lariatsoft/ups/product_deps | grep -v qualifier | awk '{print $2}'`
   100 echo "lariatuitil version: $lariatutil_version"
   101 mrb g -d lariatutil -t $lariatutil_version http://cdcvs.fnal.gov/projects/lardbt-lariatutil/ || exit 1
   103 # Extract lariatfragments version from lariatsoft product_deps
   104 lariatfragments_version=`grep lariatfragments $MRB_SOURCE/lariatsoft/ups/product_deps | grep -v qualifier | awk '{print $2}'`
   105 echo "ubuitil version: $lariatfragments_version"
   106 mrb g -d lariatfragments -t $lariatfragments_version http://cdcvs.fnal.gov/projects/lariat-online-lariatfragments/ || exit 1
   108 cd $MRB_BUILDDIR || exit 1
   110 mrb b -j$ncores || exit 1
   111 mrb mp -n lariat -- -j$ncores || exit 1
   113 manifest=lariat-*_MANIFEST.txt
   115 if echo $QUAL | grep -q nobeam; then
   118 # add LariatBeamFiles to the manifest
   119 # currently does not exist on scisoft
   120     LariatBeamFiles_version=`grep LariatBeamFiles $MRB_SOURCE/lariatsoft/ups/product_deps | grep -v qualifier | awk '{print $2}'`
   121     LariatBeamFiles_dot_version=`echo ${LariatBeamFiles_version} | sed -e 's/_/./g' | sed -e 's/^v//'`
   122 #    echo "LariatBeamFiles      ${LariatBeamFiles_version}          LariatBeamFiles-${LariatBeamFiles_dot_version}-noarch.tar.bz2" >>  $manifest
   125 LariatFilters_version=`grep LariatFilters $MRB_SOURCE/lariatsoft/ups/product_deps | grep -v qualifier | awk '{print $2}'`
   126 LariatFilters_dot_version=`echo ${LariatFilters_version} | sed -e 's/_/./g' | sed -e 's/^v//'`
   127 echo "LariatFilters        ${LariatFilters_version}          LariatFilters-${LariatFilters_dot_version}-noarch.tar.gz" >>  $manifest
   129 # Extract larsoft version from product_deps.
   131 larsoft_version=`grep larsoft $MRB_SOURCE/lariatsoft/ups/product_deps | grep -v qualifier | awk '{print $2}'`
   132 larsoft_dot_version=`echo ${larsoft_version} |  sed -e 's/_/./g' | sed -e 's/^v//'`
   137 if uname | grep -q Darwin; then
   143 # Construct name of larsoft manifest.
   145 larsoft_hyphen_qual=`echo $LARSOFT_QUAL | tr : - | sed 's/-noifdh//'`
   146 larsoft_manifest=larsoft-${larsoft_dot_version}-${flvr}-${larsoft_hyphen_qual}-${BUILDTYPE}_MANIFEST.txt
   147 echo "Larsoft manifest:"
   148 echo $larsoft_manifest
   151 # Fetch laraoft manifest from scisoft and append to lariatsoft manifest.
   153 curl --fail --silent --location --insecure http://scisoft.fnal.gov/scisoft/bundles/larsoft/${larsoft_version}/manifest/${larsoft_manifest} >> $manifest || exit 1
   155 # Special handling of noifdh builds goes here.
   157 if echo $QUAL | grep -q noifdh; then
   159   if uname | grep -q Darwin; then
   161     # If this is a macos build, then rename the manifest to remove noifdh qualifier in the name
   163     noifdh_manifest=`echo $manifest | sed 's/-noifdh//'`
   164     mv $manifest $noifdh_manifest
   168     # Otherwise (for slf builds), delete the manifest entirely.
   177 mv *.bz2  $WORKSPACE/copyBack/ || exit 1
   178 manifest=lariat-*_MANIFEST.txt
   179 if [ -f $manifest ]; then
   180   mv $manifest  $WORKSPACE/copyBack/ || exit 1
   182 #cp $MRB_BUILDDIR/lariatsoft/releaseDB/*.html $WORKSPACE/copyBack/
   183 ls -l $WORKSPACE/copyBack/
   184 cd $WORKSPACE || exit 1
   185 rm -rf $WORKSPACE/temp || exit 1