From 28cd6e7e2a952b09aeeffa2a5ec20816404c661e Mon Sep 17 00:00:00 2001 From: jhoyt4 Date: Wed, 5 Feb 2025 05:48:16 -0500 Subject: [PATCH] cmake: on macOS fix dmg generation race condition 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. --- platform/darwin/CMakeLists.txt | 1 + platform/darwin/hdiutil_repeat.zsh | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100755 platform/darwin/hdiutil_repeat.zsh 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