From: Ben Soares Date: Mon, 19 Aug 2024 16:08:12 +0000 (+0100) Subject: JAL-3631 Change macos-install-jalview.sh to use ditto instead of rsync. Localise... X-Git-Tag: Release_2_11_4_0~14^2~8^2~8 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=b3aa009895567ae6c7131c2c09aefb7def40fc7a;p=jalview.git JAL-3631 Change macos-install-jalview.sh to use ditto instead of Localise function vars. --- diff --git a/utils/install4j/macos-install-jalview.sh b/utils/install4j/macos-install-jalview.sh index aa9f0fd..9b40271 100755 --- a/utils/install4j/macos-install-jalview.sh +++ b/utils/install4j/macos-install-jalview.sh @@ -232,35 +232,48 @@ hdiutil attach ${HDIUTILOPT} -mountpoint "${VOLUMEDIR}" "${DMGFILE}" VOLUMEFILES=$( ls -1 ${VOLUMEDIR} ) while IFS= read -r VOLUMEFILE; do FILE=$( basename "${VOLUMEFILE}" ) - if [ "${FILE}" != "${FILE#Jalview}" -a "${FILE}" != "${FILE%.app}" ]; then - APP="${FILE}" + if [ "$FILE" != "${FILE#Jalview}" -a "$FILE" != "${FILE%.app}" ]; then + APP="$FILE" break fi done <<< "$VOLUMEFILES" -[ -z "${APP}" ] && echo "Could not find Jalview\*.app in the volume '${VOLUMEDIR}'" && exit 10 +[ -z "$APP" ] && echo "Could not find Jalview\*.app in the volume '${VOLUMEDIR}'" && exit 10 APPNAME=$( basename "$APP" ) # ensure no trailing slash on APPNAME or APPLICATIONFOLDER (important for rsync) -while [ "${APPLICATIONFOLDER}" != "${APPLICATIONFOLDER%/}" -a "${APPLICATIONFOLDER}" != "/" ]; do +while [ "${APPLICATIONFOLDER}" != "/" ]; do APPLICATIONFOLDER=${APPLICATIONFOLDER%/} done while [ "${APPNAME}" != "${APPNAME%/}" ]; do APPNAME=${APPNAME%/} done -[ -z "${APPNAME}" ] && echo "Could not find suitable Jalview\*.app in the volume '${VOLUMEDIR}'" && exit 11 - -# rsync .app from mounted volume to application folder -myecho "Rsyncing '${VOLUMEDIR}/${APPNAME}' to '${APPLICATIONFOLDER}/${APPNAME}'" -rsync ${RSYNCOPT} -ah --delete "${VOLUMEDIR}/${APPNAME}" "${APPLICATIONFOLDER}/" -[ $? != 0 ] && echo "Possible problem when rsyncing '${APP}' to '${APPLICATIONFOLDER}'" && exit 12 -myecho "Finished rsync" +[ -z "$APPNAME" -o "${APPNAME%.app}" = "$APPNAME" ] && echo "Could not find suitable Jalview\*.app in the volume '${VOLUMEDIR}'" && exit 11 + +## rsync .app from mounted volume to application folder +#myecho "Rsyncing '${VOLUMEDIR}/${APPNAME}' to '${APPLICATIONFOLDER}/${APPNAME}'" +#rsync ${RSYNCOPT} -ah --delete "${VOLUMEDIR}/${APPNAME}" "${APPLICATIONFOLDER}/" +#[ $? != 0 ] && echo "Possible problem when rsyncing '${APP}' to '${APPLICATIONFOLDER}'" && exit 12 +#myecho "Finished rsync" + +# using ditto +APPPATH="${APPLICATIONFOLDER}/${APPNAME}" +OLDAPPPATH="${APPPATH}.old" +myecho "Copying '${VOLUMEDIR}/${APPNAME}' to '${APPPATH}'" +if [ -e "$APPPATH" ]; then + if [ -e "$OLDAPPPATH" ]; then + rm -Rf "$OLDAPPPATH" + fi + mv "$APPPATH" "$OLDAPPPATH" +fi +ditto "${VOLUMEDIR}/${APPNAME}" "$APPPATH" && [ -e "$OLDAPPPATH" ] && rm -Rf "$OLDAPPPATH" +myecho "Finished copying '${APPNAME}'" EXIT=0 declare -a WARNINGS=() addwarning() { - W=$1 - N=$2 + local W=$1 + local N=$2 myecho "${W}" WARNINGS=( "${WARNINGS[@]}" "${W}" ) # exit with the first warning value