From: Ben Soares Date: Fri, 26 Jul 2024 16:50:10 +0000 (+0100) Subject: JAL-3631 Added an --update option to the jalview.sh launcher (does not launch, just... X-Git-Tag: Release_2_11_4_0~17^2~3^2~9 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=3768f6ca406a0142e31ed352dba9646140e6b9a3;p=jalview.git JAL-3631 Added an --update option to the jalview.sh launcher (does not launch, just updates). Combining the update script with this as there's a lot of work to make this shell script Linux/macOS/Cygwin/WSL compliant that doesn't need to be duplicated. PS1 still to do. --- diff --git a/src/jalview/bin/Cache.java b/src/jalview/bin/Cache.java index a45fc42..f79c265 100755 --- a/src/jalview/bin/Cache.java +++ b/src/jalview/bin/Cache.java @@ -1309,6 +1309,8 @@ public class Cache System.getProperty("launcher.distdir"), "\n", null); appendIfNotNull(sb, "Launcher appbase: ", System.getProperty("launcher.appbase"), "\n", null); + appendIfNotNull(sb, "Launcher script: ", + System.getProperty("launcher.script"), "\n", null); } return sb.toString(); } diff --git a/utils/getdown/bin/jalview.sh b/utils/getdown/bin/jalview.sh index 90d1558..e2e7599 100755 --- a/utils/getdown/bin/jalview.sh +++ b/utils/getdown/bin/jalview.sh @@ -40,6 +40,7 @@ HEADLESS=0 GUI=0 HELP=0 DEBUG=0 +UPDATE=0 for RAWARG in "${@}"; do ARG="${RAWARG%%=*}" case "${ARG}" in @@ -55,30 +56,40 @@ for RAWARG in "${@}"; do --debug) DEBUG=1 ;; + --update) + UPDATE=1 + ;; esac - - if [ "${HELP}" = 1 ]; then - # --help takes precedence - HEADLESS=1 - GUI=0 - elif [ "${GUI}" = 1 ]; then - # --gui takes precedence over --headless - HEADLESS=0 - fi done +if [ "${HELP}" = 1 ]; then + # --help takes precedence + HEADLESS=1 + GUI=0 +elif [ "${UPDATE}" = 1 ]; then + # --update takes precedence over everything else, we don't run jalview! + HEADLESS=1 + GUI=0 +elif [ "${GUI}" = 1 ]; then + # --gui takes precedence over --headless + HEADLESS=0 +fi declare -a JVMARGS=() # set vars for being inside the macos App Bundle if [ "${ISMACOS}" = 1 ]; then # MACOS ONLY - DIR="$(dirname "$(readlinkf "$0")")" + SCRIPT="$(readlinkf "$0")" + DIR="$(dirname "${SCRIPT}")" APPDIR="${DIR%/bin}" JAVA="${APPDIR}/jre/Contents/Home/bin/java" - JVMARGS=( "${JVMARGS[@]}" "-Xdock:icon=${APPDIR}/resource/jalview_logo.png" ) + if [ "${HEADLESS}" != 1 ]; then + JVMARGS=( "${JVMARGS[@]}" "-Xdock:icon=${APPDIR}/resource/jalview_logo.png" ) + fi else # NOT MACOS - DIR="$(dirname "$(readlink -f "$0")")" + SCRIPT="$(readlink -f "$0")" + DIR="$(dirname "${SCRIPT}")" APPDIR="${DIR%/bin}" JAVA="${APPDIR}/jre/bin/java" fi @@ -96,21 +107,66 @@ fi SYSJAVA=java GETDOWNTXT="${APPDIR}/getdown.txt" +GETDOWNJAR="${APPDIR}/getdown-launcher.jar" CLASSPATH="" # save an array of JAR paths in case we're in WSL (see later) declare -a JARPATHS=() -if [ -e "${GETDOWNTXT}" ]; then - # always check grep and sed regexes on macos -- they're not the same -for JAR in $(grep -e '^code[[:space:]]*=[[:space:]]*' "${GETDOWNTXT}" | while read -r line; do echo $line | sed -E -e 's/code[[:space:]]*=[[:space:]]*//;'; done); - do - [ -n "${CLASSPATH}" ] && CLASSPATH="${CLASSPATH}:" - CLASSPATH="${CLASSPATH}${APPDIR}/${JAR}" - JARPATHS=( "${JARPATHS[@]}" "${APPDIR}/${JAR}" ) - done + +CLASS="jalview.bin.Launcher" # set as default Just In Case +if [ "${UPDATE}" = 1 ]; then + + # JUST RUNNING A GETDOWN INSTALLATION UPDATE, not launching Jalview + CLASS="com.threerings.getdown.launcher.GetdownApp" + if [ -e "${GETDOWNJAR}" ]; then + CLASSPATH="${APPDIR}/${GETDOWNJAR}" + JARPATHS=( "${JARPATHS[@]}" "${APPDIR}/${GETDOWNJAR}" ) + else + echo "Cannot find getdown-launcher.jar to run update" >&2 + exit 13 + fi + + JVMARGS=( "${JVMARGS[@]}" "-Dsilent=true" ) + JVMARGS=( "${JVMARGS[@]}" "-Dnouserdefaultappdir=true" ) + JVMARGS=( "${JVMARGS[@]}" "-Dappid=jalview" ) + JVMARGS=( "${JVMARGS[@]}" "-Dinstaller.appdir=${APPDIR}" ) + + # resetting ARGS to just these two values + ARGS=( "${APPDIR}" "jalview" ) + else - echo "Cannot find getdown.txt" >&2 - exit 3 + + # LAUNCHING JALVIEW without getdown-launcher + CLASS="jalview.bin.Launcher" + if [ -e "${GETDOWNTXT}" ]; then + # always check grep and sed regexes on macos -- they're not the same + for JAR in $(grep -e '^code[[:space:]]*=[[:space:]]*' "${GETDOWNTXT}" | while read -r line; do echo $line | sed -E -e 's/code[[:space:]]*=[[:space:]]*//;'; done); + do + [ -n "${CLASSPATH}" ] && CLASSPATH="${CLASSPATH}:" + CLASSPATH="${CLASSPATH}${APPDIR}/${JAR}" + JARPATHS=( "${JARPATHS[@]}" "${APPDIR}/${JAR}" ) + done + else + echo "Cannot find getdown.txt" >&2 + exit 3 + fi + + COLUMNS=80 + # get console width -- three ways to try, just in case (not needed for update) + if command -v tput 2>&1 >/dev/null; then + COLUMNS=$(tput cols) 2>/dev/null + elif command -v stty 2>&1 >/dev/null; then + COLUMNS=$(stty size | cut -d" " -f2) 2>/dev/null + elif command -v resize 2>&1 >/dev/null; then + COLUMNS=$(resize -u | grep COLUMNS= | sed -e 's/.*=//;s/;//') 2>/dev/null + fi + + JVMARGS=( "${JVMARGS[@]}" "-DCONSOLEWIDTH=${COLUMNS}" ) + JVMARGS=( "${JVMARGS[@]}" "-Dgetdownappdir=${APPDIR}" ) + JVMARGS=( "${JVMARGS[@]}" "-Dinstaller.appdir=${APPDIR}" ) + JVMARGS=( "${JVMARGS[@]}" "-Dlauncher.appdir=${APPDIR}" ) + JVMARGS=( "${JVMARGS[@]}" "-Dlauncher.script=${SCRIPT}" ) + fi # WINDOWS ONLY (Cygwin or WSL) @@ -151,23 +207,13 @@ if [ "${ISMACOS}" != 1 ]; then # older macos doesn't like uname -o, best to avoi fi fi -# get console width -- three ways to try, just in case -if command -v tput 2>&1 >/dev/null; then - COLUMNS=$(tput cols) 2>/dev/null -elif command -v stty 2>&1 >/dev/null; then - COLUMNS=$(stty size | cut -d" " -f2) 2>/dev/null -elif command -v resize 2>&1 >/dev/null; then - COLUMNS=$(resize -u | grep COLUMNS= | sed -e 's/.*=//;s/;//') 2>/dev/null -fi -JVMARGS=( "${JVMARGS[@]}" "-DCONSOLEWIDTH=${COLUMNS}" ) -JVMARGS=( "${JVMARGS[@]}" "-Dgetdownappdir=${APPDIR}" ) - # Is there a bundled Java? If not just try one in the PATH (do need .exe in WSL) if [ \! -e "${JAVA}" ]; then JAVA=$SYSJAVA echo "Cannot find bundled java, using system ${JAVA} and hoping for the best!" >&2 fi +# This is just needed for display purposes function quotearray() { QUOTEDVALS="" for VAL in "${@}"; do @@ -183,7 +229,7 @@ JVMARGSSTR=$(quotearray "${JVMARGS[@]}") ARGSSTR=$(quotearray "${ARGS[@]}") if [ "${DEBUG}" = 1 ]; then - echo Shell running: \""${JAVA}"\" ${JVMARGSSTR} -cp \""${CLASSPATH}"\" jalview.bin.Launcher ${ARGSSTR} + echo Shell running: \""${JAVA}"\" ${JVMARGSSTR} -cp \""${CLASSPATH}"\" "${CLASS}" ${ARGSSTR} fi -"${JAVA}" "${JVMARGS[@]}" -cp "${CLASSPATH}" jalview.bin.Launcher "${ARGS[@]}" +"${JAVA}" "${JVMARGS[@]}" -cp "${CLASSPATH}" "${CLASS}" "${ARGS[@]}"