JAL-3631 Create an installer.properties file in the userappdir
authorBen Soares <b.soares@dundee.ac.uk>
Mon, 26 Aug 2024 16:43:29 +0000 (17:43 +0100)
committerBen Soares <b.soares@dundee.ac.uk>
Mon, 26 Aug 2024 16:43:29 +0000 (17:43 +0100)
getdown/lib/getdown-core.jar
getdown/lib/getdown-launcher-local.jar
getdown/lib/getdown-launcher.jar
getdown/src/getdown/core/src/main/java/com/threerings/getdown/data/Application.java
getdown/src/getdown/core/src/main/java/com/threerings/getdown/data/EnvConfig.java
j11lib/getdown-core.jar
j8lib/getdown-core.jar

index 62d0343..652c6c4 100644 (file)
Binary files a/getdown/lib/getdown-core.jar and b/getdown/lib/getdown-core.jar differ
index 82102c2..a393030 100644 (file)
Binary files a/getdown/lib/getdown-launcher-local.jar and b/getdown/lib/getdown-launcher-local.jar differ
index 195c369..faaba1e 100644 (file)
Binary files a/getdown/lib/getdown-launcher.jar and b/getdown/lib/getdown-launcher.jar differ
index 12c2b64..19f4030 100644 (file)
@@ -23,8 +23,8 @@ import java.nio.file.Files;
 import java.nio.file.StandardCopyOption;
 import java.security.*;
 import java.security.cert.Certificate;
-import java.util.*;
 import java.util.concurrent.*;
+import java.util.*;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 import java.util.zip.GZIPInputStream;
@@ -1092,7 +1092,7 @@ public class Application
         args.add("-Dlauncher.version=" + Build.version());
         addSystemPropertyIfNotNull(args, "installer.appdir");
         // add the marker indicating the app is running in getdown
-        args.add("-D" + Properties.GETDOWN + "=true");
+        args.add("-D" + com.threerings.getdown.data.Properties.GETDOWN + "=true");
         args.add("-Dsys.install4jVersion=" + Application.i4jVersion);
         addSystemPropertyIfNotNull(args, "installer.template_version");
         addSystemPropertyIfNotNull(args, "installer.logfile");
@@ -2139,6 +2139,27 @@ public class Application
         }
       }
       
+      final String installerPropsFilename = "installer.properties";
+      log.info("Creating " + installerPropsFilename);
+      java.util.Properties installerProps = new java.util.Properties();
+      installerProps.setProperty("installer.appdir", applicationAppDir.getAbsolutePath());
+      installerProps.setProperty("installer.appdirhash", EnvConfig.getAppDirHash());
+      for ( String key: new String[] {"installer.template_version", "installer.application_folder", "installer.icon", "installer.mac_icons", "installer.logfile", "installer.logfile_append"}) {
+          String val = System.getProperty(key);
+          if (val != null) {
+            installerProps.put(key, val);
+          }
+      }
+      for (String prop: installerProps.stringPropertyNames()) {
+        log.info("Adding property '" + prop + "'='" + installerProps.getProperty(prop) + "' to " + installerPropsFilename);
+      }
+      File installerPropsFile = new File(userAppDir, installerPropsFilename);
+      try {
+        installerProps.store(new FileOutputStream(installerPropsFile.getAbsolutePath()), "Created by installer launcher in " + applicationAppDir);
+      } catch (IOException e) {
+        log.warning("Could not write installer properties file '" + installerPropsFile.getAbsolutePath() + "'");
+      }
+      
       MessageDigest md = Digest.getMessageDigest(Digest.VERSION);
       for (Resource rsc: copyResources) {
         String digestHash = digest2.getDigest(rsc);
index dbd60cf..dd163d3 100644 (file)
@@ -381,9 +381,8 @@ public final class EnvConfig {
       }
       String appname = StringUtil.isBlank(appName) ? ChannelProperties.FALLBACK_APPNAME : appName;
       final String FS = File.separator;
-      String appDirHash;
       try {
-        appDirHash = getFullPathToDirectoryHash(new File(installerAppdir).getCanonicalPath());
+        setAppDirHash(installerAppdir);
       } catch (IOException ioex) {
         System.err.println("Unable to resolve '"+installerAppdir+"' as a proper path on this system.\nNot generating a user local appdir - getdown may fail to update!");
         return null;
@@ -421,7 +420,7 @@ public final class EnvConfig {
       }
       sb.append(appDataPath).append(FS);
       sb.append(append).append(FS);
-      sb.append(appDirHash).append(FS);
+      sb.append(getAppDirHash()).append(FS);
       sb.append("app");
       return sb.toString();
     }
@@ -454,6 +453,14 @@ public final class EnvConfig {
       appName = System.getProperty("channel.app_name");
     }
     
+    public static String getAppDirHash() {
+      return appDirHash;
+    }
+    
+    public static void setAppDirHash(String path) throws IOException {
+      appDirHash = getFullPathToDirectoryHash(new File(path).getCanonicalPath());
+    }
+    
     private static boolean relaunched = false;
     
     private static final String USER_HOME_KEY = "${user.home}";
@@ -464,6 +471,8 @@ public final class EnvConfig {
     
     private static String appName = null;
     
+    private static String appDirHash = null;
+    
     public static final String USER_DEFAULT_APPDIR_PROPERTY = "userdefaultappdir";
     
     protected static final String APPLICATION_APPDIR_PROPERTY = "installer.appdir";
index 62d0343..652c6c4 100644 (file)
Binary files a/j11lib/getdown-core.jar and b/j11lib/getdown-core.jar differ
index 62d0343..652c6c4 100644 (file)
Binary files a/j8lib/getdown-core.jar and b/j8lib/getdown-core.jar differ