JAL-3631 Adjustments to the Windows installer
authorBen Soares <b.soares@dundee.ac.uk>
Fri, 28 Jun 2024 11:04:05 +0000 (12:04 +0100)
committerBen Soares <b.soares@dundee.ac.uk>
Fri, 28 Jun 2024 11:04:05 +0000 (12:04 +0100)
utils/install4j/install4j10_template.install4j

index 8600f75..8d9e5b5 100644 (file)
           <property name="frameHeight" type="int" value="600" />
           <property name="frameWidth" type="int" value="800" />
           <property name="useCustomIcon" type="boolean" value="true" />
-          <property name="windowsConsoleExecutable" type="boolean" value="true" />
         </serializedBean>
         <styleOverrides>
           <styleOverride name="Customize banner image" enabled="true">
                 <serializedBean>
                   <property name="failIfNotObtainedMac" type="boolean" value="false" />
                   <property name="failIfNotObtainedWin" type="boolean" value="false" />
-                  <property name="linuxPrivilegeRequirement" type="enum" class="com.install4j.runtime.beans.actions.misc.PrivilegeRequirement" value="OBTAIN" />
-                  <property name="obtainIfNormalWin" type="boolean" value="true" />
+                  <property name="obtainIfAdminMac" type="boolean" value="true" />
                 </serializedBean>
               </action>
-              <action name="USERSPACE: Set unixBinDir (Linux or Unix)" id="2738" beanClass="com.install4j.runtime.beans.actions.control.SetVariableAction" rollbackBarrierExitCode="0">
+              <action name="BOTHSPACE: Set makeSymbolicLink boolean variable?" id="2853" beanClass="com.install4j.runtime.beans.actions.control.SetVariableAction" rollbackBarrierExitCode="0">
                 <serializedBean>
                   <property name="script">
                     <object class="com.install4j.api.beans.ScriptProperty">
-                      <property name="value" type="string">String userHome = (String)context.getVariable("sys.userHome");
-
-ArrayList&lt;String&gt; tryPaths = new ArrayList&lt;&gt; ();
-tryPaths.add(userHome + File.separator + "bin");
-tryPaths.add(userHome + File.separator + "local" + File.separator + "bin");
-tryPaths.add(userHome + File.separator + ".local" + File.separator + "bin");
-tryPaths.add(userHome + File.separator + "opt" + File.separator + "bin");
-
-for (int i = 0; i &lt; tryPaths.size(); i++) {
-    String tryPath = tryPaths.get(i);
-    File unixBinDir = new File(tryPath);
-    if (unixBinDir.exists()) {
-        return tryPath;
-    }
-}
-
-return null;
-</property>
+                      <property name="value" type="string">Util.isLinux() || Util.isUnixInstaller()</property>
                     </object>
                   </property>
-                  <property name="variableName" type="string">unixBinDir</property>
+                  <property name="variableName" type="string">makeSymbolicLink</property>
                 </serializedBean>
-                <condition>!Util.hasFullAdminRights()
-&amp;&amp;
-(
-  Util.isLinux()
-  || Util.isUnixInstaller()
-  || Util.isMacOS()
-)</condition>
               </action>
-              <action name="SYSTEMSPACE: Set unixBinDir (Linux or Unix)" id="2845" beanClass="com.install4j.runtime.beans.actions.control.SetVariableAction" rollbackBarrierExitCode="0">
+              <action name="BOTHSPACE: Set unixBinDir (Linux or Unix)" id="2845" beanClass="com.install4j.runtime.beans.actions.control.SetVariableAction" rollbackBarrierExitCode="0">
                 <serializedBean>
                   <property name="script">
                     <object class="com.install4j.api.beans.ScriptProperty">
                       <property name="value" type="string">ArrayList&lt;String&gt; tryPaths = new ArrayList&lt;&gt; ();
-tryPaths.add(File.separator + "opt" + File.separator + "bin");
-tryPaths.add(File.separator + "usr" + File.separator + "local" + File.separator + "bin");
+
+if (Util.hasFullAdminRights()) {
+    tryPaths.add(File.separator + "opt" + File.separator + "bin");
+    tryPaths.add(File.separator + "usr" + File.separator + "local" + File.separator + "bin");
+} else {
+    String userHome = (String)context.getVariable("sys.userHome");
+    tryPaths.add(userHome + File.separator + "bin");
+    tryPaths.add(userHome + File.separator + "local" + File.separator + "bin");
+    tryPaths.add(userHome + File.separator + ".local" + File.separator + "bin");
+    tryPaths.add(userHome + File.separator + "opt" + File.separator + "bin");
+}
 
 for (int i = 0; i &lt; tryPaths.size(); i++) {
     String tryPath = tryPaths.get(i);
@@ -383,15 +366,9 @@ return null;
                   </property>
                   <property name="variableName" type="string">unixBinDir</property>
                 </serializedBean>
-                <condition>Util.hasFullAdminRights()
-&amp;&amp;
-(
-  Util.isLinux()
-  || Util.isUnixInstaller()
-  || Util.isMacOS()
-)</condition>
+                <condition>context.getBooleanVariable("makeSymbolicLink")</condition>
               </action>
-              <action name="Set macWrapperLinkLocation (macOS)" id="2745" beanClass="com.install4j.runtime.beans.actions.control.SetVariableAction" rollbackBarrierExitCode="0">
+              <action name="USERSPACE: Set macWrapperLinkLocation (macOS)" id="2745" beanClass="com.install4j.runtime.beans.actions.control.SetVariableAction" rollbackBarrierExitCode="0">
                 <serializedBean>
                   <property name="script">
                     <object class="com.install4j.api.beans.ScriptProperty">
@@ -408,7 +385,7 @@ return wrapperLink;
                   </property>
                   <property name="variableName" type="string">macWrapperLinkLocation</property>
                 </serializedBean>
-                <condition>Util.isMacOS()</condition>
+                <condition>Util.isMacOS() &amp;&amp; !Util.hasFullAdminRights() // Admin on macOS will add path to /etc/paths.d in Create File action</condition>
               </action>
             </actions>
           </screen>
@@ -785,9 +762,7 @@ return console.askOkCancel(message, true);
                     </object>
                   </property>
                 </serializedBean>
-                <condition>!Util.hasFullAdminRights()
-&amp;&amp;
-!context.getBooleanVariable("sys.programGroupDisabled")</condition>
+                <condition>!Util.hasFullAdminRights() &amp;&amp; !context.getBooleanVariable("sys.programGroupDisabled")</condition>
               </action>
               <action name="USERSPACE: Add a desktop link" id="573" beanClass="com.install4j.runtime.beans.actions.desktop.CreateDesktopLinkAction" actionElevationType="elevated" rollbackBarrierExitCode="0" errorMessage="Could not make desktop link">
                 <serializedBean>
@@ -810,9 +785,7 @@ return console.askOkCancel(message, true);
                     </object>
                   </property>
                 </serializedBean>
-                <condition>!Util.hasFullAdminRights()
-&amp;&amp;
-context.getBooleanVariable("createDesktopLinkAction")</condition>
+                <condition>!Util.hasFullAdminRights() &amp;&amp; context.getBooleanVariable("createDesktopLinkAction")</condition>
               </action>
               <action name="USERSPACE: Add an executable to the dock (macOS)" id="576" beanClass="com.install4j.runtime.beans.actions.desktop.AddToDockAction" actionElevationType="none" rollbackBarrierExitCode="0">
                 <serializedBean>
@@ -832,9 +805,7 @@ context.getBooleanVariable("addToDockAction")</condition>
                   <property name="value" type="string">${installer:sys.contentDir}\${compiler:WRAPPER_SCRIPT_BIN_DIR}</property>
                   <property name="variableName" type="string">Path</property>
                 </serializedBean>
-                <condition>!Util.hasFullAdminRights()
-&amp;&amp;
-context.getBooleanVariable("appendToPathAction")</condition>
+                <condition>!Util.hasFullAdminRights() &amp;&amp; context.getBooleanVariable("appendToPathAction")</condition>
               </action>
               <action name="USERSPACE: Create macOS symbolic link to jalview in user's local bin" id="2743" beanClass="com.install4j.runtime.beans.actions.files.CreateSymlinkAction" rollbackBarrierExitCode="0" errorMessage="Could not make a ${compiler:WRAPPER_LINK} symbolic link in ~/${installer:unixBinDir}">
                 <serializedBean>
@@ -849,16 +820,15 @@ context.getBooleanVariable("appendToPathAction")</condition>
                     </object>
                   </property>
                 </serializedBean>
-                <condition>!Util.hasFullAdminRights()
+                <condition>Util.isMacOS() &amp;&amp; !Util.hasFullAdminRights() // Admin on macOS will add path to /etc/paths.d
 &amp;&amp;
 (
-  Util.isMacOS()
-  &amp;&amp; context.getBooleanVariable("makeUserSymbolicLinkAction")
+  context.getBooleanVariable("makeSymbolicLinkAction")
   &amp;&amp; context.getVariable("unixBinDir") != null
   &amp;&amp; context.getVariable("macWrapperLinkLocation") != null
 )</condition>
               </action>
-              <action name="Linux/Unix symlink" id="2733" beanClass="com.install4j.runtime.beans.actions.files.CreateSymlinkAction" rollbackBarrierExitCode="0" errorMessage="Could not make symlink to wrapper script">
+              <action name="Linux/Unix Jalview bin dir symlink" id="2733" beanClass="com.install4j.runtime.beans.actions.files.CreateSymlinkAction" rollbackBarrierExitCode="0" errorMessage="Could not make symlink to wrapper script">
                 <serializedBean>
                   <property name="file">
                     <object class="java.io.File">
@@ -871,11 +841,7 @@ context.getBooleanVariable("appendToPathAction")</condition>
                     </object>
                   </property>
                 </serializedBean>
-                <condition>( 
-  Util.isLinux()
-  || Util.isUnixInstaller()
-  || Util.isMacOS()
-)</condition>
+                <condition>Util.isLinux() || Util.isUnixInstaller() || Util.isMacOS()</condition>
               </action>
               <action name="Windows copy BAT file" id="2817" beanClass="com.install4j.runtime.beans.actions.files.CopyFileAction" rollbackBarrierExitCode="0">
                 <serializedBean>
@@ -933,9 +899,7 @@ context.getBooleanVariable("appendToPathAction")</condition>
                     </object>
                   </property>
                 </serializedBean>
-                <condition>Util.hasFullAdminRights()
-&amp;&amp;
-!context.getBooleanVariable("sys.programGroupDisabled")</condition>
+                <condition>Util.hasFullAdminRights() &amp;&amp; !context.getBooleanVariable("sys.programGroupDisabled")</condition>
               </action>
               <action name="SYSTEMSPACE: Add a desktop link" id="2847" beanClass="com.install4j.runtime.beans.actions.desktop.CreateDesktopLinkAction" actionElevationType="elevated" rollbackBarrierExitCode="0" errorMessage="Could not make desktop link">
                 <serializedBean>
@@ -958,9 +922,7 @@ context.getBooleanVariable("appendToPathAction")</condition>
                     </object>
                   </property>
                 </serializedBean>
-                <condition>Util.hasFullAdminRights()
-&amp;&amp;
-context.getBooleanVariable("createDesktopLinkAction")</condition>
+                <condition>Util.hasFullAdminRights() &amp;&amp; context.getBooleanVariable("createDesktopLinkAction")</condition>
               </action>
               <action name="SYSTEMSPACE: Add Jalview bin to the user's path (Windows)" id="2849" beanClass="com.install4j.runtime.beans.actions.misc.ModifyEnvironmentVariableAction" actionElevationType="elevated" rollbackBarrierExitCode="0" errorMessage="Could not add &quot;${installer:sys.contentDir}\${compiler:WRAPPER_SCRIPT_BIN_DIR}&quot; to the Path environment variable">
                 <serializedBean>
@@ -969,9 +931,7 @@ context.getBooleanVariable("createDesktopLinkAction")</condition>
                   <property name="value" type="string">${installer:sys.contentDir}\${compiler:WRAPPER_SCRIPT_BIN_DIR}</property>
                   <property name="variableName" type="string">Path</property>
                 </serializedBean>
-                <condition>Util.hasFullAdminRights()
-&amp;&amp;
-context.getBooleanVariable("appendToPathAction")</condition>
+                <condition>Util.hasFullAdminRights() &amp;&amp; context.getBooleanVariable("appendToPathAction")</condition>
               </action>
               <action name="SYSTEMSPACE: macOS /etc/paths.d entry" id="2852" beanClass="com.install4j.runtime.beans.actions.text.WriteTextFileAction" actionElevationType="elevated" rollbackBarrierExitCode="0">
                 <serializedBean>
@@ -982,8 +942,7 @@ context.getBooleanVariable("appendToPathAction")</condition>
                   </property>
                   <property name="text" type="string">/Applications/${compiler:JALVIEW_APPLICATION_NAME}.app/Contents/MacOS</property>
                 </serializedBean>
-                <condition>Util.hasFullAdminRights()
-&amp;&amp; Util.isMacOS()</condition>
+                <condition>Util.hasFullAdminRights() &amp;&amp; Util.isMacOS()</condition>
               </action>
               <action name="BOTHSPACE: Create Linux/Unix user symbolic link to jalview.sh in system bin" id="2850" beanClass="com.install4j.runtime.beans.actions.files.CreateSymlinkAction" rollbackBarrierExitCode="0" errorMessage="Could not make a ${compiler:WRAPPER_LINK} symbolic link in ~/${installer:unixBinDir}">
                 <serializedBean>
@@ -998,14 +957,9 @@ context.getBooleanVariable("appendToPathAction")</condition>
                     </object>
                   </property>
                 </serializedBean>
-                <condition>(
-  context.getBooleanVariable("makeUserSymbolicLinkAction")
-  &amp;&amp; (
-       Util.isLinux()
-       || Util.isUnixInstaller()
-     )
-  &amp;&amp; context.getVariable("unixBinDir") != null
-)</condition>
+                <condition>context.getBooleanVariable("makeSymbolicLinkAction")
+&amp;&amp; context.getVariable("unixBinDir") != null
+&amp;&amp; context.getBooleanVariable("makeSymbolicLink")</condition>
               </action>
             </actions>
             <formComponents>
@@ -1014,48 +968,56 @@ context.getBooleanVariable("appendToPathAction")</condition>
                   <property name="labelText" type="string">${form:finishedMessage}</property>
                 </serializedBean>
               </formComponent>
-              <formComponent name="Add a desktop link" id="574" beanClass="com.install4j.runtime.beans.formcomponents.CheckboxComponent" resetInitOnPrevious="true">
+              <formComponent name="USERSPACE: Add a desktop link (not macOS)" id="574" beanClass="com.install4j.runtime.beans.formcomponents.CheckboxComponent" resetInitOnPrevious="true">
                 <serializedBean>
                   <property name="checkboxText" type="string">${i18n:CreateDesktopIcon}</property>
                   <property name="variableName" type="string">createDesktopLinkAction</property>
                 </serializedBean>
-                <visibilityScript>!Util.isMacOS()
-&amp;&amp; !Util.hasFullAdminRights()
+                <visibilityScript>!Util.isMacOS() &amp;&amp; !Util.hasFullAdminRights()
 </visibilityScript>
               </formComponent>
-              <formComponent name="Add an executable to the dock" id="577" beanClass="com.install4j.runtime.beans.formcomponents.CheckboxComponent">
+              <formComponent name="USERSPACE: Add an executable to the dock (macOS)" id="577" beanClass="com.install4j.runtime.beans.formcomponents.CheckboxComponent">
                 <serializedBean>
                   <property name="checkboxText" type="string">${i18n:AddToDock}</property>
                   <property name="initiallySelected" type="boolean" value="true" />
                   <property name="variableName" type="string">addToDockAction</property>
                 </serializedBean>
-                <visibilityScript>Util.isMacOS()
-&amp;&amp; !Util.hasFullAdminRights()
+                <visibilityScript>Util.isMacOS() &amp;&amp; !Util.hasFullAdminRights()
 </visibilityScript>
               </formComponent>
-              <formComponent name="Add jalview bin to the user's Path environment variable (Windows)" id="2734" beanClass="com.install4j.runtime.beans.formcomponents.CheckboxComponent">
+              <formComponent name="USERSPACE: Add jalview bin to the user's Path environment variable (Windows)" id="2734" beanClass="com.install4j.runtime.beans.formcomponents.CheckboxComponent">
                 <serializedBean>
-                  <property name="checkboxText" type="string">Add ${compiler:JALVIEW_APPLICATION_NAME}'s bin folder to the Path environment variable</property>
+                  <property name="checkboxText" type="string">Add ${compiler:JALVIEW_APPLICATION_NAME}'s bin folder to your Path environment variable</property>
                   <property name="initiallySelected" type="boolean" value="true" />
                   <property name="variableName" type="string">appendToPathAction</property>
                 </serializedBean>
-                <visibilityScript>Util.isWindows()</visibilityScript>
+                <visibilityScript>Util.isWindows() &amp;&amp; !Util.hasFullAdminRights()</visibilityScript>
+              </formComponent>
+              <formComponent name="SYSTEMSPACE: Add jalview bin to all users' Path environment variable (Windows)" id="2854" beanClass="com.install4j.runtime.beans.formcomponents.CheckboxComponent">
+                <serializedBean>
+                  <property name="checkboxText" type="string">Add ${compiler:JALVIEW_APPLICATION_NAME}'s bin folder to the system Path environment variable</property>
+                  <property name="initiallySelected" type="boolean" value="true" />
+                  <property name="variableName" type="string">appendToPathAction</property>
+                </serializedBean>
+                <visibilityScript>Util.isWindows() &amp;&amp; Util.hasFullAdminRights()</visibilityScript>
               </formComponent>
               <formComponent name="BOTHSPACE: Make a symbolic link to jalview.sh bash script in the user's/system local bin (Linux or Unix)" id="2736" beanClass="com.install4j.runtime.beans.formcomponents.CheckboxComponent">
                 <serializedBean>
                   <property name="checkboxText" type="string">Make a ${compiler:WRAPPER_LINK} symbolic link in ${installer:unixBinDir}</property>
                   <property name="initiallySelected" type="boolean" value="true" />
-                  <property name="variableName" type="string">makeUserSymbolicLinkAction</property>
+                  <property name="variableName" type="string">makeSymbolicLinkAction</property>
                 </serializedBean>
-                <visibilityScript>(
-  Util.isLinux()
-  || Util.isUnixInstaller()
-  || (
-       Util.isMacOS()
-       &amp;&amp; context.getVariable("macWrapperLinkLocation") != null
-     )
- )
- &amp;&amp; context.getVariable("unixBinDir") != null</visibilityScript>
+                <visibilityScript>context.getBooleanVariable("makeSymbolicLink")
+&amp;&amp; context.getVariable("unixBinDir") != null
+&amp;&amp; (
+     Util.isLinux()
+     || Util.isUnixInstaller()
+     || (
+          ( Util.isMacOS() &amp;&amp; !Util.hasFullAdminRights() ) // Admin on macOS will add path to /etc/paths.d
+          &amp;&amp; context.getVariable("macWrapperLinkLocation") != null
+        )
+    )
+</visibilityScript>
               </formComponent>
             </formComponents>
           </screen>
@@ -1064,6 +1026,8 @@ context.getBooleanVariable("appendToPathAction")</condition>
       <application id="uninstaller" beanClass="com.install4j.runtime.beans.applications.UninstallerApplication" styleId="35">
         <serializedBean>
           <property name="customMacosExecutableName" type="string">${i18n:UninstallerMenuEntry(${compiler:sys.fullName})}</property>
+          <property name="frameHeight" type="int" value="480" />
+          <property name="frameWidth" type="int" value="640" />
           <property name="useCustomMacosExecutableName" type="boolean" value="true" />
         </serializedBean>
         <styleOverrides>
@@ -1406,13 +1370,14 @@ return console.askYesNo(message, true);
             </object>
           </property>
           <property name="executableName" type="string">${compiler:WRAPPER_LINK}_setup</property>
+          <property name="frameHeight" type="int" value="600" />
+          <property name="frameWidth" type="int" value="800" />
           <property name="windowTitle" type="string">${compiler:sys.fullName}</property>
         </serializedBean>
         <startup>
           <screen id="2747" beanClass="com.install4j.runtime.beans.screens.StartupScreen" rollbackBarrierExitCode="0">
             <actions>
               <link id="2749" targetId="22" />
-              <link id="2750" targetId="2738" />
               <link id="2751" targetId="2745" />
             </actions>
           </screen>
@@ -1444,7 +1409,7 @@ return console.askYesNo(message, true);
                 <serializedBean>
                   <property name="checkboxText" type="string">Make a ${compiler:WRAPPER_LINK} symbolic link in ${installer:unixBinDir}</property>
                   <property name="initiallySelected" type="boolean" value="true" />
-                  <property name="variableName" type="string">makeUserSymbolicLinkAction</property>
+                  <property name="variableName" type="string">makeSymbolicLinkAction</property>
                 </serializedBean>
                 <visibilityScript>
 
@@ -1774,7 +1739,7 @@ ${compiler:JALVIEW_APPLICATION_NAME} will now launch.</property>
         <file name=".VolumeIcon.icns" file="${compiler:JALVIEW_DIR}/${compiler:MACOSARCHIVE_VOLUMEICON}" />
       </topLevelFiles>
     </macosArchive>
-    <unixInstaller name="Linux x64 Shell Installer" id="1595" customizedId="LINUX-X64-SH" mediaFileName="${compiler:UNIX_APPLICATION_FOLDER}-${compiler:JALVIEW_VERSION}-linux-x64-java_${compiler:JAVA_INTEGER_VERSION}" installDir="${compiler:UNIX_APPLICATION_FOLDER}" customInstallBaseDir="~/opt/">
+    <unixInstaller name="Linux x64 Shell Installer" id="1595" customizedId="LINUX-X64-SH" mediaFileName="${compiler:UNIX_APPLICATION_FOLDER}-${compiler:JALVIEW_VERSION}-linux-x64-java_${compiler:JAVA_INTEGER_VERSION}" installDir="${compiler:UNIX_APPLICATION_FOLDER}">
       <excludedBeans>
         <bean refId="2746" />
       </excludedBeans>
@@ -1789,7 +1754,7 @@ ${compiler:JALVIEW_APPLICATION_NAME} will now launch.</property>
       </variables>
       <jreBundle jreBundleSource="preCreated" includedJre="${compiler:LINUX_X64_JAVA_VM_TGZ}" manualJreEntry="true" />
     </unixInstaller>
-    <unixInstaller name="Linux aarch64 Shell Installer" id="2782" customizedId="LINUX-AARCH64-SH" mediaFileName="${compiler:UNIX_APPLICATION_FOLDER}-${compiler:JALVIEW_VERSION}-linux-aarch64-java_${compiler:JAVA_INTEGER_VERSION}" installDir="${compiler:UNIX_APPLICATION_FOLDER}" customInstallBaseDir="~/opt/">
+    <unixInstaller name="Linux aarch64 Shell Installer" id="2782" customizedId="LINUX-AARCH64-SH" mediaFileName="${compiler:UNIX_APPLICATION_FOLDER}-${compiler:JALVIEW_VERSION}-linux-aarch64-java_${compiler:JAVA_INTEGER_VERSION}" installDir="${compiler:UNIX_APPLICATION_FOLDER}">
       <excludedBeans>
         <bean refId="2746" />
       </excludedBeans>
@@ -1815,7 +1780,7 @@ ${compiler:JALVIEW_APPLICATION_NAME} will now launch.</property>
       </exclude>
       <jreBundle jreBundleSource="none" includedJre="${compiler:LINUX_X64_JAVA_VM_TGZ}" manualJreEntry="true" />
     </unixArchive>
-    <unixInstaller name="Unix Shell Installer" id="2639" customizedId="UNIX--SH" mediaFileName="${compiler:UNIX_APPLICATION_FOLDER}-${compiler:JALVIEW_VERSION}-${compiler:sys.platform}-java_${compiler:JAVA_INTEGER_VERSION}" installDir="${compiler:UNIX_APPLICATION_FOLDER}" customInstallBaseDir="~/opt/">
+    <unixInstaller name="Unix Shell Installer" id="2639" customizedId="UNIX--SH" mediaFileName="${compiler:UNIX_APPLICATION_FOLDER}-${compiler:JALVIEW_VERSION}-${compiler:sys.platform}-java_${compiler:JAVA_INTEGER_VERSION}" installDir="${compiler:UNIX_APPLICATION_FOLDER}">
       <excludedBeans>
         <bean refId="2746" />
       </excludedBeans>