From e3e6d56846047bb2783dd5e252e2ce87895689fb Mon Sep 17 00:00:00 2001 From: Dmitry Vedenko Date: Wed, 28 Jul 2021 15:35:52 +0300 Subject: [PATCH] Add a wrapper that retries `hdiutil` with progressive timeout This seems to be a common workaround for CPack issue on macOS. Script has 10 attempts and in the worst case it will take 55 seconds for it to fail. --- cmake-proxies/cmake-modules/Package.cmake | 2 ++ scripts/build/macOS/hdiutil_wrapper.sh | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100755 scripts/build/macOS/hdiutil_wrapper.sh diff --git a/cmake-proxies/cmake-modules/Package.cmake b/cmake-proxies/cmake-modules/Package.cmake index f6bfed833..65c977e04 100644 --- a/cmake-proxies/cmake-modules/Package.cmake +++ b/cmake-proxies/cmake-modules/Package.cmake @@ -49,6 +49,8 @@ if(CMAKE_SYSTEM_NAME MATCHES "Linux") elseif( CMAKE_SYSTEM_NAME STREQUAL "Darwin" ) set( CPACK_GENERATOR DragNDrop ) + set( CPACK_COMMAND_HDIUTIL "${CMAKE_SOURCE_DIR}/scripts/build/macOS/hdiutil_wrapper.sh" ) + set( CPACK_DMG_BACKGROUND_IMAGE "${CMAKE_SOURCE_DIR}/mac/Resources/Audacity-DMG-background.png") set( CPACK_DMG_DS_STORE_SETUP_SCRIPT "${CMAKE_SOURCE_DIR}/scripts/build/macOS/DMGSetup.scpt") diff --git a/scripts/build/macOS/hdiutil_wrapper.sh b/scripts/build/macOS/hdiutil_wrapper.sh new file mode 100755 index 000000000..9f7fc711c --- /dev/null +++ b/scripts/build/macOS/hdiutil_wrapper.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +# A special wrapper for hdiutil, that retries hdiutil call with +# the progressive timeout. +# This seems to be the common workaround for the CPack problem + +counter=0 +max_retries=10 + +hdiutil $@ + +while [ $? -ne 0 ]; do + ((counter++)) + + if [[ $counter -eq $max_retries ]]; then + exit 1 + fi + + sleep $counter + hdiutil $@ +done