From 220bddbc07cfe20490625f0e886e62a62361d0b9 Mon Sep 17 00:00:00 2001
From: Andrea Valassi <andrea.valassi@cern.ch>
Date: Thu, 11 Jul 2019 19:30:08 +0200
Subject: [PATCH] Fix immediate filaure on copy_cvmfs failure (BMK-15)

---
 build-executor/main.sh | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/build-executor/main.sh b/build-executor/main.sh
index 0a9df130..e5882d8e 100755
--- a/build-executor/main.sh
+++ b/build-executor/main.sh
@@ -205,16 +205,20 @@ function copy_cvmfs(){
   echo "[copy_cvmfs] ................................................"
   echo "[copy_cvmfs] starting at $(date)"
   echo "[copy_cvmfs] current directory is $(pwd)"
-  fail "[copy_cvmfs] TEST IMMEDIATE EXIT BMK-15"
   echo "[copy_cvmfs] remove ${MAIN_CVMFSEXPORTDIR}/cvmfs/.data" # this is a _very_ large (and useless?) directory produced by cvmfs_shrinkwrap
   ###rm -rf ${MAIN_CVMFSEXPORTDIR}/cvmfs/.data # this is slow, rsync is faster (https://unix.stackexchange.com/a/79656)
   cd ${MAIN_CVMFSEXPORTDIR}/cvmfs; mkdir EMPTYDIR; rsync -a --delete EMPTYDIR/ .data || fail "[copy_cvmfs] rsync"; cd - # NB for rsync, add a trailing "/" to the source and none to the target
   date
-  [[ -e $MAIN_HEPWLBUILDDIR/cvmfs ]] && echo "[copy_cvmfs] removing cvmfs dir in $MAIN_HEPWLBUILDDIR/" && rm -rf $MAIN_HEPWLBUILDDIR/cvmfs
+  if [ -e $MAIN_HEPWLBUILDDIR/cvmfs ]; then
+    echo "[copy_cvmfs] removing cvmfs dir in $MAIN_HEPWLBUILDDIR/"
+    rm -rf $MAIN_HEPWLBUILDDIR/cvmfs
+  fi
   echo "[copy_cvmfs] mv ${MAIN_CVMFSEXPORTDIR}/cvmfs $MAIN_HEPWLBUILDDIR "
   mv ${MAIN_CVMFSEXPORTDIR}/cvmfs $MAIN_HEPWLBUILDDIR || fail "[copy_cvmfs] cannot mv ${MAIN_CVMFSEXPORTDIR}/cvmfs $MAIN_HEPWLBUILDDIR"
   # FIXME: if cms repo, need to copy by hand the SITECONF/local, because it's a sym link
-  [[ -e /cvmfs/cms.cern.ch/SITECONF/local ]] && ( cp -r -H /cvmfs/cms.cern.ch/SITECONF/local $MAIN_HEPWLBUILDDIR/cvmfs/cms.cern.ch/SITECONF/ || fail "[copy_cvmfs] cannot cp /cvmfs/cms.cern.ch/SITECONF/local" )
+  if [ -e /cvmfs/cms.cern.ch/SITECONF/local ]; then 
+     cp -r -H /cvmfs/cms.cern.ch/SITECONF/local $MAIN_HEPWLBUILDDIR/cvmfs/cms.cern.ch/SITECONF/ || fail "[copy_cvmfs] cannot cp /cvmfs/cms.cern.ch/SITECONF/local" # BMK-15: do NOT use '.. && ( .. || fail )'
+  fi
   ls $MAIN_HEPWLBUILDDIR/cvmfs
   echo "[copy_cvmfs] finished at $(date)"
   return 0
-- 
GitLab