JAL-3631 JAL-4444 Change way we add the jalview_x and jalview_x_update PS1 and BAT...
authorBen Soares <b.soares@dundee.ac.uk>
Mon, 5 Aug 2024 22:49:05 +0000 (23:49 +0100)
committerBen Soares <b.soares@dundee.ac.uk>
Mon, 5 Aug 2024 22:49:05 +0000 (23:49 +0100)
build.gradle
gradle.properties
utils/getdown/bin/jalview.ps1
utils/getdown/bin/run_other_script.ps1 [new file with mode: 0755]
utils/getdown/bin/run_powershell.bat [moved from utils/getdown/bin/jalview.bat with 100% similarity]
utils/getdown/bin/update.bat [deleted file]
utils/getdown/bin/update.ps1 [changed mode: 0644->0755]
utils/install4j/install4j10_template.install4j

index 87e4ced..a5d3658 100644 (file)
@@ -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",
   ]
 
index 23d745a..823264c 100644 (file)
@@ -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 =
index 3445aad..ade0089 100755 (executable)
@@ -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 (executable)
index 0000000..80f2a87
--- /dev/null
@@ -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/update.bat b/utils/getdown/bin/update.bat
deleted file mode 100644 (file)
index c88225d..0000000
+++ /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%' %*";
old mode 100644 (file)
new mode 100755 (executable)
index e771aed..82b74d4
@@ -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,
index 16fc35c..c845583 100644 (file)
       <variable name="MACOSARCHIVE_VOLUMEICON" />
       <variable name="WRAPPER_LINK" value="jalview" />
       <variable name="BASH_WRAPPER_SCRIPT" value="jalview.sh" />
-      <variable name="BATCH_WRAPPER_SCRIPT" value="jalview.bat" />
       <variable name="POWERSHELL_WRAPPER_SCRIPT" value="jalview.ps1" />
       <variable name="BASH_UPDATE_SCRIPT" value="update.sh" />
-      <variable name="BATCH_UPDATE_SCRIPT" value="update.bat" />
       <variable name="POWERSHELL_UPDATE_SCRIPT" value="update.ps1" />
       <variable name="WRAPPER_SCRIPT_BIN_DIR" value="bin" />
       <variable name="MACOSARCHIVE_X64_NAME" value="Install Jalview (Intel)" />
@@ -78,6 +76,7 @@
       <variable name="INSTALLER_ICON" value="jalview_installer.png" description="An icon with installation arrow.&#xA;NOT USED" />
       <variable name="INSTALLER_MAC_ICON" value="jalview_installer.icns" description="An icon with installation arrow.&#xA;NOT USED" />
       <variable name="INSTALLER_WINDOWS_ICON" value="jalview_installer.ico" description="An icon with installation arrow.&#xA;NOT USED" />
+      <variable name="TITLE_ICON" value="jalview_logo-64.png" description="Icon sized for the installer wizard title bar" />
       <variable name="LOG_FILE" value=".jalview.log" />
     </variables>
     <codeSigning macEnabled="true" macPkcs12File="${compiler:OSX_KEYSTORE}" macNotarize="true" appleId="${compiler:OSX_APPLEID}">
@@ -479,7 +478,7 @@ public static final String getCanonicalFullPathToDirectoryHash(String installerA
             </group>
           </styleOverride>
           <styleOverride name="Jalview" enabled="true">
-            <formComponent name="Watermark" id="352" beanClass="com.install4j.runtime.beans.formcomponents.SeparatorComponent" insetTop="0" insetLeft="5" insetBottom="0" useExternalParametrization="true" externalParametrizationName="Jalview" externalParametrizationMode="include">
+            <formComponent name="Watermark" id="352" beanClass="com.install4j.runtime.beans.formcomponents.SeparatorComponent" insetTop="0" insetLeft="5" insetBottom="0" useExternalParametrization="true" externalParametrizationName="Custom watermark" externalParametrizationMode="include">
               <serializedBean>
                 <property name="enabledTitleText" type="boolean" value="false" />
               </serializedBean>
@@ -516,7 +515,7 @@ public static final String getCanonicalFullPathToDirectoryHash(String installerA
                 <property name="imageEdgeBorderWidth" type="int" value="2" />
                 <property name="imageFile">
                   <object class="com.install4j.api.beans.ExternalFile">
-                    <string>${compiler:JALVIEW_DIR}/${compiler:ICONS_DIR}/${compiler:PNG_ICON_FILE}</string>
+                    <string>${compiler:JALVIEW_DIR}/${compiler:TITLE_ICON}</string>
                   </object>
                 </property>
                 <property name="imageInsets">
@@ -2018,78 +2017,6 @@ return sb.toString();
                   </action>
                 </beans>
               </group>
-              <group name="Windows scripts" id="2949" beanClass="com.install4j.runtime.beans.groups.ActionGroup">
-                <beans>
-                  <action name="Windows copy BAT jalview file" id="2947" beanClass="com.install4j.runtime.beans.actions.files.CopyFileAction" rollbackBarrierExitCode="0">
-                    <serializedBean>
-                      <property name="destinationFile">
-                        <object class="java.io.File">
-                          <string>${compiler:WRAPPER_SCRIPT_BIN_DIR}/${compiler:WRAPPER_LINK}.bat</string>
-                        </object>
-                      </property>
-                      <property name="files" type="array" class="java.io.File" length="1">
-                        <element index="0">
-                          <object class="java.io.File">
-                            <string>${compiler:WRAPPER_SCRIPT_BIN_DIR}/${compiler:BATCH_WRAPPER_SCRIPT}</string>
-                          </object>
-                        </element>
-                      </property>
-                    </serializedBean>
-                    <condition>Util.isWindows() &amp;&amp; !(((String)context.getCompilerVariable("WRAPPER_LINK")+".bat").equals((String)context.getCompilerVariable("BATCH_WRAPPER_SCRIPT")))</condition>
-                  </action>
-                  <action name="Windows copy PS1 jalview file" id="2948" beanClass="com.install4j.runtime.beans.actions.files.CopyFileAction" rollbackBarrierExitCode="0">
-                    <serializedBean>
-                      <property name="destinationFile">
-                        <object class="java.io.File">
-                          <string>${compiler:WRAPPER_SCRIPT_BIN_DIR}/${compiler:WRAPPER_LINK}.ps1</string>
-                        </object>
-                      </property>
-                      <property name="files" type="array" class="java.io.File" length="1">
-                        <element index="0">
-                          <object class="java.io.File">
-                            <string>${compiler:WRAPPER_SCRIPT_BIN_DIR}/${compiler:POWERSHELL_WRAPPER_SCRIPT}</string>
-                          </object>
-                        </element>
-                      </property>
-                    </serializedBean>
-                    <condition>Util.isWindows() &amp;&amp; !(((String)context.getCompilerVariable("WRAPPER_LINK")+".ps1").equals((String)context.getCompilerVariable("POWERSHELL_WRAPPER_SCRIPT")))</condition>
-                  </action>
-                  <action name="Windows copy BAT update file" id="3055" beanClass="com.install4j.runtime.beans.actions.files.CopyFileAction" rollbackBarrierExitCode="0">
-                    <serializedBean>
-                      <property name="destinationFile">
-                        <object class="java.io.File">
-                          <string>${compiler:WRAPPER_SCRIPT_BIN_DIR}/update_${compiler:WRAPPER_LINK}.bat</string>
-                        </object>
-                      </property>
-                      <property name="files" type="array" class="java.io.File" length="1">
-                        <element index="0">
-                          <object class="java.io.File">
-                            <string>${compiler:WRAPPER_SCRIPT_BIN_DIR}/${compiler:BATCH_UPDATE_SCRIPT}</string>
-                          </object>
-                        </element>
-                      </property>
-                    </serializedBean>
-                    <condition>Util.isWindows()</condition>
-                  </action>
-                  <action name="Windows copy PS1 update file" id="3056" beanClass="com.install4j.runtime.beans.actions.files.CopyFileAction" rollbackBarrierExitCode="0">
-                    <serializedBean>
-                      <property name="destinationFile">
-                        <object class="java.io.File">
-                          <string>${compiler:WRAPPER_SCRIPT_BIN_DIR}/update_${compiler:WRAPPER_LINK}.ps1</string>
-                        </object>
-                      </property>
-                      <property name="files" type="array" class="java.io.File" length="1">
-                        <element index="0">
-                          <object class="java.io.File">
-                            <string>${compiler:WRAPPER_SCRIPT_BIN_DIR}/${compiler:POWERSHELL_UPDATE_SCRIPT}</string>
-                          </object>
-                        </element>
-                      </property>
-                    </serializedBean>
-                    <condition>Util.isWindows()</condition>
-                  </action>
-                </beans>
-              </group>
               <action id="3020" beanClass="com.install4j.runtime.beans.actions.control.SetProgressAction" actionElevationType="none" rollbackBarrierExitCode="0">
                 <serializedBean>
                   <property name="percentValue" type="int" value="100" />
@@ -2562,7 +2489,7 @@ ${compiler:JALVIEW_APPLICATION_NAME} will now launch.</property>
             </serializedBean>
             <beans>
               <formComponent id="38" beanClass="com.install4j.runtime.beans.styles.ContentComponent" insetTop="10" insetLeft="20" insetBottom="10" insetRight="20" />
-              <formComponent name="Watermark" id="39" beanClass="com.install4j.runtime.beans.formcomponents.SeparatorComponent" insetTop="0" insetLeft="5" insetBottom="0" useExternalParametrization="true" externalParametrizationName="${compiler:JALVIEW_APPLICATION_NAME}" externalParametrizationMode="include">
+              <formComponent name="Watermark" id="39" beanClass="com.install4j.runtime.beans.formcomponents.SeparatorComponent" insetTop="0" insetLeft="5" insetBottom="0" useExternalParametrization="true" externalParametrizationMode="include">
                 <serializedBean>
                   <property name="enabledTitleText" type="boolean" value="false" />
                 </serializedBean>