diff --git a/mac/Keyman4MacIM/make-km-dmg.sh b/mac/Keyman4MacIM/make-km-dmg.sh index b79f40e8b48..b6a3ae38f69 100755 --- a/mac/Keyman4MacIM/make-km-dmg.sh +++ b/mac/Keyman4MacIM/make-km-dmg.sh @@ -190,11 +190,17 @@ displayInfo "Detaching \"$WORKING_COPY_OF_IMAGE\"" # because macOS may still be working in the folder in the # background DETACH_SUCCESS=0 +DETACH_FORCE= while (( DETACH_SUCCESS < 10 )); do - hdiutil detach $STAGING_DIR $VERBOSITY - if [[ $? != 0 || -d "$STAGING_DIR" ]] ; then + DETACH_RESULT=0 + hdiutil detach $STAGING_DIR $VERBOSITY $DETACH_FORCE || DETACH_RESULT=$? + if [[ $DETACH_RESULT != 0 || -d "$STAGING_DIR" ]] ; then (( DETACH_SUCCESS++ )) echo "Failed to unmount: \"$STAGING_DIR\" on attempt #$DETACH_SUCCESS. Waiting 5 seconds to try again." + if (( DETACH_SUCCESS > 5 )); then + echo " Note: Detach failed first five times, so now attempting with '-force'" + DETACH_FORCE=-force + fi sleep 5 else DETACH_SUCCESS=999