From 95d1f9d6c1f2274238c21ddfc8d23778b040e626 Mon Sep 17 00:00:00 2001 From: Jehan Date: Thu, 8 Feb 2024 00:43:01 +0100 Subject: [PATCH] build: work around repetitive pacman failures by retrying. MSYS2 pacman gets randomly stuck on Windows/Aarch64. The actual issue is still being investigated by upstream projects, though anyway it's bad for us right now, to the point that there are discussions to remove Aarch64 support from the Windows installer (whereas it just got added recently!) in #10729. This is an attempt to a workaround. Instead of getting stuck forever and waiting until the whole job times out (per Gitlab CI settings), I time-out the pacman command within our script and try again, up to 2 more times. Hopefully one of the calls would succeed. See: https://github.com/msys2/MSYS2-packages/issues/4340 --- build/windows/gitlab-ci/1_build-deps-msys2.sh | 19 +++++++++++--- build/windows/gitlab-ci/2_build-gimp-msys2.sh | 19 +++++++++++--- .../gitlab-ci/3_package-gimp-uni_base.sh | 26 +++++++++++++------ 3 files changed, 48 insertions(+), 16 deletions(-) diff --git a/build/windows/gitlab-ci/1_build-deps-msys2.sh b/build/windows/gitlab-ci/1_build-deps-msys2.sh index 8c2cdcf27ac..1046ab82d0c 100644 --- a/build/windows/gitlab-ci/1_build-deps-msys2.sh +++ b/build/windows/gitlab-ci/1_build-deps-msys2.sh @@ -35,10 +35,21 @@ fi export DEPS_PATH="build/windows/gitlab-ci/all-deps-uni.txt" sed -i "s/DEPS_ARCH_/${MINGW_PACKAGE_PREFIX}-/g" $DEPS_PATH export GIMP_DEPS=`cat $DEPS_PATH` -pacman --noconfirm -S --needed git \ - base-devel \ - ${MINGW_PACKAGE_PREFIX}-toolchain \ - $GIMP_DEPS + +retry=3 +while [ $retry -gt 0 ]; do + : $((--retry)) + timeout 10m pacman --noconfirm -S --needed git \ + base-devel \ + ${MINGW_PACKAGE_PREFIX}-toolchain \ + $GIMP_DEPS && break + echo "MSYS2 pacman timed out. Trying again." +done + +if [ $? -ne 0 ]; then + echo "MSYS2 pacman repeatedly failed. See: https://github.com/msys2/MSYS2-packages/issues/4340" + exit 1 +fi # Clone babl and GEGL (follow master branch) diff --git a/build/windows/gitlab-ci/2_build-gimp-msys2.sh b/build/windows/gitlab-ci/2_build-gimp-msys2.sh index e4f73dc4259..d949f7855d1 100644 --- a/build/windows/gitlab-ci/2_build-gimp-msys2.sh +++ b/build/windows/gitlab-ci/2_build-gimp-msys2.sh @@ -43,9 +43,20 @@ fi export DEPS_PATH="build/windows/gitlab-ci/all-deps-uni.txt" sed -i "s/DEPS_ARCH_/${MINGW_PACKAGE_PREFIX}-/g" $DEPS_PATH export GIMP_DEPS=`cat $DEPS_PATH` -pacman --noconfirm -S --needed base-devel \ - ${MINGW_PACKAGE_PREFIX}-toolchain \ - $GIMP_DEPS + +retry=3 +while [ $retry -gt 0 ]; do + : $((--retry)) + timeout 10m pacman --noconfirm -S --needed base-devel \ + ${MINGW_PACKAGE_PREFIX}-toolchain \ + $GIMP_DEPS && break + echo "MSYS2 pacman timed out. Trying again." +done + +if [ $? -ne 0 ]; then + echo "MSYS2 pacman repeatedly failed. See: https://github.com/msys2/MSYS2-packages/issues/4340" + exit 1 +fi # Install QOI header manually # mingw32 package of qoi was removed from MSYS2, we have download it by ourselves @@ -145,4 +156,4 @@ if [[ "$BUILD_TYPE" == "CI_NATIVE" ]]; then mv "${GIMP_PREFIX}" . else make_cmd local $MSYS2_PREFIX -fi \ No newline at end of file +fi diff --git a/build/windows/gitlab-ci/3_package-gimp-uni_base.sh b/build/windows/gitlab-ci/3_package-gimp-uni_base.sh index 2503759432f..18378686ee1 100644 --- a/build/windows/gitlab-ci/3_package-gimp-uni_base.sh +++ b/build/windows/gitlab-ci/3_package-gimp-uni_base.sh @@ -24,13 +24,23 @@ fi if [[ "$BUILD_TYPE" != "CI_CROSS" ]]; then -# Install the required (pre-built) packages again -export DEPS_PATH="build/windows/gitlab-ci/all-deps-uni.txt" -sed -i "s/DEPS_ARCH_/${MINGW_PACKAGE_PREFIX}-/g" $DEPS_PATH -export GIMP_DEPS=`cat $DEPS_PATH` -pacman --noconfirm -S --needed base-devel \ - ${MINGW_PACKAGE_PREFIX}-toolchain \ - $GIMP_DEPS + # Install the required (pre-built) packages again + export DEPS_PATH="build/windows/gitlab-ci/all-deps-uni.txt" + sed -i "s/DEPS_ARCH_/${MINGW_PACKAGE_PREFIX}-/g" $DEPS_PATH + export GIMP_DEPS=`cat $DEPS_PATH` + retry=3 + while [ $retry -gt 0 ]; do + : $((--retry)) + timeout 10m pacman --noconfirm -S --needed base-devel \ + ${MINGW_PACKAGE_PREFIX}-toolchain \ + $GIMP_DEPS && break + echo "MSYS2 pacman timed out. Trying again." + done + + if [ $? -ne 0 ]; then + echo "MSYS2 pacman repeatedly failed. See: https://github.com/msys2/MSYS2-packages/issues/4340" + exit 1 + fi fi @@ -177,4 +187,4 @@ done libList=$(find ${GIMP_DISTRIB}/lib/ \( -iname '*.dll' -or -iname '*.exe' \)) && libArray=($libList) for lib in "${libArray[@]}"; do python3 build/windows/gitlab-ci/3_package-gimp-uni_dep.py $lib ${GIMP_PREFIX}/ ${MSYS_PREFIX}/ ${GIMP_DISTRIB} --output-dll-list done-dll.list; -done \ No newline at end of file +done