diff --git a/packaging/CPackConfig.cmake b/packaging/CPackConfig.cmake index ca371c28e..ba88e2d77 100644 --- a/packaging/CPackConfig.cmake +++ b/packaging/CPackConfig.cmake @@ -14,6 +14,7 @@ set(CPACK_PACKAGE_VERSION_MAJOR "$ENV{VERSION_MAJOR}") set(CPACK_PACKAGE_VERSION_MINOR "$ENV{VERSION_MINOR}") set(CPACK_PACKAGE_VERSION_PATCH "$ENV{VERSION_PATCH}") set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}") +set(CPACK_COMMAND_HDIUTIL "hdiutil_repeat.sh") set(CPACK_INSTALL_COMMANDS "python package.py -h $ENV{HEXRD_PACKAGE_CHANNEL} -o $ENV{HEXRDGUI_OUTPUT_FOLDER}" ) set(CPACK_INSTALLED_DIRECTORIES "${CMAKE_CURRENT_LIST_DIR}/package;/") diff --git a/packaging/hdiutil_repeat.sh b/packaging/hdiutil_repeat.sh new file mode 100755 index 000000000..901b7910e --- /dev/null +++ b/packaging/hdiutil_repeat.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash + +# Workaround XProtect race condition for "hdiutil create" for MacOS 13 + +if [ "$1" != "create" ]; then + # If it isn't an `hdiutil create` command, just run and exit normally + exit $(hdiutil "$@") +fi + +# For an `hdiutil create` command, try repeatedly, up to 10 times +# This prevents spurious errors caused by a race condition with XProtect +# See https://github.com/actions/runner-images/issues/7522 +i=0 +until +hdiutil "$@" +do +if [ $i -eq 10 ]; then exit 1; fi +i=$((i+1)) +sleep 1 +done