From fb2acffde9626c68514def6d609de3f39e2302dc Mon Sep 17 00:00:00 2001 From: Ben Soares Date: Fri, 12 Mar 2021 01:09:56 +0000 Subject: [PATCH] JAL-3830 unix and macos wrappers. Symbolic link to jalviewc-macos in Contents/MacOS/jalviewc. --- build.gradle | 15 ++++++++++- gradle.properties | 4 ++- utils/getdown/jalviewc | 28 ++++++++++++++++++++ utils/getdown/jalviewc-macos | 34 +++++++++++++++++++++++++ utils/install4j/install4j8_template.install4j | 5 ++-- utils/install4j/macos_jalview | 28 -------------------- 6 files changed, 82 insertions(+), 32 deletions(-) create mode 100755 utils/getdown/jalviewc create mode 100755 utils/getdown/jalviewc-macos delete mode 100755 utils/install4j/macos_jalview diff --git a/build.gradle b/build.gradle index 5588c51..4930f94 100644 --- a/build.gradle +++ b/build.gradle @@ -1572,6 +1572,18 @@ task getdownWebsite() { into getdownResourceDir } } + + def getdownWrapperScripts = [ getdown_mac_wrapper_script, getdown_unix_wrapper_script ] + getdownWrapperScripts.each{ script -> + def s = file( "${jalviewDir}/utils/getdown/${script}" ) + if (s.exists()) { + copy { + from s + into getdownWebsiteDir + } + getdownTextString += "resource = ${script}\n" + } + } def codeFiles = [] fileTree(file(package_dir)).each{ f -> @@ -1900,7 +1912,8 @@ task installers(type: com.install4j.gradle.Install4jTask) { 'WINDOWS_APPLICATION_ID': install4jWinApplicationId, 'MACOS_DMG_DS_STORE': install4jDMGDSStore, 'MACOS_DMG_BG_IMAGE': install4jDMGBackgroundImage, - 'MACOS_DMG_WRAPPER_SCRIPT': install4j_dmg_wrapper_script, + 'MACOS_DMG_WRAPPER_LINK': install4j_dmg_wrapper_link, + 'MACOS_WRAPPER_SCRIPT': getdown_mac_wrapper_script, 'INSTALLER_NAME': install4jInstallerName, 'INSTALL4J_UTILS_DIR': install4j_utils_dir, 'GETDOWN_WEBSITE_DIR': getdown_website_dir, diff --git a/gradle.properties b/gradle.properties index 1d7b10c..8157012 100644 --- a/gradle.properties +++ b/gradle.properties @@ -133,7 +133,9 @@ install4j_png_icon_file = jalview_logo.png install4j_background = jalview_logo_background_fade-640x480.png install4j_dmg_background = jalview_dmg_background-NON-RELEASE.png install4j_dmg_ds_store = jalview_dmg_DS_Store -install4j_dmg_wrapper_script = utils/install4j/macos_jalview +install4j_dmg_wrapper_link = jalviewc +getdown_mac_wrapper_script = jalviewc-macos +getdown_unix_wrapper_script = jalviewc OSX_KEYSTORE = OSX_KEYPASS = diff --git a/utils/getdown/jalviewc b/utils/getdown/jalviewc new file mode 100755 index 0000000..a3fa66b --- /dev/null +++ b/utils/getdown/jalviewc @@ -0,0 +1,28 @@ +#!/usr/bin/env bash + +ARG1=$1 +WDIR="$( pwd )" +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" + +# check to see if $1 is set and is not start of other cli set args +OPEN="" +if [ -n "$ARG1" -a "$ARG1" = "${ARG1#-}" -a \! "$ARG1" = "open" ]; then + # first argument exists and does not start with a "-" and is not "open" + OPEN="-open" +fi + +APPDIR="${DIR}" +JAVA="${APPDIR}/jre/bin/java" +GETDOWNTXT="${APPDIR}/getdown.txt" +if [ -e "$GETDOWNTXT" ]; then + CLASSPATH="" + for x in $(grep -e 'code = ' "${GETDOWNTXT}" | sed -e 's/^code\s*=\s*//;'); do + [ -n "$CLASSPATH" ] && CLASSPATH="${CLASSPATH}:" + CLASSPATH="${CLASSPATH}${APPDIR}/${x}" + done +else + echo "Cannot find getdown.txt" >&2 + exit 1 +fi + +"$JAVA" -cp "$CLASSPATH" jalview.bin.Launcher $OPEN "$@" diff --git a/utils/getdown/jalviewc-macos b/utils/getdown/jalviewc-macos new file mode 100755 index 0000000..32748cb --- /dev/null +++ b/utils/getdown/jalviewc-macos @@ -0,0 +1,34 @@ +#!/usr/bin/env bash + +ARG1=$1 +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" +APP=${DIR%/Contents/*} + +if [ "${APP}" = "${APP%.app}" ]; then + echo "Could not find .app dir" >&2 + exit 1 +fi + +# check to see if $1 is set and is not start of other cli set args +OPEN="" +if [ -n "$ARG1" -a "$ARG1" = "${ARG1#-}" -a \! "$ARG1" = "open" ]; then + # first argument exists and does not start with a "-" and is not "open" + OPEN="-open" +fi + +APPDIR="${APP}/Contents/Resources/app" +JAVA="${APPDIR}/jre/Contents/Home/bin/java" +GETDOWNTXT="${APPDIR}/getdown.txt" +# always check grep and sed regexes on macOS -- they're not the same +if [ -e "$GETDOWNTXT" ]; then + CLASSPATH="" + for x in $(grep -e 'code = ' "${GETDOWNTXT}" | sed -e 's/^code\s*=\s*//;'); do + [ -n "$CLASSPATH" ] && CLASSPATH="${CLASSPATH}:" + CLASSPATH="${CLASSPATH}${APPDIR}/${x}" + done +else + echo "Cannot find getdown.txt" >&2 + exit 1 +fi + +"$JAVA" -cp "$CLASSPATH" jalview.bin.Launcher $OPEN "$@" diff --git a/utils/install4j/install4j8_template.install4j b/utils/install4j/install4j8_template.install4j index 038ee90..112cbbc 100644 --- a/utils/install4j/install4j8_template.install4j +++ b/utils/install4j/install4j8_template.install4j @@ -35,7 +35,8 @@ - + + @@ -1178,7 +1179,7 @@ return console.askYesNo(message, true); - + diff --git a/utils/install4j/macos_jalview b/utils/install4j/macos_jalview deleted file mode 100755 index aabdba8..0000000 --- a/utils/install4j/macos_jalview +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env bash - -ARG1=$1 -WDIR="$( pwd )" -DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" -APP=${DIR%/Contents/MacOS} - -if [ "${APP}" = "${APP%.app}" ]; then - echo "Could not find .app dir" >&2 - exit 1 -fi - -# check to see if $1 is set and is not start of other cli set args -OPEN="" -if [ -n "$ARG1" -a "$ARG1" = "${ARG1#-}" ]; then - # first argument exists and does not start with a "-" - OPEN="-open" -fi - -# This would open the Jalview application as if double clicking, with the supplied args -# open -a ${APP} --args $OPEN "$@" -### but we don't want to run getdown in case of autoupdates or changing the working dir, so ... - -APPDIR="${APP}/Contents/Resources/app" -JAVA="${APPDIR}/jre/Contents/Home/bin/java" -CLASSPATH=""; for x in $(grep -e 'code = ' "${APP}/Contents/Resources/app/getdown.txt" | sed -e 's/^code\s*=\s*//;'); do [ -n "$CLASSPATH" ] && CLASSPATH="${CLASSPATH}:"; CLASSPATH="${CLASSPATH}${APPDIR}/${x}"; done - -"$JAVA" -cp "$CLASSPATH" jalview.bin.Launcher $OPEN "$@" -- 1.7.10.2