Now caches ubuntu + fedora version information
This commit is contained in:
parent
d900b9ddca
commit
1440b4ac37
@ -335,10 +335,16 @@ class OSUtil {
|
|||||||
return isFedora;
|
return isFedora;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static Integer fedoraVersion = null;
|
||||||
public static
|
public static
|
||||||
int getFedoraVersion() {
|
int getFedoraVersion() {
|
||||||
|
if (fedoraVersion != null) {
|
||||||
|
return fedoraVersion;
|
||||||
|
}
|
||||||
|
|
||||||
if (!isFedora()) {
|
if (!isFedora()) {
|
||||||
return 0;
|
fedoraVersion = 0;
|
||||||
|
return fedoraVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -349,12 +355,15 @@ class OSUtil {
|
|||||||
// should be: VERSION_ID=23\n or something
|
// should be: VERSION_ID=23\n or something
|
||||||
int beginIndex = output.indexOf("VERSION_ID=") + 11;
|
int beginIndex = output.indexOf("VERSION_ID=") + 11;
|
||||||
String fedoraVersion_ = output.substring(beginIndex, output.indexOf(OS.LINE_SEPARATOR_UNIX, beginIndex));
|
String fedoraVersion_ = output.substring(beginIndex, output.indexOf(OS.LINE_SEPARATOR_UNIX, beginIndex));
|
||||||
return Integer.parseInt(fedoraVersion_);
|
|
||||||
|
fedoraVersion = Integer.parseInt(fedoraVersion_);
|
||||||
|
return fedoraVersion;
|
||||||
}
|
}
|
||||||
} catch (Throwable ignored) {
|
} catch (Throwable ignored) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
fedoraVersion = 0;
|
||||||
|
return fedoraVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Boolean isLinuxMint = null;
|
private static Boolean isLinuxMint = null;
|
||||||
@ -375,17 +384,16 @@ class OSUtil {
|
|||||||
return isUbuntu;
|
return isUbuntu;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private static int[] ubuntuVersion = null;
|
||||||
* @return the ubuntu version or "" if not found.
|
|
||||||
*/
|
|
||||||
public static
|
public static
|
||||||
int[] getUbuntuVersion() {
|
int[] getUbuntuVersion() {
|
||||||
if (!OS.isLinux()) {
|
if (ubuntuVersion != null) {
|
||||||
return new int[]{0,0};
|
return ubuntuVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isUbuntu()) {
|
if (!isUbuntu()) {
|
||||||
return new int[] {0, 0};
|
ubuntuVersion = new int[]{0,0};
|
||||||
|
return ubuntuVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
String info = getInfo();
|
String info = getInfo();
|
||||||
@ -399,14 +407,17 @@ class OSUtil {
|
|||||||
String versionInfo = info.substring(index, newLine);
|
String versionInfo = info.substring(index, newLine);
|
||||||
if (versionInfo.indexOf('.') > 0) {
|
if (versionInfo.indexOf('.') > 0) {
|
||||||
String[] split = versionInfo.split("\\.");
|
String[] split = versionInfo.split("\\.");
|
||||||
return new int[] {Integer.parseInt(split[0]), Integer.parseInt(split[1])};
|
|
||||||
|
ubuntuVersion = new int[] {Integer.parseInt(split[0]), Integer.parseInt(split[1])};
|
||||||
|
return ubuntuVersion;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Throwable ignored) {
|
} catch (Throwable ignored) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return new int[] {0, 0};
|
ubuntuVersion = new int[]{0,0};
|
||||||
|
return ubuntuVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user