From 6b7728bf7b7dff99e4f9daef00f7cea7c834c105 Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Thu, 21 Aug 2025 12:05:53 +0200 Subject: [PATCH] .github: win32: several retries on git clones The mingw32 build job often fails due frequent temporary problems on cloning vom savannah. Retry several times, hoping to fix it. Signed-off-by: Enrico Weigelt, metux IT consult --- .../scripts/mingw32/cross-prereqs-build.sh | 44 ++++++++++++++++--- 1 file changed, 37 insertions(+), 7 deletions(-) diff --git a/.github/scripts/mingw32/cross-prereqs-build.sh b/.github/scripts/mingw32/cross-prereqs-build.sh index c08fdcdbc4..bb125933f7 100755 --- a/.github/scripts/mingw32/cross-prereqs-build.sh +++ b/.github/scripts/mingw32/cross-prereqs-build.sh @@ -20,6 +20,42 @@ chmod +x /usr/local/bin/${HOST}-pkg-config # --enable-malloc0returnsnull export xorg_cv_malloc0_returns_null=yes +die() { + echo "FAILED: $*" >&1 + exit 1 +} + +# retry +retry() { + local max_attempts=$1 + local sleep_time=$2 + shift 2 + + local attempt=1 + while true; do + "$@" && return 0 # success → return immediately + if [ $attempt -ge $max_attempts ]; then + return 1 # failed after all attempts + fi + attempt=$((attempt+1)) + sleep "$sleep_time" + done +} + +try_clone() { + local url="$1" + local commit="$2" + local name="$3" + + if [[ $commit =~ ^[[:xdigit:]]{1,}$ ]] + then + git clone ${url} ${name} || return 1 + git -C ${name} checkout ${commit} || return 1 + else + git clone --depth 1 --branch ${commit:-master} --recurse-submodules -c advice.detachedHead=false ${url} ${name} || return 1 + fi +} + build() { url=$1 commit=$2 @@ -27,13 +63,7 @@ build() { name=$(basename ${url} .git) - if [[ $commit =~ ^[[:xdigit:]]{1,}$ ]] - then - git clone ${url} ${name} - git -C ${name} checkout ${commit} - else - git clone --depth 1 --branch ${commit:-master} --recurse-submodules -c advice.detachedHead=false ${url} ${name} - fi + retry 10 10 try_clone "$url" "$commit" "$name" || die "failed cloning $url - $commit" pushd ${name} NOCONFIGURE=1 ./autogen.sh || ./.bootstrap