From: Ben Soares Date: Mon, 26 Aug 2024 16:44:30 +0000 (+0100) Subject: JAL-3631 When appdir/jre can't be found, look for the installer.appdir found in insta... X-Git-Tag: Release_2_11_4_0~14^2~8^2~6 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=87ab843ae2e9afa891535b885d49d16ce6d1fce5;p=jalview.git JAL-3631 When appdir/jre can't be found, look for the installer.appdir found in installer.properties (if it exists) and use jre dir in installer.appdir --- diff --git a/utils/getdown/bin/jalview.sh b/utils/getdown/bin/jalview.sh index 95e6fae..04a9144 100755 --- a/utils/getdown/bin/jalview.sh +++ b/utils/getdown/bin/jalview.sh @@ -69,25 +69,43 @@ function readlinkf() { # args for the JVM declare -a JVMARGS=() +JAVABIN="" # set vars for being inside the macos App Bundle if [ "${ISMACOS}" = 1 ]; then # MACOS ONLY SCRIPT="$(readlinkf "$0")" DIR="$(dirname "${SCRIPT}")" APPDIR="${DIR%/bin}" - JAVABIN="${APPDIR}/jre/Contents/Home/bin" - JAVA="${JAVABIN}/java" + + if [ -d "${APPDIR}/jre" ]; then + JREDIR="${APPDIR}/jre" + elif [ -e "${APPDIR}/installer.properties" ]; then + INSTALLERAPPDIR="$( grep -E '^installer.appdir[[:space:]]*=[[:space:]]*' '${APPDIR}/installer.properties' | sed -E 's/^installer.appdir[[:space:]]*=[[:space:]]*//' )" + if [ -d "${INSTALLERAPPDIR}/jre" ]; then + JREDIR="${INSTALLERAPPDIR}/jre" + fi + fi + if [ ! -z "$JREDIR" ]; then + JAVABIN="${JREDIR}/Contents/Home/bin" + fi if [ "${HEADLESS}" != 1 ]; then - JVMARGS=( "${JVMARGS[@]}" "-Xdock:icon=${APPDIR}/resource/jalview_logo.png" ) + JVMARGS=( "${JVMARGS[@]}" "-Xdock:icon=${APPDIR}/resource/jalview_logo.png" ) fi else # NOT MACOS SCRIPT="$(readlink -f "$0")" DIR="$(dirname "${SCRIPT}")" APPDIR="${DIR%/bin}" - JAVABIN="${APPDIR}/jre/bin" - JAVA="${JAVABIN}/java" + if [ -d "${APPDIR}/jre" ]; then + JAVABIN="${APPDIR}/jre/bin" + elif [ -e "${APPDIR}/installer.properties" ]; then + INSTALLERAPPDIR="$( grep -E "^installer.appdir[[:space:]]*=[[:space:]]*" "${APPDIR}/installer.properties" | sed -E 's/^installer.appdir[[:space:]]*=[[:space:]]*//' )" + if [ ! -z "$INSTALLERAPPDIR" -a -d "${INSTALLERAPPDIR}/jre" ]; then + JAVABIN="${INSTALLERAPPDIR}/jre/bin" + fi + fi fi +JAVA="${JAVABIN}/java" # headless java arguments if [ "${HEADLESS}" = 1 ]; then @@ -111,7 +129,7 @@ CLASSPATH="" declare -a JARPATHS=() # look for getdown.txt -- needed to create classpath -if [ \! -e "${GETDOWNTXT}" ]; then +if [ ! -e "${GETDOWNTXT}" ]; then echo "Cannot find ${GETDOWNTXT}" >&2 exit 3 fi @@ -183,11 +201,11 @@ if [ "${ISMACOS}" != 1 ]; then # older macos doesn't like uname -o, best to avoi fi # look for bundled JRE. Might not be there if unix installer used in which case just invoke "java" -if [ -e "${JAVABIN}/${NAME}${JAVAEXT}" ]; then +if [ ! -z "${JAVABIN}" -a -e "${JAVABIN}/${NAME}${JAVAEXT}" ]; then JAVA="${JAVABIN}/${NAME}${JAVAEXT}" fi # If not just try one in the PATH (we need .exe in WSL, added above) -if [ \! -e "${JAVA}" ]; then +if [ -z "${JAVABIN}" -o ! -e "${JAVA}" ]; then JAVA="${SYSJAVA}" echo "Cannot find bundled ${JAVA}, using system ${SYSJAVA} and hoping for the best!" >&2 fi @@ -196,7 +214,7 @@ fi function quotearray() { QUOTEDVALS="" for VAL in "${@}"; do - if [ \! "$QUOTEDVALS" = "" ]; then + if [ ! "$QUOTEDVALS" = "" ]; then QUOTEDVALS="${QUOTEDVALS} " fi QUOTEDVALS="${QUOTEDVALS}\"${VAL}\""