From 61f9227f67503b084fab63e11537641779f09d1d Mon Sep 17 00:00:00 2001 From: Emily Mabrey <3370875+emabrey@users.noreply.github.com> Date: Sat, 10 Jul 2021 19:47:54 -0400 Subject: [PATCH] Reattempt fixing MacOS build problem related to CPack issue (#198) * Undo non-working Mac OS CI build fix in build_dist.sh * Implement CPack workaround for CMake PR #4769 * Fix typo in scripts/ci/package.sh * Fix typo in scripts/ci/package.sh * Add debug option for hdiutil_repeat.sh * Make reviewer changes * Change typo in package.sh with hdiutil script name. * Change path reference in package.sh to use $PWD. * Add strings to escape path in scripts/ci/package.sh * Fix scripts/ci/macos/repeat_hdiutil.sh * Remove -e option. Don't copy/paste without double checking closely I guess. :neutral_face: * :heavy_dollar_sign: Add dollar signs where appropriate as reviewers pointed out. * Replace until/do contents with easier to read if block. * Cleanup readability of scripts/ci/macos/repeat_hdiutil.sh * Add $wait_before_retry config value * Replace $cmd_string with literal value * Move do onto same line as until. * Minor changes to fix for MacOS CMake builds * Rename variable in scripts/ci/macos/repeat_hdiutil.sh * Use . instead of pwd in package.sh Signed-off-by: Emily Mabrey --- mac/scripts/build_dist.sh | 2 +- scripts/ci/macos/repeat_hdiutil.sh | 20 ++++++++++++++++++++ scripts/ci/package.sh | 1 + 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 scripts/ci/macos/repeat_hdiutil.sh diff --git a/mac/scripts/build_dist.sh b/mac/scripts/build_dist.sh index 4a62f4ca6..7d002d57e 100755 --- a/mac/scripts/build_dist.sh +++ b/mac/scripts/build_dist.sh @@ -205,7 +205,7 @@ cp "${SRCROOT}/Resources/Audacity-DMG-background.png" "${DMG}/.background" ATTACHED=$(hdiutil info | awk "/\/Volumes\/${VOL}/{print \$1}") if [ -n "${ATTACHED}" ] then - #hdiutil detach "${ATTACHED}" + hdiutil detach "${ATTACHED}" fi # Create and mount the image diff --git a/scripts/ci/macos/repeat_hdiutil.sh b/scripts/ci/macos/repeat_hdiutil.sh new file mode 100644 index 000000000..79db88151 --- /dev/null +++ b/scripts/ci/macos/repeat_hdiutil.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash + +((${BASH_VERSION%%.*} >= 4)) || { echo >&2 "$0: Error: Please upgrade Bash."; exit 1; } + +set -uxo pipefail + +max_retry=5 +counter=0 +num_secs_await_retry=1 + +until /usr/bin/hdiutil ""$*"" -debug; do + sleep $num_secs_await_retry + if [[ $counter -eq $max_retry ]]; then + echo "CPack failed despite retry attempts!" + exit 1 + else + echo "Trying CPack hdiutil call again. Try #$counter" + ((counter++)) + fi +done diff --git a/scripts/ci/package.sh b/scripts/ci/package.sh index c3d4ed0fe..7eed1a740 100755 --- a/scripts/ci/package.sh +++ b/scripts/ci/package.sh @@ -9,6 +9,7 @@ cd build if [[ "${OSTYPE}" == msys* && ${GIT_BRANCH} == release* ]]; then # Windows cmake --build . --target innosetup --config "${AUDACITY_BUILD_TYPE}" else + export CPACK_COMMAND_HDIUTIL="./macos/repeat_hdiutil.sh" cpack -C "${AUDACITY_BUILD_TYPE}" --verbose fi