From: Ben Soares Date: Mon, 26 Aug 2024 16:43:29 +0000 (+0100) Subject: JAL-3631 Create an installer.properties file in the userappdir X-Git-Tag: Release_2_11_4_0~14^2~8^2~7 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=451d5c6724dd5ed4c42f8546553f97e2e9b686da;p=jalview.git JAL-3631 Create an installer.properties file in the userappdir --- diff --git a/getdown/lib/getdown-core.jar b/getdown/lib/getdown-core.jar index 62d0343..652c6c4 100644 Binary files a/getdown/lib/getdown-core.jar and b/getdown/lib/getdown-core.jar differ diff --git a/getdown/lib/getdown-launcher-local.jar b/getdown/lib/getdown-launcher-local.jar index 82102c2..a393030 100644 Binary files a/getdown/lib/getdown-launcher-local.jar and b/getdown/lib/getdown-launcher-local.jar differ diff --git a/getdown/lib/getdown-launcher.jar b/getdown/lib/getdown-launcher.jar index 195c369..faaba1e 100644 Binary files a/getdown/lib/getdown-launcher.jar and b/getdown/lib/getdown-launcher.jar differ diff --git a/getdown/src/getdown/core/src/main/java/com/threerings/getdown/data/Application.java b/getdown/src/getdown/core/src/main/java/com/threerings/getdown/data/Application.java index 12c2b64..19f4030 100644 --- a/getdown/src/getdown/core/src/main/java/com/threerings/getdown/data/Application.java +++ b/getdown/src/getdown/core/src/main/java/com/threerings/getdown/data/Application.java @@ -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); diff --git a/getdown/src/getdown/core/src/main/java/com/threerings/getdown/data/EnvConfig.java b/getdown/src/getdown/core/src/main/java/com/threerings/getdown/data/EnvConfig.java index dbd60cf..dd163d3 100644 --- a/getdown/src/getdown/core/src/main/java/com/threerings/getdown/data/EnvConfig.java +++ b/getdown/src/getdown/core/src/main/java/com/threerings/getdown/data/EnvConfig.java @@ -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"; diff --git a/j11lib/getdown-core.jar b/j11lib/getdown-core.jar index 62d0343..652c6c4 100644 Binary files a/j11lib/getdown-core.jar and b/j11lib/getdown-core.jar differ diff --git a/j8lib/getdown-core.jar b/j8lib/getdown-core.jar index 62d0343..652c6c4 100644 Binary files a/j8lib/getdown-core.jar and b/j8lib/getdown-core.jar differ