enable custom java local dir instead of hardcoded "java_vm"
This commit is contained in:
@@ -0,0 +1,20 @@
|
|||||||
|
[*]
|
||||||
|
charset=utf-8
|
||||||
|
end_of_line=lf
|
||||||
|
indent_size=2
|
||||||
|
indent_style=space
|
||||||
|
insert_final_newline=true
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
|
||||||
|
[*.java]
|
||||||
|
indent_size=4
|
||||||
|
|
||||||
|
# also configure imports order manually as follows:
|
||||||
|
# import java.*
|
||||||
|
# <blank line>
|
||||||
|
# import javax.*
|
||||||
|
# <blank line>
|
||||||
|
# import com.samskivert.*
|
||||||
|
# import com.threerings.*
|
||||||
|
# import all other imports
|
||||||
|
# import static all other imports
|
||||||
@@ -1,3 +1,9 @@
|
|||||||
/*/target/
|
/*/target/
|
||||||
/target/
|
/target/
|
||||||
core/src/main/java/com/threerings/getdown/data/Build.java
|
core/src/main/java/com/threerings/getdown/data/Build.java
|
||||||
|
|
||||||
|
# IntelliJ IDEA
|
||||||
|
.idea/
|
||||||
|
*.iml
|
||||||
|
*.ipr
|
||||||
|
*.iws
|
||||||
|
|||||||
@@ -32,8 +32,7 @@ import static com.threerings.getdown.Log.log;
|
|||||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parses and provide access to the information contained in the <code>getdown.txt</code>
|
* Parses and provide access to the information contained in the {@code getdown.txt} configuration file.
|
||||||
* configuration file.
|
|
||||||
*/
|
*/
|
||||||
public class Application
|
public class Application
|
||||||
{
|
{
|
||||||
@@ -211,10 +210,10 @@ public class Application
|
|||||||
* Used by {@link #verifyMetadata} to communicate status in circumstances where it needs to
|
* Used by {@link #verifyMetadata} to communicate status in circumstances where it needs to
|
||||||
* take network actions.
|
* take network actions.
|
||||||
*/
|
*/
|
||||||
public static interface StatusDisplay
|
public interface StatusDisplay
|
||||||
{
|
{
|
||||||
/** Requests that the specified status message be displayed. */
|
/** Requests that the specified status message be displayed. */
|
||||||
public void updateStatus (String message);
|
void updateStatus (String message);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -238,13 +237,12 @@ public class Application
|
|||||||
public Proxy proxy = Proxy.NO_PROXY;
|
public Proxy proxy = Proxy.NO_PROXY;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an application instance which records the location of the <code>getdown.txt</code>
|
* Creates an application instance which records the location of the {@code getdown.txt}
|
||||||
* configuration file from the supplied application directory.
|
* configuration file from the supplied application directory.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public Application (EnvConfig envc) {
|
public Application (EnvConfig envc) {
|
||||||
_envc = envc;
|
_envc = envc;
|
||||||
_config = getLocalPath(envc.appDir, CONFIG_FILE);
|
_config = new File(envc.appDir, CONFIG_FILE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -368,8 +366,7 @@ public class Application
|
|||||||
*/
|
*/
|
||||||
public List<Resource> getActiveCodeResources ()
|
public List<Resource> getActiveCodeResources ()
|
||||||
{
|
{
|
||||||
ArrayList<Resource> codes = new ArrayList<>();
|
List<Resource> codes = new ArrayList<>(getCodeResources());
|
||||||
codes.addAll(getCodeResources());
|
|
||||||
for (AuxGroup aux : getAuxGroups()) {
|
for (AuxGroup aux : getAuxGroups()) {
|
||||||
if (isAuxGroupActive(aux.name)) {
|
if (isAuxGroupActive(aux.name)) {
|
||||||
codes.addAll(aux.codes);
|
codes.addAll(aux.codes);
|
||||||
@@ -397,8 +394,7 @@ public class Application
|
|||||||
*/
|
*/
|
||||||
public List<Resource> getActiveResources ()
|
public List<Resource> getActiveResources ()
|
||||||
{
|
{
|
||||||
ArrayList<Resource> rsrcs = new ArrayList<>();
|
List<Resource> rsrcs = new ArrayList<>(getResources());
|
||||||
rsrcs.addAll(getResources());
|
|
||||||
for (AuxGroup aux : getAuxGroups()) {
|
for (AuxGroup aux : getAuxGroups()) {
|
||||||
if (isAuxGroupActive(aux.name)) {
|
if (isAuxGroupActive(aux.name)) {
|
||||||
rsrcs.addAll(aux.rsrcs);
|
rsrcs.addAll(aux.rsrcs);
|
||||||
@@ -435,7 +431,15 @@ public class Application
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a resource for a zip file containing a Java VM that can be downloaded to use in
|
* @return directory into which a local VM installation should be unpacked.
|
||||||
|
*/
|
||||||
|
public File getJavaLocalDir ()
|
||||||
|
{
|
||||||
|
return _javaLocalDir;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return a resource for a zip file containing a Java VM that can be downloaded to use in
|
||||||
* place of the installed VM (in the case where the VM that launched Getdown does not meet the
|
* place of the installed VM (in the case where the VM that launched Getdown does not meet the
|
||||||
* application's version requirements) or null if no VM is available for this platform.
|
* application's version requirements) or null if no VM is available for this platform.
|
||||||
*/
|
*/
|
||||||
@@ -445,7 +449,7 @@ public class Application
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
String vmfile = LaunchUtil.LOCAL_JAVA_DIR + ".jar";
|
String vmfile = _javaLocalDir.getName() + ".jar";
|
||||||
try {
|
try {
|
||||||
URL remote = new URL(createVAppBase(_targetVersion), encodePath(_javaLocation));
|
URL remote = new URL(createVAppBase(_targetVersion), encodePath(_javaLocation));
|
||||||
return new Resource(vmfile, remote, getLocalPath(vmfile),
|
return new Resource(vmfile, remote, getLocalPath(vmfile),
|
||||||
@@ -591,7 +595,7 @@ public class Application
|
|||||||
_vappbase = createVAppBase(_version);
|
_vappbase = createVAppBase(_version);
|
||||||
} catch (MalformedURLException mue) {
|
} catch (MalformedURLException mue) {
|
||||||
String err = MessageUtil.tcompose("m.invalid_appbase", _appbase);
|
String err = MessageUtil.tcompose("m.invalid_appbase", _appbase);
|
||||||
throw (IOException) new IOException(err).initCause(mue);
|
throw new IOException(err, mue);
|
||||||
}
|
}
|
||||||
|
|
||||||
// check for a latest config URL
|
// check for a latest config URL
|
||||||
@@ -645,6 +649,9 @@ public class Application
|
|||||||
_javaLocation = (String)javaloc;
|
_javaLocation = (String)javaloc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// used only in conjunction with java_location
|
||||||
|
_javaLocalDir = getLocalPath(config.getString("java_local_dir", LaunchUtil.LOCAL_JAVA_DIR));
|
||||||
|
|
||||||
// determine whether we have any tracking configuration
|
// determine whether we have any tracking configuration
|
||||||
_trackingURL = config.getString("tracking_url");
|
_trackingURL = config.getString("tracking_url");
|
||||||
|
|
||||||
@@ -753,7 +760,7 @@ public class Application
|
|||||||
/**
|
/**
|
||||||
* Adds strings of the form pair0=pair1 to collector for each pair parsed out of pairLocation.
|
* Adds strings of the form pair0=pair1 to collector for each pair parsed out of pairLocation.
|
||||||
*/
|
*/
|
||||||
protected void fillAssignmentListFromPairs (String pairLocation, List<String> collector)
|
protected void fillAssignmentListFromPairs (String pairLocation, Collection<String> collector)
|
||||||
{
|
{
|
||||||
File pairFile = getLocalPath(pairLocation);
|
File pairFile = getLocalPath(pairLocation);
|
||||||
if (pairFile.exists()) {
|
if (pairFile.exists()) {
|
||||||
@@ -787,7 +794,7 @@ public class Application
|
|||||||
*/
|
*/
|
||||||
public File getLocalPath (String path)
|
public File getLocalPath (String path)
|
||||||
{
|
{
|
||||||
return getLocalPath(getAppDir(), path);
|
return new File(getAppDir(), path);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -810,8 +817,7 @@ public class Application
|
|||||||
// if we have an unpacked VM, check the 'release' file for its version
|
// if we have an unpacked VM, check the 'release' file for its version
|
||||||
Resource vmjar = getJavaVMResource();
|
Resource vmjar = getJavaVMResource();
|
||||||
if (vmjar != null && vmjar.isMarkedValid()) {
|
if (vmjar != null && vmjar.isMarkedValid()) {
|
||||||
File vmdir = new File(getAppDir(), LaunchUtil.LOCAL_JAVA_DIR);
|
File relfile = new File(_javaLocalDir, "release");
|
||||||
File relfile = new File(vmdir, "release");
|
|
||||||
if (!relfile.exists()) {
|
if (!relfile.exists()) {
|
||||||
log.warning("Unpacked JVM missing 'release' file. Assuming valid version.");
|
log.warning("Unpacked JVM missing 'release' file. Assuming valid version.");
|
||||||
return true;
|
return true;
|
||||||
@@ -868,7 +874,7 @@ public class Application
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attempts to redownload the <code>getdown.txt</code> file based on information parsed from a
|
* Attempts to redownload the {@code getdown.txt} file based on information parsed from a
|
||||||
* previous call to {@link #init}.
|
* previous call to {@link #init}.
|
||||||
*/
|
*/
|
||||||
public void attemptRecovery (StatusDisplay status)
|
public void attemptRecovery (StatusDisplay status)
|
||||||
@@ -879,7 +885,7 @@ public class Application
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Downloads and replaces the <code>getdown.txt</code> and <code>digest.txt</code> files with
|
* Downloads and replaces the {@code getdown.txt} and {@code digest.txt} files with
|
||||||
* those for the target version of our application.
|
* those for the target version of our application.
|
||||||
*/
|
*/
|
||||||
public void updateMetadata ()
|
public void updateMetadata ()
|
||||||
@@ -890,7 +896,7 @@ public class Application
|
|||||||
_vappbase = createVAppBase(_targetVersion);
|
_vappbase = createVAppBase(_targetVersion);
|
||||||
} catch (MalformedURLException mue) {
|
} catch (MalformedURLException mue) {
|
||||||
String err = MessageUtil.tcompose("m.invalid_appbase", _appbase);
|
String err = MessageUtil.tcompose("m.invalid_appbase", _appbase);
|
||||||
throw (IOException) new IOException(err).initCause(mue);
|
throw new IOException(err, mue);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -926,10 +932,10 @@ public class Application
|
|||||||
public Process createProcess (boolean optimum)
|
public Process createProcess (boolean optimum)
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
ArrayList<String> args = new ArrayList<>();
|
List<String> args = new ArrayList<>();
|
||||||
|
|
||||||
// reconstruct the path to the JVM
|
// reconstruct the path to the JVM
|
||||||
args.add(LaunchUtil.getJVMPath(getAppDir(), _windebug || optimum));
|
args.add(LaunchUtil.getJVMBinaryPath(_javaLocalDir, _windebug || optimum));
|
||||||
|
|
||||||
// check whether we're using -jar mode or -classpath mode
|
// check whether we're using -jar mode or -classpath mode
|
||||||
boolean dashJarMode = MANIFEST_CLASS.equals(_class);
|
boolean dashJarMode = MANIFEST_CLASS.equals(_class);
|
||||||
@@ -1126,8 +1132,8 @@ public class Application
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads the <code>digest.txt</code> file and verifies the contents of both that file and the
|
* Loads the {@code digest.txt} file and verifies the contents of both that file and the
|
||||||
* <code>getdown.text</code> file. Then it loads the <code>version.txt</code> and decides
|
* {@code getdown.text} file. Then it loads the {@code version.txt} and decides
|
||||||
* whether or not the application needs to be updated or whether we can proceed to verification
|
* whether or not the application needs to be updated or whether we can proceed to verification
|
||||||
* and execution.
|
* and execution.
|
||||||
*
|
*
|
||||||
@@ -1421,7 +1427,7 @@ public class Application
|
|||||||
protected URL createVAppBase (long version)
|
protected URL createVAppBase (long version)
|
||||||
throws MalformedURLException
|
throws MalformedURLException
|
||||||
{
|
{
|
||||||
String url = version < 0 ? _appbase : _appbase.replace("%VERSION%", "" + version);
|
String url = version < 0 ? _appbase : _appbase.replace("%VERSION%", String.valueOf(version));
|
||||||
return HostWhitelist.verify(new URL(url));
|
return HostWhitelist.verify(new URL(url));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1546,7 +1552,6 @@ public class Application
|
|||||||
|
|
||||||
if (!sig.verify(Base64.decode(signature, Base64.DEFAULT))) {
|
if (!sig.verify(Base64.decode(signature, Base64.DEFAULT))) {
|
||||||
log.info("Signature does not match", "cert", cert.getPublicKey());
|
log.info("Signature does not match", "cert", cert.getPublicKey());
|
||||||
continue;
|
|
||||||
} else {
|
} else {
|
||||||
log.info("Signature matches", "cert", cert.getPublicKey());
|
log.info("Signature matches", "cert", cert.getPublicKey());
|
||||||
validated++;
|
validated++;
|
||||||
@@ -1592,7 +1597,7 @@ public class Application
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.warning("Requested to download invalid control file",
|
log.warning("Requested to download invalid control file",
|
||||||
"appbase", _vappbase, "path", path, "error", e);
|
"appbase", _vappbase, "path", path, "error", e);
|
||||||
throw (IOException) new IOException("Invalid path '" + path + "'.").initCause(e);
|
throw new IOException("Invalid path '" + path + "'.", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
log.info("Attempting to refetch '" + path + "' from '" + targetURL + "'.");
|
log.info("Attempting to refetch '" + path + "' from '" + targetURL + "'.");
|
||||||
@@ -1627,11 +1632,9 @@ public class Application
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Helper function to add all values in {@code values} (if non-null) to {@code target}. */
|
/** Helper function to add all values in {@code values} (if non-null) to {@code target}. */
|
||||||
protected static void addAll (String[] values, List<String> target) {
|
protected static void addAll (String[] values, Collection<String> target) {
|
||||||
if (values != null) {
|
if (values != null) {
|
||||||
for (String value : values) {
|
Collections.addAll(target, values);
|
||||||
target.add(value);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1713,11 +1716,6 @@ public class Application
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected File getLocalPath (File appdir, String path)
|
|
||||||
{
|
|
||||||
return new File(appdir, path);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected final EnvConfig _envc;
|
protected final EnvConfig _envc;
|
||||||
protected File _config;
|
protected File _config;
|
||||||
protected Digest _digest;
|
protected Digest _digest;
|
||||||
@@ -1749,6 +1747,7 @@ public class Application
|
|||||||
protected long _javaMinVersion, _javaMaxVersion;
|
protected long _javaMinVersion, _javaMaxVersion;
|
||||||
protected boolean _javaExactVersionRequired;
|
protected boolean _javaExactVersionRequired;
|
||||||
protected String _javaLocation;
|
protected String _javaLocation;
|
||||||
|
protected File _javaLocalDir;
|
||||||
|
|
||||||
protected List<Resource> _codes = new ArrayList<>();
|
protected List<Resource> _codes = new ArrayList<>();
|
||||||
protected List<Resource> _resources = new ArrayList<>();
|
protected List<Resource> _resources = new ArrayList<>();
|
||||||
@@ -1766,9 +1765,6 @@ public class Application
|
|||||||
|
|
||||||
protected List<String> _txtJvmArgs = new ArrayList<>();
|
protected List<String> _txtJvmArgs = new ArrayList<>();
|
||||||
|
|
||||||
/** If a warning has been issued about not being able to set modtimes. */
|
|
||||||
protected boolean _warnedAboutSetLastModified;
|
|
||||||
|
|
||||||
/** Locks gettingdown.lock in the app dir. Held the entire time updating is going on.*/
|
/** Locks gettingdown.lock in the app dir. Held the entire time updating is going on.*/
|
||||||
protected FileLock _lock;
|
protected FileLock _lock;
|
||||||
|
|
||||||
|
|||||||
@@ -237,7 +237,7 @@ public class Config
|
|||||||
*/
|
*/
|
||||||
public String getString (String name, String def) {
|
public String getString (String name, String def) {
|
||||||
String value = (String)_data.get(name);
|
String value = (String)_data.get(name);
|
||||||
return value == null ? def : value;
|
return StringUtil.isBlank(value) ? def : value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -17,21 +17,22 @@ import static com.threerings.getdown.Log.log;
|
|||||||
* Useful routines for launching Java applications from within other Java
|
* Useful routines for launching Java applications from within other Java
|
||||||
* applications.
|
* applications.
|
||||||
*/
|
*/
|
||||||
public class LaunchUtil
|
public final class LaunchUtil
|
||||||
{
|
{
|
||||||
/** The directory into which a local VM installation should be unpacked. */
|
/** The default directory into which a local VM installation should be unpacked. */
|
||||||
public static final String LOCAL_JAVA_DIR = "java_vm";
|
public static final String LOCAL_JAVA_DIR = "java_vm";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Writes a <code>version.txt</code> file into the specified application directory and
|
* Writes a {@code version.txt} file into the specified application directory and
|
||||||
* attempts to relaunch Getdown in that directory which will cause it to upgrade to the newly
|
* attempts to relaunch Getdown in that directory which will cause it to upgrade to the newly
|
||||||
* specified version and relaunch the application.
|
* specified version and relaunch the application.
|
||||||
*
|
*
|
||||||
* @param appdir the directory in which the application is installed.
|
* @param appdir the directory in which the application is installed.
|
||||||
* @param getdownJarName the name of the getdown jar file in the application directory. This is
|
* @param getdownJarName the name of the getdown jar file in the application directory. This is
|
||||||
* probably <code>getdown-pro.jar</code> or <code>getdown-retro-pro.jar</code> if you are using
|
* probably {@code getdown-pro.jar} or <code>getdown-retro-pro.jar</code> if you are using
|
||||||
* the results of the standard build.
|
* the results of the standard build.
|
||||||
* @param newVersion the new version to which Getdown will update when it is executed.
|
* @param newVersion the new version to which Getdown will update when it is executed.
|
||||||
|
* @param javaLocalDir JRE location within appdir, falls back to {@link #LOCAL_JAVA_DIR} in case if null is passed
|
||||||
*
|
*
|
||||||
* @return true if the relaunch succeeded, false if we were unable to relaunch due to being on
|
* @return true if the relaunch succeeded, false if we were unable to relaunch due to being on
|
||||||
* Windows 9x where we cannot launch subprocesses without waiting around for them to exit,
|
* Windows 9x where we cannot launch subprocesses without waiting around for them to exit,
|
||||||
@@ -39,13 +40,13 @@ public class LaunchUtil
|
|||||||
* after making this call as it will be upgraded and restarted. If false is returned, the
|
* after making this call as it will be upgraded and restarted. If false is returned, the
|
||||||
* application should tell the user that they must restart the application manually.
|
* application should tell the user that they must restart the application manually.
|
||||||
*
|
*
|
||||||
* @exception IOException thrown if we were unable to create the <code>version.txt</code> file
|
* @exception IOException thrown if we were unable to create the {@code version.txt} file
|
||||||
* in the supplied application directory. If the version.txt file cannot be created, restarting
|
* in the supplied application directory. If the version.txt file cannot be created, restarting
|
||||||
* Getdown will not cause the application to be upgraded, so the application will have to
|
* Getdown will not cause the application to be upgraded, so the application will have to
|
||||||
* resort to telling the user that it is in a bad way.
|
* resort to telling the user that it is in a bad way.
|
||||||
*/
|
*/
|
||||||
public static boolean updateVersionAndRelaunch (
|
public static boolean updateVersionAndRelaunch (
|
||||||
File appdir, String getdownJarName, String newVersion)
|
File appdir, String getdownJarName, String newVersion, String javaLocalDir)
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
// create the file that instructs Getdown to upgrade
|
// create the file that instructs Getdown to upgrade
|
||||||
@@ -61,8 +62,11 @@ public class LaunchUtil
|
|||||||
}
|
}
|
||||||
|
|
||||||
// do the deed
|
// do the deed
|
||||||
String[] args = new String[] {
|
String[] args = {
|
||||||
getJVMPath(appdir), "-jar", pro.toString(), appdir.getPath()
|
getJVMBinaryPath(new File(appdir, StringUtil.isBlank(javaLocalDir) ? LOCAL_JAVA_DIR : javaLocalDir), false),
|
||||||
|
"-jar",
|
||||||
|
pro.toString(),
|
||||||
|
appdir.getPath()
|
||||||
};
|
};
|
||||||
log.info("Running " + StringUtil.join(args, "\n "));
|
log.info("Running " + StringUtil.join(args, "\n "));
|
||||||
try {
|
try {
|
||||||
@@ -75,22 +79,14 @@ public class LaunchUtil
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reconstructs the path to the JVM used to launch this process.
|
* @param javaLocalDir JRE location within appdir
|
||||||
*/
|
|
||||||
public static String getJVMPath (File appdir)
|
|
||||||
{
|
|
||||||
return getJVMPath(appdir, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reconstructs the path to the JVM used to launch this process.
|
|
||||||
*
|
|
||||||
* @param windebug if true we will use java.exe instead of javaw.exe on Windows.
|
* @param windebug if true we will use java.exe instead of javaw.exe on Windows.
|
||||||
|
* @return the path to the JVM binary used to launch this process.
|
||||||
*/
|
*/
|
||||||
public static String getJVMPath (File appdir, boolean windebug)
|
public static String getJVMBinaryPath(File javaLocalDir, boolean windebug)
|
||||||
{
|
{
|
||||||
// first look in our application directory for an installed VM
|
// first look in our application directory for an installed VM
|
||||||
String vmpath = checkJVMPath(new File(appdir, LOCAL_JAVA_DIR).getAbsolutePath(), windebug);
|
String vmpath = checkJVMPath(javaLocalDir.getAbsolutePath(), windebug);
|
||||||
|
|
||||||
// then fall back to the VM in which we're already running
|
// then fall back to the VM in which we're already running
|
||||||
if (vmpath == null) {
|
if (vmpath == null) {
|
||||||
@@ -99,7 +95,7 @@ public class LaunchUtil
|
|||||||
|
|
||||||
// then throw up our hands and hope for the best
|
// then throw up our hands and hope for the best
|
||||||
if (vmpath == null) {
|
if (vmpath == null) {
|
||||||
log.warning("Unable to find java [appdir=" + appdir +
|
log.warning("Unable to find java [javaLocalDir=" + javaLocalDir +
|
||||||
", java.home=" + System.getProperty("java.home") + "]!");
|
", java.home=" + System.getProperty("java.home") + "]!");
|
||||||
vmpath = "java";
|
vmpath = "java";
|
||||||
}
|
}
|
||||||
@@ -150,8 +146,7 @@ public class LaunchUtil
|
|||||||
if (newgd.renameTo(curgd)) {
|
if (newgd.renameTo(curgd)) {
|
||||||
FileUtil.deleteHarder(oldgd); // yay!
|
FileUtil.deleteHarder(oldgd); // yay!
|
||||||
try {
|
try {
|
||||||
// copy the moved file back to getdown-dop-new.jar so that we don't end up
|
// copy the moved file back to newgd so that we don't end up downloading another copy next time
|
||||||
// downloading another copy next time
|
|
||||||
FileUtil.copy(curgd, newgd);
|
FileUtil.copy(curgd, newgd);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
log.warning("Error copying updated Getdown back: " + e);
|
log.warning("Error copying updated Getdown back: " + e);
|
||||||
@@ -182,23 +177,23 @@ public class LaunchUtil
|
|||||||
public static boolean mustMonitorChildren ()
|
public static boolean mustMonitorChildren ()
|
||||||
{
|
{
|
||||||
String osname = System.getProperty("os.name", "").toLowerCase(Locale.ROOT);
|
String osname = System.getProperty("os.name", "").toLowerCase(Locale.ROOT);
|
||||||
return (osname.indexOf("windows 98") != -1 || osname.indexOf("windows me") != -1);
|
return osname.contains("windows 98") || osname.contains("windows me");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if we're running in a JVM that identifies its operating system as Windows.
|
* Returns true if we're running in a JVM that identifies its operating system as Windows.
|
||||||
*/
|
*/
|
||||||
public static final boolean isWindows () { return _isWindows; }
|
public static boolean isWindows () { return _isWindows; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if we're running in a JVM that identifies its operating system as MacOS.
|
* Returns true if we're running in a JVM that identifies its operating system as MacOS.
|
||||||
*/
|
*/
|
||||||
public static final boolean isMacOS () { return _isMacOS; }
|
public static boolean isMacOS () { return _isMacOS; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if we're running in a JVM that identifies its operating system as Linux.
|
* Returns true if we're running in a JVM that identifies its operating system as Linux.
|
||||||
*/
|
*/
|
||||||
public static final boolean isLinux () { return _isLinux; }
|
public static boolean isLinux () { return _isLinux; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks whether a Java Virtual Machine can be located in the supplied path.
|
* Checks whether a Java Virtual Machine can be located in the supplied path.
|
||||||
@@ -236,11 +231,10 @@ public class LaunchUtil
|
|||||||
static {
|
static {
|
||||||
try {
|
try {
|
||||||
String osname = System.getProperty("os.name");
|
String osname = System.getProperty("os.name");
|
||||||
osname = (osname == null) ? "" : osname;
|
osname = osname == null ? "" : osname;
|
||||||
_isWindows = (osname.indexOf("Windows") != -1);
|
_isWindows = osname.contains("Windows");
|
||||||
_isMacOS = (osname.indexOf("Mac OS") != -1 ||
|
_isMacOS = osname.contains("Mac OS") || osname.contains("MacOS");
|
||||||
osname.indexOf("MacOS") != -1);
|
_isLinux = osname.contains("Linux");
|
||||||
_isLinux = (osname.indexOf("Linux") != -1);
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// can't grab system properties; we'll just pretend we're not on any of these OSes
|
// can't grab system properties; we'll just pretend we're not on any of these OSes
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ public abstract class Getdown extends Thread
|
|||||||
// welcome to hell, where java can't cope with a classpath that contains jars that live
|
// welcome to hell, where java can't cope with a classpath that contains jars that live
|
||||||
// in a directory that contains a !, at least the same bug happens on all platforms
|
// in a directory that contains a !, at least the same bug happens on all platforms
|
||||||
String dir = envc.appDir.toString();
|
String dir = envc.appDir.toString();
|
||||||
if (dir.equals(".")) {
|
if (".".equals(dir)) {
|
||||||
dir = System.getProperty("user.dir");
|
dir = System.getProperty("user.dir");
|
||||||
}
|
}
|
||||||
String errmsg = "The directory in which this application is installed:\n" + dir +
|
String errmsg = "The directory in which this application is installed:\n" + dir +
|
||||||
@@ -130,7 +130,7 @@ public abstract class Getdown extends Thread
|
|||||||
File instdir = _app.getLocalPath("");
|
File instdir = _app.getLocalPath("");
|
||||||
if (!instdir.canWrite()) {
|
if (!instdir.canWrite()) {
|
||||||
String path = instdir.getPath();
|
String path = instdir.getPath();
|
||||||
if (path.equals(".")) {
|
if (".".equals(path)) {
|
||||||
path = System.getProperty("user.dir");
|
path = System.getProperty("user.dir");
|
||||||
}
|
}
|
||||||
fail(MessageUtil.tcompose("m.readonly_error", path));
|
fail(MessageUtil.tcompose("m.readonly_error", path));
|
||||||
@@ -161,20 +161,7 @@ public abstract class Getdown extends Thread
|
|||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.warning("run() failed.", e);
|
log.warning("run() failed.", e);
|
||||||
String msg = e.getMessage();
|
fail(e);
|
||||||
if (msg == null) {
|
|
||||||
msg = MessageUtil.compose("m.unknown_error", _ifc.installError);
|
|
||||||
} else if (!msg.startsWith("m.")) {
|
|
||||||
// try to do something sensible based on the type of error
|
|
||||||
if (e instanceof FileNotFoundException) {
|
|
||||||
msg = MessageUtil.compose(
|
|
||||||
"m.missing_resource", MessageUtil.taint(msg), _ifc.installError);
|
|
||||||
} else {
|
|
||||||
msg = MessageUtil.compose(
|
|
||||||
"m.init_error", MessageUtil.taint(msg), _ifc.installError);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fail(msg);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -423,22 +410,7 @@ public abstract class Getdown extends Thread
|
|||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.warning("getdown() failed.", e);
|
log.warning("getdown() failed.", e);
|
||||||
String msg = e.getMessage();
|
fail(e);
|
||||||
if (msg == null) {
|
|
||||||
msg = MessageUtil.compose("m.unknown_error", _ifc.installError);
|
|
||||||
} else if (!msg.startsWith("m.")) {
|
|
||||||
// try to do something sensible based on the type of error
|
|
||||||
if (e instanceof FileNotFoundException) {
|
|
||||||
msg = MessageUtil.compose(
|
|
||||||
"m.missing_resource", MessageUtil.taint(msg), _ifc.installError);
|
|
||||||
} else {
|
|
||||||
msg = MessageUtil.compose(
|
|
||||||
"m.init_error", MessageUtil.taint(msg), _ifc.installError);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Since we're dead, clear off the 'time remaining' label along with displaying the
|
|
||||||
// error message
|
|
||||||
fail(msg);
|
|
||||||
_app.releaseLock();
|
_app.releaseLock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -507,13 +479,13 @@ public abstract class Getdown extends Thread
|
|||||||
vmjar.install(true);
|
vmjar.install(true);
|
||||||
|
|
||||||
// these only run on non-Windows platforms, so we use Unix file separators
|
// these only run on non-Windows platforms, so we use Unix file separators
|
||||||
String localJavaDir = LaunchUtil.LOCAL_JAVA_DIR + "/";
|
File javaLocalDir = _app.getJavaLocalDir();
|
||||||
FileUtil.makeExecutable(_app.getLocalPath(localJavaDir + "bin/java"));
|
FileUtil.makeExecutable(new File(javaLocalDir, "bin/java"));
|
||||||
FileUtil.makeExecutable(_app.getLocalPath(localJavaDir + "lib/jspawnhelper"));
|
FileUtil.makeExecutable(new File(javaLocalDir, "lib/jspawnhelper"));
|
||||||
FileUtil.makeExecutable(_app.getLocalPath(localJavaDir + "lib/amd64/jspawnhelper"));
|
FileUtil.makeExecutable(new File(javaLocalDir, "lib/amd64/jspawnhelper"));
|
||||||
|
|
||||||
// lastly regenerate the .jsa dump file that helps Java to start up faster
|
// lastly regenerate the .jsa dump file that helps Java to start up faster
|
||||||
String vmpath = LaunchUtil.getJVMPath(_app.getLocalPath(""));
|
String vmpath = LaunchUtil.getJVMBinaryPath(javaLocalDir, false);
|
||||||
try {
|
try {
|
||||||
log.info("Regenerating classes.jsa for " + vmpath + "...");
|
log.info("Regenerating classes.jsa for " + vmpath + "...");
|
||||||
Runtime.getRuntime().exec(vmpath + " -Xshare:dump");
|
Runtime.getRuntime().exec(vmpath + " -Xshare:dump");
|
||||||
@@ -836,8 +808,23 @@ public abstract class Getdown extends Thread
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void fail(Exception e) {
|
||||||
|
String msg = e.getMessage();
|
||||||
|
if (msg == null) {
|
||||||
|
msg = MessageUtil.compose("m.unknown_error", _ifc.installError);
|
||||||
|
} else if (!msg.startsWith("m.")) {
|
||||||
|
// try to do something sensible based on the type of error
|
||||||
|
if (e instanceof FileNotFoundException) {
|
||||||
|
msg = MessageUtil.compose("m.missing_resource", MessageUtil.taint(msg), _ifc.installError);
|
||||||
|
} else {
|
||||||
|
msg = MessageUtil.compose("m.init_error", MessageUtil.taint(msg), _ifc.installError);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fail(msg);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the status to indicate getdown has failed for the reason in <code>message</code>.
|
* Update the status to indicate getdown has failed for the reason in {@code message}.
|
||||||
*/
|
*/
|
||||||
protected void fail (String message)
|
protected void fail (String message)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user