JAL-3631 Added install4j installer command line options -a -u -U and -S to match...
authorBen Soares <b.soares@dundee.ac.uk>
Tue, 6 Aug 2024 19:13:17 +0000 (20:13 +0100)
committerBen Soares <b.soares@dundee.ac.uk>
Tue, 6 Aug 2024 19:13:17 +0000 (20:13 +0100)
utils/install4j/install4j10_template.install4j

index b3bf0a9..774a318 100644 (file)
@@ -789,6 +789,16 @@ 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">
@@ -816,6 +826,50 @@ return context.getCompilerVariable("sys.platform");</property>
                   <property name="variableName" type="string">osName</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">
+                    <object class="com.install4j.api.beans.ScriptProperty">
+                      <property name="value" type="string">String[] args = context.getExtraCommandLineArguments();
+
+for (int i = 0; i &lt; args.length; i++) {
+    String arg = args[i];
+    switch(arg) {
+        case "-a":
+            if (args.length - 1 &lt; i + 1) {
+                System.out.println("Option " + arg + " requires a value.  Ignoring.");
+            }
+            context.setInstallationDirectory(new File(args[i + 1]));
+            i++;
+            break;
+        case "-u":
+            if (args.length - 1 &lt; i + 1) {
+                System.out.println("Option " + arg + " requires a value.  Ignoring.");
+            }
+            context.setVariable("userAppdirPath", args[i + 1]);
+            context.setVariable("advancedOptions", true);
+            context.setVariable("allowSetUserAppdirPath", true);
+            i++;        
+            break;
+        case "-U":
+            context.setVariable("allowUserDefaultAppdirUpdates", false);
+            context.setVariable("advancedOptions", true);
+            break;
+        case "-S":
+            context.setVariable("disableAllUpdates", true);
+            context.setVariable("advancedOptions", true);
+            break;
+        default:
+            System.out.println("Option " + arg + " not recognised.  Ignoring.");
+            break;
+    }
+}
+
+return true;</property>
+                    </object>
+                  </property>
+                </serializedBean>
+              </action>
             </actions>
           </screen>
         </startup>
@@ -1005,14 +1059,12 @@ for (com.install4j.api.actions.Action a : context.getActions(s2)) {
         boolean set = aid.endsWith("-true");
         boolean got = aa.isSelected();
         aa.setSelected(set);
-        System.err.println("##### Setting '"+aid+"' from "+got+" to "+set);
+        System.err.println("Setting '"+aid+"' from "+got+" to "+set);
     }
 }
 
-//context.gotoScreen(s);
-//boolean b = formEnvironment.saveFormComponents();
-//System.err.println("##### saveFormComponents was "+b);
-formEnvironment.reinitializeFormComponents();</property>
+context.gotoScreen(s);
+//formEnvironment.reinitializeFormComponents();</property>
                     </object>
                   </property>
                   <property name="buttonText" type="string">Reset</property>
@@ -1897,9 +1949,7 @@ return context.getBooleanVariable("allowUserDefaultAppdirUpdates") &amp;&amp; co
                       <property name="script">
                         <object class="com.install4j.api.beans.ScriptProperty">
                           <property name="value" type="string">String dir = (String)context.getVariable("sys.installationDir");
-System.out.println("##### sys.installationDir = " + dir);
 String hash = getCanonicalFullPathToDirectoryHash(dir);
-System.out.println("##### sys.installationDir hash = " + dir);
 return (Object) hash;
 </property>
                         </object>
@@ -1979,8 +2029,9 @@ 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 ? !( allowUser || allowInstaller ) : false;</property>
+return advanced ? disableAllUpdates || !( allowUser || allowInstaller ) : false;</property>
                         </object>
                       </property>
                       <property name="variableName" type="string">disableUpdates</property>