From 87e83efdb057cb0761a7be1fc09fa3bbb2f72c42 Mon Sep 17 00:00:00 2001 From: Ben Soares Date: Mon, 5 Aug 2024 23:49:05 +0100 Subject: [PATCH] JAL-3631 JAL-4444 Change way we add the jalview_x and jalview_x_update PS1 and BAT files, moved into build.gradle and removed from install4j. Add title icon to install4j. --- build.gradle | 34 ++++++-- gradle.properties | 4 +- utils/getdown/bin/jalview.ps1 | 39 ++++++---- utils/getdown/bin/run_other_script.ps1 | 43 +++++++++++ .../bin/{jalview.bat => run_powershell.bat} | 0 utils/getdown/bin/update.bat | 50 ------------ utils/getdown/bin/update.ps1 | 6 +- utils/install4j/install4j10_template.install4j | 81 +------------------- 8 files changed, 104 insertions(+), 153 deletions(-) create mode 100755 utils/getdown/bin/run_other_script.ps1 rename utils/getdown/bin/{jalview.bat => run_powershell.bat} (100%) delete mode 100644 utils/getdown/bin/update.bat mode change 100644 => 100755 utils/getdown/bin/update.ps1 diff --git a/build.gradle b/build.gradle index 87e4ced..a5d3658 100644 --- a/build.gradle +++ b/build.gradle @@ -2387,15 +2387,15 @@ task getdownWebsiteBuild() { into getdownResourceDir } } - + def getdownWrapperScripts = [ getdown_bash_wrapper_script, getdown_powershell_wrapper_script, - getdown_batch_wrapper_script, getdown_bash_update_script, getdown_powershell_update_script, - getdown_batch_update_script ] + def run_powershell = file( "${jalviewDir}/utils/getdown/${getdown_wrapper_script_dir}/${getdown_run_powershell}" ) + def run_other_script = file( "${jalviewDir}/utils/getdown/${getdown_wrapper_script_dir}/${getdown_run_other_script}" ) getdownWrapperScripts.each{ script -> def s = file( "${jalviewDir}/utils/getdown/${getdown_wrapper_script_dir}/${script}" ) if (s.exists()) { @@ -2405,6 +2405,31 @@ task getdownWebsiteBuild() { } getdownTextLines += "xresource = ${getdown_wrapper_script_dir}/${script}" } + def ext = script.toLowerCase(Locale.ROOT).substring(script.lastIndexOf(".") + 1) + if ("ps1".equals(ext)) { + def base = script.take(script.lastIndexOf(".")) + def newbase = "update".equals(base) ? "${install4jUnixApplicationFolder}_update" : install4jUnixApplicationFolder + if (!newbase.equals(base)) { + copy { + from run_other_script + rename(run_other_script.getName(), "${newbase}.${ext}") + into "${getdownAppBaseDir}/${getdown_wrapper_script_dir}" + getdownTextLines += "xresource = ${getdown_wrapper_script_dir}/${newbase}.${ext}" + filter(ReplaceTokens, + beginToken: '__', + endToken: '__', + tokens: [ + 'OTHERSCRIPT': script + ] + ) } + } + copy { + from run_powershell + rename(run_powershell.getName(), "${newbase}.bat") + into "${getdownAppBaseDir}/${getdown_wrapper_script_dir}" + getdownTextLines += "xresource = ${getdown_wrapper_script_dir}/${newbase}.bat" + } + } } def codeFiles = [] @@ -3031,10 +3056,8 @@ task installerFiles(type: com.install4j.gradle.Install4jTask) { 'WRAPPER_LINK': getdownWrapperLink, 'BASH_WRAPPER_SCRIPT': getdown_bash_wrapper_script, 'POWERSHELL_WRAPPER_SCRIPT': getdown_powershell_wrapper_script, - 'BATCH_WRAPPER_SCRIPT': getdown_batch_wrapper_script, 'BASH_UPDATE_SCRIPT': getdown_bash_update_script, 'POWERSHELL_UPDATE_SCRIPT': getdown_powershell_update_script, - 'BATCH_UPDATE_SCRIPT': getdown_batch_update_script, 'WRAPPER_SCRIPT_BIN_DIR': getdown_wrapper_script_dir, 'MACOSARCHIVE_X64_NAME': install4jmacOSArchiveX64Name, 'MACOSARCHIVE_AARCH64_NAME': install4jmacOSArchiveAarch64Name, @@ -3063,6 +3086,7 @@ task installerFiles(type: com.install4j.gradle.Install4jTask) { 'INSTALLER_ICON': "${getdownImagesDir}/${install4j_installer_icon}", 'INSTALLER_MAC_ICON': "${getdownImagesDir}/${install4j_installer_mac_icon}", 'INSTALLER_WINDOWS_ICON': "${getdownImagesDir}/${install4j_installer_windows_icon}", + 'TITLE_ICON': "${getdownImagesDir}/${install4j_title_icon}", 'LOG_FILE': "${install4jUnixApplicationFolder}.log", ] diff --git a/gradle.properties b/gradle.properties index 23d745a..823264c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -165,10 +165,10 @@ jalview_customise_ds_store = utils/macos_dmg/jalview_customise_dsstore.py getdown_wrapper_script_dir = bin getdown_bash_wrapper_script = jalview.sh getdown_powershell_wrapper_script = jalview.ps1 -getdown_batch_wrapper_script = jalview.bat getdown_bash_update_script = update.sh getdown_powershell_update_script = update.ps1 -getdown_batch_update_script = update.bat +getdown_run_other_script = run_other_script.ps1 +getdown_run_powershell = run_powershell.bat OSX_KEYSTORE = OSX_KEYPASS = diff --git a/utils/getdown/bin/jalview.ps1 b/utils/getdown/bin/jalview.ps1 index 3445aad..ade0089 100755 --- a/utils/getdown/bin/jalview.ps1 +++ b/utils/getdown/bin/jalview.ps1 @@ -2,7 +2,6 @@ # save args and first parameter $myArgs = $args.Clone() -$myArg1 = $args[0] # setup for powershell version < 6.0 [bool] $myIsWindows = 0 @@ -47,22 +46,34 @@ if ( $help ) { $headless = 0 } -# parent dir of this actual script (which should be the getdown appdir/bin). Follow all symlinks. Like GNU readlink -f +# actual path of this script (which should be the getdown appdir/bin). Follow all symlinks. Like GNU readlink -f function Readlink-f { - Param($Link) - $dirs = @() - $dir = Convert-Path $Link - while ( $dir ) { - $dirs = @( Split-Path $dir -Leaf ) + $dirs - $dir = Split-Path $dir -Parent + Param( + [Parameter(mandatory=$true, ValueFromPipeline=$true)]$Link, + [Parameter()]$iteration_count = 1 + ) + if ( $iteration_count -ge 100 ) { + Write-Error "Readlink-f iterated 100 times" + return $Link } - $real = Get-Item "/" - foreach ($d in $dirs) { - $real = Join-Path -Path $real -ChildPath $d - $item = Get-Item $real - if ($item.Target -ne $null) { - $real = Convert-Path $item.Target + if ( $Link -eq "" -or $Link -eq $null ) { + return $null + } + $path_components = @() + $dir = Get-Item $Link + while ( $dir -ne $null ) { + while ( $dir.Target -ne $null ) { + # [System.IO.Path]::Combine caters for a multitude of sins that it's almost impossible to deal with with Join-Path + $dir = Get-Item ([System.IO.Path]::GetFullPath( [System.IO.Path]::Combine( (Split-Path $dir -Parent), $dir.Target ))) } + $parent = Split-Path -Path $dir -Parent + $path_components = @( (Split-Path -Path $dir -Leaf) ) + $path_components + $dir = Readlink-f $parent ($iteration_count + 1) + } + $real = Get-Item "/" + foreach ( $component in $path_components) { + # [System.IO.Path]::Combine caters for a multitude of sins that it's almost impossible to deal with with Join-Path + $real = Get-Item ([System.IO.Path]::GetFullPath( [System.IO.Path]::Combine( $real, $component ))) } $real } diff --git a/utils/getdown/bin/run_other_script.ps1 b/utils/getdown/bin/run_other_script.ps1 new file mode 100755 index 0000000..80f2a87 --- /dev/null +++ b/utils/getdown/bin/run_other_script.ps1 @@ -0,0 +1,43 @@ +#!/usr/bin/env pwsh + +$OTHERSCRIPT = "__OTHERSCRIPT__" + +# actual path of this script (which should be the getdown appdir/bin). Follow all symlinks. Like GNU readlink -f +function Readlink-f { + Param( + [Parameter(mandatory=$true, ValueFromPipeline=$true)]$Link, + [Parameter()]$iteration_count = 1 + ) + if ( $iteration_count -ge 100 ) { + Write-Error "Readlink-f iterated 100 times" + return $Link + } + if ( $Link -eq "" -or $Link -eq $null ) { + return $null + } + $path_components = @() + $dir = Get-Item $Link + while ( $dir -ne $null ) { + while ( $dir.Target -ne $null ) { + # [System.IO.Path]::Combine caters for a multitude of sins that it's almost impossible to deal with with Join-Path + $dir = Get-Item ([System.IO.Path]::GetFullPath( [System.IO.Path]::Combine( (Split-Path $dir -Parent), $dir.Target ))) + } + $parent = Split-Path -Path $dir -Parent + $path_components = @( (Split-Path -Path $dir -Leaf) ) + $path_components + $dir = Readlink-f $parent ($iteration_count + 1) + } + $real = Get-Item "/" + foreach ( $component in $path_components) { + # [System.IO.Path]::Combine caters for a multitude of sins that it's almost impossible to deal with with Join-Path + $real = Get-Item ([System.IO.Path]::GetFullPath( [System.IO.Path]::Combine( $real, $component ))) + } + $real +} + +$CMDPATH = ( Get-Item $MyInvocation.MyCommand.Path ) +$SCRIPTPATH = Readlink-f -Link $CMDPATH +$SCRIPTBIN = Split-Path -Path $SCRIPTPATH -Parent +$SCRIPT = Join-Path $SCRIPTBIN -ChildPath $OTHERSCRIPT + +Write-Host "Running: $SCRIPT $args" +& $SCRIPT $args diff --git a/utils/getdown/bin/jalview.bat b/utils/getdown/bin/run_powershell.bat similarity index 100% rename from utils/getdown/bin/jalview.bat rename to utils/getdown/bin/run_powershell.bat diff --git a/utils/getdown/bin/update.bat b/utils/getdown/bin/update.bat deleted file mode 100644 index c88225d..0000000 --- a/utils/getdown/bin/update.bat +++ /dev/null @@ -1,50 +0,0 @@ -@ECHO OFF - -REM This is the Jalview batch script wrapper to run the powershell script of the same name. -REM There is nothing specific to Jalview. - -REM ****************************************************************************** -REM If you need to set a full path to the PowerShell executable please do so here: -SET PWSHPATH= -REM ****************************************************************************** - -REM This is some DOS magic to substitute the extension in the full path of this batch script with .ps1 -SET SCRIPTPATH=%~dpn0.ps1 - -REM PowerShell script isn't where it should be! -IF NOT EXIST "%SCRIPTPATH%" ( - ECHO Could not find PowerShell script "%SCRIPTPATH%". Is %~nx0 in the right folder? - EXIT /B 1 -) - -REM Look for either pwsh.exe or powershell.exe if not set in PWSHPATH above. -REM pwsh.exe is preferred as it is likely to be a newer version. -SET PWSH= -IF DEFINED PWSHPATH ( - SET PWSH=%PWSHPATH% -) -FOR %%X IN (pwsh.exe powershell.exe) DO ( - IF NOT DEFINED PWSH ( - IF NOT "%%~$PATH:X" == "" ( - REM Found a PowerShell executable in the PATH - SET PWSH="%%X" - GOTO end_looking - ) - ) -) -:end_looking - -IF NOT DEFINED PWSH ( - REM No PowerShell executable found -- tell the user what to do. - ECHO No PowerShell found in %%PATH%%. If PowerShell is installed either - ECHO 1. add it to your PATH, or - ECHO 2. edit the PWSHPATH value at the top of this file: - ECHO "%~dpnx0" - ECHO. - ECHO %~n0 on the command line requires PowerShell. To install PowerShell see - ECHO https://docs.microsoft.com/en-us/powershell/scripting/install/installing-powershell - EXIT /B 2 -) - -REM Run the PowerShell script -"%PWSH%" -NoProfile -ExecutionPolicy Bypass -Command "& '%SCRIPTPATH%' %*"; diff --git a/utils/getdown/bin/update.ps1 b/utils/getdown/bin/update.ps1 old mode 100644 new mode 100755 index e771aed..82b74d4 --- a/utils/getdown/bin/update.ps1 +++ b/utils/getdown/bin/update.ps1 @@ -1,9 +1,5 @@ #!/usr/bin/env pwsh -# save args and first parameter -$myArgs = $args.Clone() -$myArg1 = $args[0] - # setup for powershell version < 6.0 [bool] $myIsWindows = 0 [bool] $myIsMacOS = 0 @@ -44,7 +40,7 @@ if ( -not ( $userspace -or -$installation ) ) { Exit } -# parent dir of this actual script (which should be the getdown appdir/bin). Follow all symlinks. Like GNU readlink -f +# actual path of this script (which should be the getdown appdir/bin). Follow all symlinks. Like GNU readlink -f function Readlink-f { Param( [Parameter(mandatory=$true, ValueFromPipeline=$true)]$Link, diff --git a/utils/install4j/install4j10_template.install4j b/utils/install4j/install4j10_template.install4j index 16fc35c..c845583 100644 --- a/utils/install4j/install4j10_template.install4j +++ b/utils/install4j/install4j10_template.install4j @@ -45,10 +45,8 @@ - - @@ -78,6 +76,7 @@ + @@ -479,7 +478,7 @@ public static final String getCanonicalFullPathToDirectoryHash(String installerA - + @@ -516,7 +515,7 @@ public static final String getCanonicalFullPathToDirectoryHash(String installerA - ${compiler:JALVIEW_DIR}/${compiler:ICONS_DIR}/${compiler:PNG_ICON_FILE} + ${compiler:JALVIEW_DIR}/${compiler:TITLE_ICON} @@ -2018,78 +2017,6 @@ return sb.toString(); - - - - - - - ${compiler:WRAPPER_SCRIPT_BIN_DIR}/${compiler:WRAPPER_LINK}.bat - - - - - - ${compiler:WRAPPER_SCRIPT_BIN_DIR}/${compiler:BATCH_WRAPPER_SCRIPT} - - - - - Util.isWindows() && !(((String)context.getCompilerVariable("WRAPPER_LINK")+".bat").equals((String)context.getCompilerVariable("BATCH_WRAPPER_SCRIPT"))) - - - - - - ${compiler:WRAPPER_SCRIPT_BIN_DIR}/${compiler:WRAPPER_LINK}.ps1 - - - - - - ${compiler:WRAPPER_SCRIPT_BIN_DIR}/${compiler:POWERSHELL_WRAPPER_SCRIPT} - - - - - Util.isWindows() && !(((String)context.getCompilerVariable("WRAPPER_LINK")+".ps1").equals((String)context.getCompilerVariable("POWERSHELL_WRAPPER_SCRIPT"))) - - - - - - ${compiler:WRAPPER_SCRIPT_BIN_DIR}/update_${compiler:WRAPPER_LINK}.bat - - - - - - ${compiler:WRAPPER_SCRIPT_BIN_DIR}/${compiler:BATCH_UPDATE_SCRIPT} - - - - - Util.isWindows() - - - - - - ${compiler:WRAPPER_SCRIPT_BIN_DIR}/update_${compiler:WRAPPER_LINK}.ps1 - - - - - - ${compiler:WRAPPER_SCRIPT_BIN_DIR}/${compiler:POWERSHELL_UPDATE_SCRIPT} - - - - - Util.isWindows() - - - @@ -2562,7 +2489,7 @@ ${compiler:JALVIEW_APPLICATION_NAME} will now launch. - + -- 1.7.10.2