Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[FIXED JENKINS-10383] svn patch applied
thanks to Ammon Riley
  • Loading branch information
ndeloof committed Feb 10, 2012
1 parent 3102100 commit b04de4a
Showing 1 changed file with 53 additions and 2 deletions.
Expand Up @@ -29,19 +29,35 @@

import hudson.remoting.Callable;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.lang.InterruptedException;
import java.util.HashSet;

class PlatformDetailsTask implements Callable<HashSet<String>, IOException> {

/** Performs computation and returns the result, or throws some exception. */
public HashSet<String> call() throws IOException {
final String arch = System.getProperty("os.arch");
String arch = System.getProperty("os.arch").toLowerCase();
String name = System.getProperty("os.name").toLowerCase();
String version = System.getProperty("os.version");
if (name.equals("solaris") || name.equals("SunOS")) {
name = "solaris";
} else if (name.startsWith("windows")) {
name = "windows";
/** os.arch is really the JRE bitness, not the OS bitness. */
if ("x86".equals(arch)) {
final String env1 =
System.getenv("PROCESSOR_ARCHITECTURE").toLowerCase();
String env2 = null;
try {
env2 = System.getenv("PROCESSOR_ARCHITEW6432").toLowerCase();
} catch (Exception e) {}

if ("amd64".equals(env1) || "amd64".equals(env2)) {
arch = "amd64";
}
}
if (name.startsWith("windows 9")) {
if (version.startsWith("4.0")) {
version = "95";
Expand All @@ -59,7 +75,25 @@ public HashSet<String> call() throws IOException {
} else if (version.startsWith("5.1")) {
version = "xp";
} else if (version.startsWith("5.2")) {
version = "2003";
if ("amd64".equals(arch)) {
// The 64-bit version of xp is based on 2003
version = "2003+xp";
} else {
version = "2003";
}
} else if (version.startsWith("6.0.6000")) {
version = "vista";
} else if (version.startsWith("6.0")) {
// Server 2008 is based on 6.0.6001
version = "vista+2008";
} else if (version.startsWith("6.1")) {
if ("x86".equals(arch)) {
// 2008 R2 is 64-bit only.
version = "7";
} else {
// TODO distinguish windows 7amd64 from 2008R2?
version = "7+2008r2";
}
}
}
} else if (name.startsWith("linux")) {
Expand All @@ -71,6 +105,23 @@ public HashSet<String> call() throws IOException {
version = release.release();
if (null == version)
version = unknown_string;

if ("x86".equals(arch)) {
Process p = Runtime.getRuntime().exec("/bin/uname -m");
try {
p.waitFor();
BufferedReader b = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line = b.readLine();
if (line != null) {
if ("x86_64".equals(line)) {
arch = "amd64";
} else {
arch = line;
}
}
}
catch (InterruptedException e) {}
}
} else if (name.startsWith("mac")) {
name = "mac";
} else {
Expand Down

0 comments on commit b04de4a

Please sign in to comment.