From 1053a11c460610c522de781e26da71a2b65dd4b4 Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Fri, 11 Nov 2016 07:57:36 -0800 Subject: [PATCH] Mark jspawnhelper as executable. Closes #74. --- .../threerings/getdown/launcher/Getdown.java | 38 +++++++++++-------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/threerings/getdown/launcher/Getdown.java b/src/main/java/com/threerings/getdown/launcher/Getdown.java index b625ae1..1cd00bb 100644 --- a/src/main/java/com/threerings/getdown/launcher/Getdown.java +++ b/src/main/java/com/threerings/getdown/launcher/Getdown.java @@ -647,21 +647,10 @@ public abstract class Getdown extends Thread } vmjar.markAsValid(); - // Sun, why dost thou spite me? Java doesn't know anything about file permissions (and by - // extension then, neither does Jar), so on Joonix we have to hackily make java_vm/bin/java - // executable by execing chmod; a pox on their children! - if (!RunAnywhere.isWindows()) { - String vmbin = LaunchUtil.LOCAL_JAVA_DIR + File.separator + "bin" + - File.separator + "java"; - String cmd = "chmod a+rx " + _app.getLocalPath(vmbin); - try { - log.info("Please smack a Java engineer. Running: " + cmd); - Runtime.getRuntime().exec(cmd); - } catch (Exception e) { - log.warning("Failed to mark VM binary as executable", "cmd", cmd, "error", e); - // we should do something like tell the user or something but fucking fuck - } - } + // these only run on non-Windows platforms, so we use Unix file separators + String localJavaDir = LaunchUtil.LOCAL_JAVA_DIR + "/"; + makeExecutable(localJavaDir + "bin/java"); + makeExecutable(localJavaDir + "lib/amd64/jspawnhelper"); // lastly regenerate the .jsa dump file that helps Java to start up faster String vmpath = LaunchUtil.getJVMPath(_app.getLocalPath("")); @@ -669,12 +658,29 @@ public abstract class Getdown extends Thread log.info("Regenerating classes.jsa for " + vmpath + "..."); Runtime.getRuntime().exec(vmpath + " -Xshare:dump"); } catch (Exception e) { - log.warning("Failed to regenerate .jsa dum file", "error", e); + log.warning("Failed to regenerate .jsa dump file", "error", e); } reportTrackingEvent("jvm_complete", -1); } + protected void makeExecutable (String path) { + // Java doesn't know anything about file permissions (and by extension then, + // neither does Jar), so on Unix we have to hackily do so via chmod + if (!RunAnywhere.isWindows()) { + File target = _app.getLocalPath(path); + String cmd = "chmod a+rx " + target; + try { + if (target.exists()) { + log.info("Running: " + cmd); + Runtime.getRuntime().exec(cmd); + } + } catch (Exception e) { + log.warning("Failed to mark VM binary as executable", "cmd", cmd, "error", e); + } + } + } + /** * Called if the application is determined to be of an old version. */