diff --git a/DATA/tools/epn/gen_topo_o2dpg.sh b/DATA/tools/epn/gen_topo_o2dpg.sh index 03a236f20..63b0cb22b 100755 --- a/DATA/tools/epn/gen_topo_o2dpg.sh +++ b/DATA/tools/epn/gen_topo_o2dpg.sh @@ -82,14 +82,26 @@ while true; do break fi fi - if [[ ! -d O2DPG ]]; then git clone https://github.com/AliceO2Group/O2DPG.git 1>&2 || { echo O2DPG checkout failed 1>&2; exit 1; }; fi - cd O2DPG - git checkout $GEN_TOPO_SOURCE &> /dev/null - if [[ $? != 0 ]]; then - git fetch --tags origin 1>&2 || { echo Repository update failed 1>&2; exit 1; } - git checkout $GEN_TOPO_SOURCE &> /dev/null || { echo commit does not exist 1>&2; exit 1; } - fi - git reset --hard $GEN_TOPO_SOURCE &> /dev/null || { echo git reset error 1>&2; exit 1; } + CHECKOUTATTEMPT=1 + while true; do + if [[ ! -d O2DPG ]]; then git clone https://github.com/AliceO2Group/O2DPG.git 1>&2 || { echo O2DPG checkout failed 1>&2; exit 1; }; fi + cd O2DPG + git checkout $GEN_TOPO_SOURCE &> /dev/null + if [[ $? != 0 ]]; then + git fetch --tags origin 1>&2 || { echo Repository update failed 1>&2; exit 1; } + git checkout $GEN_TOPO_SOURCE &> /dev/null || { echo commit does not exist 1>&2; exit 1; } + fi + git reset --hard $GEN_TOPO_SOURCE &> /dev/null + if [ $? -eq 0 ]; then + break + else + [[ $CHECKOUTATTEMPT -eq 2 ]] && { echo git reset error 1>&2; exit 1; } + echo "First attempt to checkout O2DPG failed. Cleaning up and trying a second time" 1>&2 + CHECKOUTATTEMPT=2 + cd $GEN_TOPO_WORKDIR || { echo Cannot enter work dir 1>&2; exit 1; } + rm -rf O2DPG + fi + done rm -f DATA/core_dump_* # At a tag, or a detached non-dirty commit, but not on a branch if ! git describe --exact-match --tags HEAD &> /dev/null && ( git symbolic-ref -q HEAD &> /dev/null || ! git diff-index --quiet HEAD &> /dev/null ); then