JAL-3631 Made bespoke command line arguments for console or unattended installs only...
authorBen Soares <b.soares@dundee.ac.uk>
Tue, 6 Aug 2024 23:50:30 +0000 (00:50 +0100)
committerBen Soares <b.soares@dundee.ac.uk>
Tue, 6 Aug 2024 23:50:30 +0000 (00:50 +0100)
utils/install4j/install4j10_template.install4j

index 774a318..8dcd9ac 100644 (file)
@@ -789,16 +789,6 @@ return MacOSDir;
                   <property name="variableName" type="string">allowInstallerAppdirUpdates</property>
                 </serializedBean>
               </action>
-              <action name="SYSTEMSPACE: Set disableAllUpdates" id="3075" 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">Boolean.FALSE</property>
-                    </object>
-                  </property>
-                  <property name="variableName" type="string">disableAllUpdates</property>
-                </serializedBean>
-              </action>
               <action name="BOTHSPACE: Set userDefaultAppdirBase for tooltip explanation" id="2981" beanClass="com.install4j.runtime.beans.actions.control.SetVariableAction" rollbackBarrierExitCode="0">
                 <serializedBean>
                   <property name="script">
@@ -826,6 +816,36 @@ return context.getCompilerVariable("sys.platform");</property>
                   <property name="variableName" type="string">osName</property>
                 </serializedBean>
               </action>
+              <action name="CONSOLE: Set consoleDisableUserAppdir" id="3075" 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">Boolean.FALSE</property>
+                    </object>
+                  </property>
+                  <property name="variableName" type="string">consoleDisableUserAppdir</property>
+                </serializedBean>
+              </action>
+              <action name="CONSOLE: Set consoleDisableAllUpdates" id="3076" 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">Boolean.FALSE</property>
+                    </object>
+                  </property>
+                  <property name="variableName" type="string">consoleDisableAllUpdates</property>
+                </serializedBean>
+              </action>
+              <action name="CONSOLE: Set consoleAllowUserAppdirPath" id="3077" 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">Boolean.FALSE</property>
+                    </object>
+                  </property>
+                  <property name="variableName" type="string">consoleAllowUserAppdirPath</property>
+                </serializedBean>
+              </action>
               <action name="Extra Command Line Options" id="3074" beanClass="com.install4j.runtime.beans.actions.control.RunScriptAction" rollbackBarrierExitCode="0">
                 <serializedBean>
                   <property name="script">
@@ -847,17 +867,14 @@ for (int i = 0; i &lt; args.length; i++) {
                 System.out.println("Option " + arg + " requires a value.  Ignoring.");
             }
             context.setVariable("userAppdirPath", args[i + 1]);
-            context.setVariable("advancedOptions", true);
-            context.setVariable("allowSetUserAppdirPath", true);
+            context.setVariable("consoleAllowUserAppdirPath", true);
             i++;        
             break;
         case "-U":
-            context.setVariable("allowUserDefaultAppdirUpdates", false);
-            context.setVariable("advancedOptions", true);
+            context.setVariable("consoleDisableUserAppdir", true);
             break;
         case "-S":
-            context.setVariable("disableAllUpdates", true);
-            context.setVariable("advancedOptions", true);
+            context.setVariable("consoleDisableAllUpdates", true);
             break;
         default:
             System.out.println("Option " + arg + " not recognised.  Ignoring.");
@@ -869,6 +886,7 @@ return true;</property>
                     </object>
                   </property>
                 </serializedBean>
+                <condition>context.isConsole() || context.isUnattended()</condition>
               </action>
             </actions>
           </screen>
@@ -1999,7 +2017,10 @@ return (Object) hash;
                         <object class="com.install4j.api.beans.ScriptProperty">
                           <property name="value" type="string">boolean advanced = context.getBooleanVariable("advancedOptions");
 boolean allowUser = context.getBooleanVariable("allowUserDefaultAppdirUpdates");
-
+boolean consoleDisableUserAppdir = context.getBooleanVariable("consoleDisableUserAppdir");
+if (consoleDisableUserAppdir) {
+    return true;
+}
 return advanced ? !allowUser : false;</property>
                         </object>
                       </property>
@@ -2015,7 +2036,10 @@ boolean allowUser = context.getBooleanVariable("allowUserDefaultAppdirUpdates");
 boolean allowSetUserAppdirPath = context.getBooleanVariable("allowSetUserAppdirPath");
 String userAppdirPath = (String)context.getVariable("userAppdirPath");
 boolean saneValue = userAppdirPath != null &amp;&amp; userAppdirPath.length() &gt; 0;
-
+boolean consoleAllowUserAppdirPath = context.getBooleanVariable("consoleAllowUserAppdirPath");
+if (consoleAllowUserAppdirPath &amp;&amp; saneValue) {
+    return userAppdirPath;
+}
 return advanced &amp;&amp; allowUser &amp;&amp; allowSetUserAppdirPath &amp;&amp; saneValue ? userAppdirPath : null;</property>
                         </object>
                       </property>
@@ -2029,9 +2053,11 @@ return advanced &amp;&amp; allowUser &amp;&amp; allowSetUserAppdirPath &amp;&amp
                           <property name="value" type="string">boolean advanced = context.getBooleanVariable("advancedOptions");
 boolean allowUser = context.getBooleanVariable("allowUserDefaultAppdirUpdates");
 boolean allowInstaller = context.getBooleanVariable("allowInstallerAppdirUpdates");
-boolean disableAllUpdates = context.getBooleanVariable("disableAllUpdates");
-
-return advanced ? disableAllUpdates || !( allowUser || allowInstaller ) : false;</property>
+boolean consoleDisableAllUpdates = context.getBooleanVariable("consoleDisableAllUpdates");
+if (consoleDisableAllUpdates) {
+    return true;
+}
+return advanced ? !( allowUser || allowInstaller ) : false;</property>
                         </object>
                       </property>
                       <property name="variableName" type="string">disableUpdates</property>