diff --git a/platform/darwin/CMakeLists.txt b/platform/darwin/CMakeLists.txt index 648a9ce0cf5..6489f0e01be 100644 --- a/platform/darwin/CMakeLists.txt +++ b/platform/darwin/CMakeLists.txt @@ -498,6 +498,7 @@ if(DARWIN_GENERATE_DISTRIBUTION) set(CPACK_INSTALL_PREFIX / ) set(CPACK_PACKAGING_INSTALL_PREFIX "${APP_NAME}.app") set(CPACK_MONOLITHIC_INSTALL TRUE) + set(CPACK_COMMAND_HDIUTIL "${CMAKE_CURRENT_LIST_DIR}/hdiutil_repeat.zsh") # Custom Inputs to Bundle set(CPACK_BUNDLE_NAME ${APP_NAME}) diff --git a/platform/darwin/hdiutil_repeat.zsh b/platform/darwin/hdiutil_repeat.zsh new file mode 100755 index 00000000000..bd795509073 --- /dev/null +++ b/platform/darwin/hdiutil_repeat.zsh @@ -0,0 +1,19 @@ +#!/bin/zsh + +if [ "$1" != "create" ]; then + # run normally in not an `hdiutil create` command + hdiutil "$@" + exit 0 +fi + +# On macOS 13, a race condition may present where hdiutil is unable to +# write to the filesystem during an `hdiutil create` command. Attempt +# to work around this by attempting to build up to 15 times. +COUNTER=0 +until /usr/bin/hdiutil "$@"; do + if [ $i -eq 15 ]; then + exit 1; + fi + let COUNTER+=1 + sleep 2 +done