Changeset 7314 in josm for trunk/src/org
- Timestamp:
- 2014-07-18T22:27:52+02:00 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/tools/PlatformHookUnixoid.java
r7206 r7314 16 16 import java.net.URISyntaxException; 17 17 import java.nio.charset.StandardCharsets; 18 import java.nio.file.Files; 19 import java.nio.file.Paths; 18 20 import java.security.KeyStore; 19 21 import java.security.KeyStoreException; … … 113 115 114 116 /** 115 * Determines if the distribution is Debian or Ubuntu, or a derivative.116 * @return {@code true} if the distribution is Debian, Ubuntu or Mint, {@code false} otherwise117 */118 public static boolean isDebianOrUbuntu() {119 try {120 String dist = Utils.execOutput(Arrays.asList("lsb_release", "-i", "-s"));121 return "Debian".equalsIgnoreCase(dist) || "Ubuntu".equalsIgnoreCase(dist) || "Mint".equalsIgnoreCase(dist);122 } catch (IOException e) {123 Main.warn(e);124 return false;125 }126 }127 128 /**129 117 * Determines if the JVM is OpenJDK-based. 130 118 * @return {@code true} if {@code java.home} contains "openjdk", {@code false} otherwise … … 138 126 /** 139 127 * Get the package name including detailed version. 140 * @param packageName The package name128 * @param packageNames The possible package names (when a package can have different names on different distributions) 141 129 * @return The package name and package version if it can be identified, null otherwise 142 */ 143 public static String getPackageDetails(String packageName) { 130 * @since 7314 131 */ 132 public static String getPackageDetails(String ... packageNames) { 144 133 try { 145 String version = Utils.execOutput(Arrays.asList( 146 "dpkg-query", "--show", "--showformat", "${Architecture}-${Version}", packageName)); 147 if (version != null) { 148 return packageName + ":" + version; 134 boolean dpkg = Files.exists(Paths.get("/usr/bin/dpkg-query")); 135 boolean rpm = Files.exists(Paths.get("/usr/bin/rpm")); 136 if (dpkg || rpm) { 137 for (String packageName : packageNames) { 138 String[] args = null; 139 if (dpkg) { 140 args = new String[] {"dpkg-query", "--show", "--showformat", "${Architecture}-${Version}", packageName}; 141 } else { 142 args = new String[] {"rpm", "-q", "--qf", "%{arch}-%{version}", packageName}; 143 } 144 String version = Utils.execOutput(Arrays.asList(args)); 145 if (version != null) { 146 return packageName + ":" + version; 147 } 148 } 149 149 } 150 150 } catch (IOException e) { … … 160 160 * to the Java version, we also need the exact package version. 161 161 * 162 * This was originally written for #8921, so only Debian based distributions 163 * are covered at the moment. This can be extended to other distributions 164 * if needed. 165 * 166 * @return The package name and package version if it can be identified, null 167 * otherwise 162 * @return The package name and package version if it can be identified, null otherwise 168 163 */ 169 164 public String getJavaPackageDetails() { 170 if (isDebianOrUbuntu()) {171 switch(System.getProperty("java.home")) {172 case "/usr/lib/jvm/java-7-openjdk-amd64/jre":173 case "/usr/lib/jvm/java-7-openjdk-i386/jre":174 return getPackageDetails("openjdk-7-jre");175 }165 switch(System.getProperty("java.home")) { 166 case "/usr/lib/jvm/java-7-openjdk-amd64/jre": 167 case "/usr/lib/jvm/java-7-openjdk-i386/jre": 168 case "/usr/lib64/jvm/java-1.7.0-openjdk-1.7.0/jre": 169 case "/usr/lib/jvm/java-1.7.0-openjdk-1.7.0/jre": 170 return getPackageDetails("openjdk-7-jre", "java-1_7_0-openjdk"); 176 171 } 177 172 return null; … … 181 176 * Get the Web Start package name including detailed version. 182 177 * 183 * Debian and Ubuntu OpenJDK packages are shipped with icedtea-web package, 184 * but its version does not match main java package version. 185 * 186 * Only Debian based distributions are covered at the moment. 187 * This can be extended to other distributions if needed. 178 * OpenJDK packages are shipped with icedtea-web package, 179 * but its version generally does not match main java package version. 188 180 * 189 181 * Simply return {@code null} if there's no separate package for Java WebStart. … … 192 184 */ 193 185 public String getWebStartPackageDetails() { 194 if (is DebianOrUbuntu() && isOpenJDK()) {195 return getPackageDetails("icedtea-netx" );186 if (isOpenJDK()) { 187 return getPackageDetails("icedtea-netx", "icedtea-web"); 196 188 } 197 189 return null; … … 224 216 new LinuxReleaseInfo("/etc/fedora-release"), 225 217 new LinuxReleaseInfo("/etc/gentoo-release"), 226 new LinuxReleaseInfo("/etc/redhat-release") 218 new LinuxReleaseInfo("/etc/redhat-release"), 219 new LinuxReleaseInfo("/etc/SuSE-release") 227 220 }) { 228 221 String description = info.extractDescription();
Note:
See TracChangeset
for help on using the changeset viewer.