#!/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|"
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
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
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"