Changeset 6850 in josm for trunk/src/org/openstreetmap/josm/tools/PlatformHookUnixoid.java
- Timestamp:
- 2014-02-14T01:09:29+01:00 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/tools/PlatformHookUnixoid.java
r6682 r6850 110 110 111 111 /** 112 * Determines if the distribution is Debian or Ubuntu. 113 * @return {@code true} if the distribution is Debian or Ubuntu, {@code false} otherwise 114 */ 115 public static boolean isDebianOrUbuntu() { 116 try { 117 String dist = Utils.execOutput(Arrays.asList("lsb_release", "-i", "-s")); 118 return "Debian".equalsIgnoreCase(dist) || "Ubuntu".equalsIgnoreCase(dist); 119 } catch (IOException e) { 120 Main.warn(e); 121 return false; 122 } 123 } 124 125 /** 126 * Get the package name including detailed version. 127 * @param packageName The package name 128 * @return The package name and package version if it can be identified, null otherwise 129 */ 130 public String getPackageDetails(String packageName) { 131 try { 132 String version = Utils.execOutput(Arrays.asList("dpkg-query", "--show", "--showformat", "${Architecture}-${Version}", packageName)); 133 return packageName + ":" + version; 134 } catch (IOException e) { 135 Main.warn(e); 136 return null; 137 } 138 } 139 140 /** 112 141 * Get the Java package name including detailed version. 113 142 * … … 123 152 */ 124 153 public String getJavaPackageDetails() { 125 try { 126 String dist = Utils.execOutput(Arrays.asList("lsb_release", "-i", "-s")); 127 if ("Debian".equalsIgnoreCase(dist) || "Ubuntu".equalsIgnoreCase(dist)) { 128 String javaHome = System.getProperty("java.home"); 129 if ("/usr/lib/jvm/java-6-openjdk-amd64/jre".equals(javaHome) || 130 "/usr/lib/jvm/java-6-openjdk-i386/jre".equals(javaHome) || 131 "/usr/lib/jvm/java-6-openjdk/jre".equals(javaHome)) { 132 String version = Utils.execOutput(Arrays.asList("dpkg-query", "--show", "--showformat", "${Architecture}-${Version}", "openjdk-6-jre")); 133 return "openjdk-6-jre:" + version; 134 } 135 if ("/usr/lib/jvm/java-7-openjdk-amd64/jre".equals(javaHome) || 136 "/usr/lib/jvm/java-7-openjdk-i386/jre".equals(javaHome)) { 137 String version = Utils.execOutput(Arrays.asList("dpkg-query", "--show", "--showformat", "${Architecture}-${Version}", "openjdk-7-jre")); 138 return "openjdk-7-jre:" + version; 139 } 140 } 141 } catch (IOException e) { 142 Main.warn(e); 154 if (isDebianOrUbuntu()) { 155 String javaHome = System.getProperty("java.home"); 156 if ("/usr/lib/jvm/java-6-openjdk-amd64/jre".equals(javaHome) || 157 "/usr/lib/jvm/java-6-openjdk-i386/jre".equals(javaHome) || 158 "/usr/lib/jvm/java-6-openjdk/jre".equals(javaHome)) { 159 return getPackageDetails("openjdk-6-jre"); 160 } 161 if ("/usr/lib/jvm/java-7-openjdk-amd64/jre".equals(javaHome) || 162 "/usr/lib/jvm/java-7-openjdk-i386/jre".equals(javaHome)) { 163 return getPackageDetails("openjdk-7-jre"); 164 } 165 } 166 return null; 167 } 168 169 /** 170 * Get the Web Start package name including detailed version. 171 * 172 * Debian and Ubuntu OpenJDK packages are shipped with icedtea-web package, 173 * but its version does not match main java package version. 174 * 175 * Only Debian based distributions are covered at the moment. 176 * This can be extended to other distributions if needed. 177 * 178 * Simply return {@code null} if there's no separate package for Java WebStart. 179 * 180 * @return The package name and package version if it can be identified, null otherwise 181 */ 182 public String getWebStartPackageDetails() { 183 if (isDebianOrUbuntu()) { 184 String javaHome = System.getProperty("java.home"); 185 if (javaHome != null && javaHome.contains("openjdk")) { 186 return getPackageDetails("icedtea-netx"); 187 } 143 188 } 144 189 return null;
Note:
See TracChangeset
for help on using the changeset viewer.