Skip to content

Commit

Permalink
Repeat "hdiutil create" commands to avoid failures
Browse files Browse the repository at this point in the history
Race conditions with XProtect on macos-13 can cause spurious failures
for `hdiutil create` commands.

As a work-around, try the `hdiutil create` command several times (up
to 10), and only fail if the command fails each time.

Signed-off-by: Patrick Avery <[email protected]>
  • Loading branch information
psavery committed Dec 17, 2024
1 parent 44f2a63 commit 0a072b1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions packaging/CPackConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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;/")

Expand Down
20 changes: 20 additions & 0 deletions packaging/hdiutil_repeat.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 0a072b1

Please sign in to comment.