From 619551ed8a68b6f9d5cedd08cc67945150cc9d9d Mon Sep 17 00:00:00 2001 From: Ben Soares Date: Wed, 11 Sep 2024 11:21:07 +0100 Subject: [PATCH] JAL-4428 Fixes to -z's and mktemp --- utils/osx_signing/sign_and_staple_dmg.sh | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/utils/osx_signing/sign_and_staple_dmg.sh b/utils/osx_signing/sign_and_staple_dmg.sh index b8b85ae..db3e07b 100755 --- a/utils/osx_signing/sign_and_staple_dmg.sh +++ b/utils/osx_signing/sign_and_staple_dmg.sh @@ -1,9 +1,12 @@ #!/usr/bin/env bash +# some defaults +ARG_D="Developer ID" +ARG_G="~/uod-development/jalview-builds/git/jalview" # These are the defaults if neither env vars or command line option are set -[ -z $GITDIR ] && GITDIR="~/uod-development/jalview-builds/git/jalview" -[ -z $DEVELOPERID ] && DEVELOPERID="Developer ID" -[ -z $JVER ] && JVER="8" +[ -z "$GITDIR" ] && GITDIR="$ARG_G" +[ -z "$DEVELOPERID" ] && DEVELOPERID="$ARG_D" +[ -z "$JVER" ] && JVER="8" TMP="/tmp" TMPDMG="signingDMG" TESTARCH="|x64|aarch64|" @@ -231,7 +234,11 @@ else echo "DMG disk image file '$DMGFILE' doesn't exist" exit 9 fi - TEMPDIR=$(mktemp -d -p "${TMP}" -t "${DMGNAMELC}") + TEMPDIR="$(mktemp -d -p "${TMP}" "${DMGNAMELC}.XXXXXXXXXX")" + if [ -z "$TEMPDIR" ]; then + echo "Could not formulate a temp dir" + exit 30 + fi DMGDIR=$(dirname "$DMGFILE") fi @@ -382,7 +389,7 @@ if [ "$CLEANUP" = 1 ]; then fi MOUNTROOT="${TEMPDIR}/Volume" -mkdir -p "$MOUNTROOT" +mkdir -p "$MOUNTROOT" || myexit "Could not create mount root dir '${MOUNTROOT}'" 31 myecho "* Mounting disk image '${DMGFILE}' in '${MOUNTROOT}'" mycommand 1 hdiutil attach $HDIUTILV -mountroot "${MOUNTROOT}" "${DMGFILE}" || myexit "Could not mount '${DMGFILE}' in '${MOUNTROOT}'. Aborting." 10 @@ -444,10 +451,10 @@ APPNAME="$FOUNDAPPNAME" myecho "* Copying '${VOLDIR}' to '${TEMPDMGDIR}'" mycommand 1 ditto "$VOLDIR" "$TEMPDMGDIR" -myecho "* Unmounting '${VOLDIR}' and removing '${TEMPDIR}/Volume'" +myecho "* Unmounting '${VOLDIR}' and removing '$MOUNTROOT" mycommand 1 hdiutil detach $HDIUTILV "$VOLDIR" mydetached "$VOLDIR" -rmdir "${TEMPDIR}/Volume" +rmdir "$MOUNTROOT" || myecho "Could not remove mount rood dir '$MOUNTROOT'. Continuing, but you might want to clean up with 'rmdir \"${MOUNTROOT}\"' or use the -C option." APPPATH="${TEMPDMGDIR}/${APPNAME}.app" -- 1.7.10.2