From 9cd70549ca1a4c6e9995708ee24b58e0e7f5b0bd Mon Sep 17 00:00:00 2001 From: George Brancovici Date: Wed, 13 May 2026 13:21:14 -0400 Subject: [PATCH] Fix hdiutil Resource Busy: retry loop + Spotlight indexing prevention Adds .metadata_never_index to staging dir and retries hdiutil create up to 3 times to handle transient "Resource busy" failures from Spotlight/fseventsd locking the source folder. Co-Authored-By: Claude Opus 4.6 (1M context) --- package.sh | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/package.sh b/package.sh index d1cd8abc..f0583931 100755 --- a/package.sh +++ b/package.sh @@ -34,10 +34,23 @@ ln -s /Applications "$STAGING_DIR/Applications" echo "Creating DMG..." hdiutil detach /Volumes/Galaxy -force 2>/dev/null || true rm -f "$DMG_PATH" -hdiutil create -volname "Galaxy" \ - -srcfolder "$STAGING_DIR" \ - -ov -format UDZO \ - "$DMG_PATH" +# Prevent Spotlight/fseventsd from locking the staging dir +touch "$STAGING_DIR/.metadata_never_index" +sleep 1 +for attempt in 1 2 3; do + if hdiutil create -volname "Galaxy" \ + -srcfolder "$STAGING_DIR" \ + -ov -format UDZO \ + "$DMG_PATH"; then + break + fi + if [ "$attempt" -eq 3 ]; then + echo "Error: hdiutil create failed after 3 attempts" + exit 1 + fi + echo "hdiutil failed (attempt $attempt/3), retrying in 3s..." + sleep 3 +done echo "Signing DMG..." codesign --force --sign "$SIGNING_IDENTITY" --timestamp "$DMG_PATH"