Skip to content

Commit

Permalink
cmake: on macOS fix dmg generation race condition
Browse files Browse the repository at this point in the history
  On macOS 13, generation of the dmg distribution file intermidittenly
  fails due to a "hdiutil: create failed - Resource busy" issue. Work
  around this issue by creating a script that repeatedly attempts to
  run hdiutil until success or 15 failures.

  Thank you for contributing to MythTV!

  Please review the checklist below to ensure that your contribution
  to MythTV is ready for review by our developers.

  It is helpful to regularly rebase your pull request to ensure changes
  apply cleanly to the current MythTV development branch.
  • Loading branch information
jhoyt4 committed Feb 5, 2025
1 parent 8961aac commit 28cd6e7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions platform/darwin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down
19 changes: 19 additions & 0 deletions platform/darwin/hdiutil_repeat.zsh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 28cd6e7

Please sign in to comment.