Skip to content

Commit

Permalink
Merge pull request #10201 from keymanapp/chore/mac/10200-force-detach
Browse files Browse the repository at this point in the history
chore(mac): force detach of disk image during build after 5 failures
  • Loading branch information
mcdurdin authored Dec 11, 2023
2 parents c945b20 + 473bc48 commit a2fd411
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions mac/Keyman4MacIM/make-km-dmg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a2fd411

Please sign in to comment.