From 6d88cdddd0620928541f77cba7471afa5c532c9e Mon Sep 17 00:00:00 2001 From: Ernst Hellbar Date: Tue, 29 Oct 2024 15:58:30 +0100 Subject: [PATCH] protection against corrupt O2DPG repository during topology generation --- DATA/tools/epn/gen_topo_o2dpg.sh | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) 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