Changeset 6103 in josm
- Timestamp:
- 2013-08-02T23:42:34+02:00 (11 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/ShowStatusReportAction.java
r6084 r6103 30 30 import org.openstreetmap.josm.tools.BugReportExceptionHandler; 31 31 import org.openstreetmap.josm.tools.OpenBrowser; 32 import org.openstreetmap.josm.tools.PlatformHookUnixoid; 32 33 import org.openstreetmap.josm.tools.PlatformHookWindows; 33 34 import org.openstreetmap.josm.tools.Shortcut; … … 85 86 text.append("Java version: " + System.getProperty("java.version") + ", " + System.getProperty("java.vendor") + ", " + System.getProperty("java.vm.name")); 86 87 text.append("\n"); 88 if (Main.platform.getClass() == PlatformHookUnixoid.class) { 89 String packageDetails = ((PlatformHookUnixoid) Main.platform).getJavaPackageDetails(); 90 if (packageDetails != null) { 91 text.append("Java package: "); 92 text.append(packageDetails); 93 text.append("\n"); 94 } 95 } 87 96 try { 88 97 final String env_java_home = System.getenv("JAVA_HOME"); -
trunk/src/org/openstreetmap/josm/tools/PlatformHookUnixoid.java
r6070 r6103 11 11 import java.io.IOException; 12 12 import java.io.InputStreamReader; 13 import java.util.Arrays; 14 import java.util.List; 13 15 14 16 /** … … 88 90 { 89 91 return from.renameTo(to); 92 } 93 94 /** 95 * Get the Java package name including detailed version. 96 * 97 * Some Java bugs are specific to a certain security update, so in addition 98 * to the Java version, we also need the exact package version. 99 * 100 * This was originally written for #8921, so only Debian based distributions 101 * are covered at the moment. This can be extended to other distributions 102 * if needed. 103 * 104 * @return The package name and package version if it can be identified, null 105 * otherwise 106 */ 107 public String getJavaPackageDetails() { 108 try { 109 String dist = Utils.execOutput(Arrays.asList("lsb_release", "-i", "-s")); 110 if ("Debian".equalsIgnoreCase(dist) || "Ubuntu".equalsIgnoreCase(dist)) { 111 String javaHome = System.getProperty("java.home"); 112 if ("/usr/lib/jvm/java-6-openjdk-amd64/jre".equals(javaHome) || 113 "/usr/lib/jvm/java-6-openjdk-i386/jre".equals(javaHome) || 114 "/usr/lib/jvm/java-6-openjdk/jre".equals(javaHome)) { 115 String version = Utils.execOutput(Arrays.asList("dpkg-query", "--show", "--showformat", "${Architecture}-${Version}", "openjdk-6-jre")); 116 return "openjdk-6-jre:" + version; 117 } 118 if ("/usr/lib/jvm/java-7-openjdk-amd64/jre".equals(javaHome) || 119 "/usr/lib/jvm/java-7-openjdk-i386/jre".equals(javaHome)) { 120 String version = Utils.execOutput(Arrays.asList("dpkg-query", "--show", "--showformat", "${Architecture}-${Version}", "openjdk-7-jre")); 121 return "openjdk-7-jre:" + version; 122 } 123 } 124 } catch (IOException e) { 125 } 126 return null; 90 127 } 91 128 -
trunk/src/org/openstreetmap/josm/tools/Utils.java
r6094 r6103 664 664 return str.substring(start, end); 665 665 } 666 667 /** 668 * Runs an external command and returns the standard output. 669 * 670 * The program is expected to execute fast. 671 * 672 * @param command the command with arguments 673 * @return the output 674 * @throws IOException when there was an error, e.g. command does not exist 675 */ 676 public static String execOutput(List<String> command) throws IOException { 677 Process p = new ProcessBuilder(command).start(); 678 BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream())); 679 StringBuilder all = null; 680 String line; 681 while ((line = input.readLine()) != null) { 682 if (all == null) { 683 all = new StringBuilder(line); 684 } else { 685 all.append(line); 686 all.append("\n"); 687 } 688 } 689 Utils.close(input); 690 return all.toString(); 691 } 692 666 693 }
Note:
See TracChangeset
for help on using the changeset viewer.