From 7894f6f84cbf22218c293149614321796e28acb8 Mon Sep 17 00:00:00 2001 From: Ben Soares Date: Wed, 31 Mar 2021 23:16:56 +0100 Subject: [PATCH] JAL-3830 BAT file wrapper around powershell, so jalview works in command prompt. Added install4j option for installer to add Jalview's bin dir to Path in Windows. Added install4j option to create symlink to bash script to user's local bin (first of ~/bin, ~/.local/bin, ~/local/bin, ~/opt/bin that exists. First two of these usually automatically in PATH). --- build.gradle | 5 +- gradle.properties | 2 +- utils/getdown/bin/jalview.bat | 4 + utils/install4j/install4j8_template.install4j | 116 ++++++++++++++++++------- 4 files changed, 92 insertions(+), 35 deletions(-) create mode 100755 utils/getdown/bin/jalview.bat diff --git a/build.gradle b/build.gradle index e6c8fbd..2c1a56d 100644 --- a/build.gradle +++ b/build.gradle @@ -370,6 +370,7 @@ ext { .replaceAll("_*-_*", "-") // collapse _-_ .toLowerCase() + getdownWrapperLink = install4jUnixApplicationFolder // e.g. "jalview_local" getdownAppDir = string("${getdownWebsiteDir}/${getdownAppDistDir}") //getdownJ11libDir = "${getdownWebsiteDir}/${getdown_j11lib_dir}" getdownResourceDir = string("${getdownWebsiteDir}/${getdown_resource_dir}") @@ -1573,7 +1574,7 @@ task getdownWebsite() { } } - def getdownWrapperScripts = [ getdown_bash_wrapper_script, getdown_powershell_wrapper_script ] + def getdownWrapperScripts = [ getdown_bash_wrapper_script, getdown_powershell_wrapper_script, getdown_batch_wrapper_script ] getdownWrapperScripts.each{ script -> def s = file( "${jalviewDir}/utils/getdown/${getdown_wrapper_script_dir}/${script}" ) if (s.exists()) { @@ -1912,7 +1913,7 @@ task installers(type: com.install4j.gradle.Install4jTask) { 'WINDOWS_APPLICATION_ID': install4jWinApplicationId, 'MACOS_DMG_DS_STORE': install4jDMGDSStore, 'MACOS_DMG_BG_IMAGE': install4jDMGBackgroundImage, - 'WRAPPER_LINK': getdown_wrapper_link, + 'WRAPPER_LINK': getdownWrapperLink, 'BASH_WRAPPER_SCRIPT': getdown_bash_wrapper_script, 'POWERSHELL_WRAPPER_SCRIPT': getdown_powershell_wrapper_script, 'WRAPPER_SCRIPT_BIN_DIR': getdown_wrapper_script_dir, diff --git a/gradle.properties b/gradle.properties index 9e7d8da..d0fb57d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -135,9 +135,9 @@ 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 getdown_wrapper_script_dir = bin -getdown_wrapper_link = jalview getdown_bash_wrapper_script = jalview.sh getdown_powershell_wrapper_script = jalview.ps1 +getdown_batch_wrapper_script = jalview.bat OSX_KEYSTORE = OSX_KEYPASS = diff --git a/utils/getdown/bin/jalview.bat b/utils/getdown/bin/jalview.bat new file mode 100755 index 0000000..428019b --- /dev/null +++ b/utils/getdown/bin/jalview.bat @@ -0,0 +1,4 @@ +@ECHO OFF +SET ThisScriptsDirectory=%~dp0 +SET PowerShellScriptPath=%ThisScriptsDirectory%jalview.ps1 +PowerShell -NoProfile -ExecutionPolicy Bypass -Command "& '%PowerShellScriptPath%' %*"; diff --git a/utils/install4j/install4j8_template.install4j b/utils/install4j/install4j8_template.install4j index 388e14c..a14900c 100644 --- a/utils/install4j/install4j8_template.install4j +++ b/utils/install4j/install4j8_template.install4j @@ -37,7 +37,6 @@ - @@ -57,7 +56,6 @@ - @@ -246,6 +244,35 @@ + + + + + String userHome = (String)context.getVariable("sys.userHome"); + +String[] tryPaths = new String[] { + "bin", + ".local" + File.separator + "bin", + "local" + File.separator + "bin", + "opt" + File.separator + "bin" +}; + +for (int i = 0; i < tryPaths.length; i++) { + String tryPath = tryPaths[i]; + File unixUserBinDir = new File(userHome + File.separator + tryPath); + if (unixUserBinDir.exists()) { + return tryPath; + } +} + +return null; + + + + unixUserBinDir + + Util.isLinux() || Util.isUnixInstaller() + @@ -492,7 +519,7 @@ return console.askOkCancel(message, true); - Creating file associations + Finished creating file associations @@ -533,20 +560,6 @@ return console.askOkCancel(message, true); - - - - - ${compiler:WRAPPER_SCRIPT_BIN_DIR}/${compiler:LINK_TO_WRAPPER_SCRIPT} - - - - - ${compiler:WRAPPER_SCRIPT_BIN_DIR}/${compiler:WRAPPER_LINK} - - - - @@ -604,6 +617,44 @@ return console.askOkCancel(message, true); context.getBooleanVariable("addToDockAction") + + + + + ${compiler:WRAPPER_SCRIPT_BIN_DIR}/${compiler:BASH_WRAPPER_SCRIPT} + + + + + ${compiler:WRAPPER_SCRIPT_BIN_DIR}/${compiler:WRAPPER_LINK} + + + + !Util.isWindows() + + + + + ${installer:sys.contentDir}\${compiler:WRAPPER_SCRIPT_BIN_DIR} + Path + + context.getBooleanVariable("appendToPathAction") + + + + + + ${installer:sys.contentDir}/${compiler:WRAPPER_SCRIPT_BIN_DIR}/${compiler:BASH_WRAPPER_SCRIPT} + + + + + ${installer:sys.userHome}/${installer:unixUserBinDir}/${compiler:WRAPPER_LINK} + + + + context.getBooleanVariable("makeSymbolicLink") && ( Util.isLinux() || Util.isUnixInstaller() ) && ( context.getVariable("unixUserBinDir") != null ) + @@ -626,6 +677,22 @@ return console.askOkCancel(message, true); Util.isMacOS() + + + Add ${compiler:JALVIEW_APPLICATION_NAME}'s bin folder to the Path environment variable + + appendToPathAction + + Util.isWindows() + + + + Make a ${compiler:WRAPPER_LINK} symbolic link in ~/${installer:unixUserBinDir} + + makeSymbolicLink + + ( Util.isLinux() || Util.isUnixInstaller() ) && ( context.getVariable("unixUserBinDir") != null ) + @@ -1202,9 +1269,6 @@ return console.askYesNo(message, true); - - - @@ -1218,9 +1282,6 @@ return console.askYesNo(message, true); - - - @@ -1244,9 +1305,6 @@ return console.askYesNo(message, true); - - - @@ -1263,9 +1321,6 @@ return console.askYesNo(message, true); - - - @@ -1282,9 +1337,6 @@ return console.askYesNo(message, true); - - - -- 1.7.10.2