Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
… cowwoc-JENKINS-8957
  • Loading branch information
jglick committed Oct 2, 2013
2 parents ea85489 + 4f6e649 commit 9ec37cc
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions core/src/main/java/hudson/tools/JDKInstaller.java
Expand Up @@ -224,16 +224,33 @@ I tried to locate exactly how InstallShield parses the arguments (and why it use
*/
String logFile = jdkBundle+".install.log";

expectedLocation = expectedLocation.trim();
if (expectedLocation.endsWith("\\")) {
// Prevent a trailing slash from escaping quotes
expectedLocation = expectedLocation.substring(0, expectedLocation.length() - 1);
}
ArgumentListBuilder args = new ArgumentListBuilder();
args.add(jdkBundle);
assert (new File(expectedLocation).exists()) : expectedLocation
+ " must exist, otherwise /L will cause the installer to fail with error 1622";
if (isJava15() || isJava14()) {
args.add("/s","/v/qn REBOOT=ReallySuppress INSTALLDIR=\""+ expectedLocation +"\" /L \""+logFile+"\"");
// Installer uses InstallShield.
args.add("CMD.EXE", "/C");

// CMD.EXE /C must be followed by a single parameter (do not split it!)
args.add(jdkBundle + " /s /v\"/qn REBOOT=ReallySuppress INSTALLDIR=\\\""
+ expectedLocation + "\\\" /L \\\"" + expectedLocation
+ "\\jdk.exe.install.log\\\"\"");
} else {
// modern version supports arguments in more sane format.
args.add("/s","/v","/qn","/L","\""+logFile+"\"","REBOOT=ReallySuppress","INSTALLDIR=\""+ expectedLocation+"\"");
// Installed uses Windows Installer (MSI)
args.add(jdkBundle, "/s");

// Create a private JRE by omitting "PublicjreFeature"
// @see http://docs.oracle.com/javase/7/docs/webnotes/install/windows/jdk-installation-windows.html#jdk-silent-installation
args.add("ADDLOCAL=\"ToolsFeature\"");

args.add("REBOOT=ReallySuppress", "INSTALLDIR=" + expectedLocation,
"/L \\\"" + expectedLocation + "\\jdk.exe.install.log\\\"");
}
// according to http://community.acresso.com/showthread.php?t=83301, \" is the trick to quote values with whitespaces.
// Oh Windows, oh windows, why do you have to be so difficult?
int r = launcher.launch().cmds(args).stdout(out)
.pwd(new FilePath(launcher.getChannel(), expectedLocation)).join();
if (r != 0) {
Expand Down

0 comments on commit 9ec37cc

Please sign in to comment.