8370719: [Linux] Use /etc/os-release values for font configuration file names

Reviewed-by: kizune, psadhukhan
This commit is contained in:
Phil Race 2025-11-04 21:47:58 +00:00
parent 245eeb41bc
commit 984c87cf76
2 changed files with 6 additions and 62 deletions

View File

@ -317,42 +317,14 @@ public final class FcFontConfiguration extends FontConfiguration {
return;
}
try {
File f;
if ((f = new File("/etc/lsb-release")).canRead()) {
/* Ubuntu and (perhaps others) use only lsb-release.
* Syntax and encoding is compatible with java properties.
* For Ubuntu the ID is "Ubuntu".
*/
Properties props = new Properties();
try (FileInputStream fis = new FileInputStream(f)) {
props.load(fis);
}
osName = extractInfo(props.getProperty("DISTRIB_ID"));
osVersion = extractInfo(props.getProperty("DISTRIB_RELEASE"));
} else if ((f = new File("/etc/redhat-release")).canRead()) {
osName = "RedHat";
osVersion = getVersionString(f);
} else if ((f = new File("/etc/SuSE-release")).canRead()) {
osName = "SuSE";
osVersion = getVersionString(f);
} else if ((f = new File("/etc/turbolinux-release")).canRead()) {
osName = "Turbo";
osVersion = getVersionString(f);
} else if ((f = new File("/etc/fedora-release")).canRead()) {
osName = "Fedora";
osVersion = getVersionString(f);
} else if ((f = new File("/etc/os-release")).canRead()) {
File f = new File("/etc/os-release");
if (f.canRead()) {
Properties props = new Properties();
try (FileInputStream fis = new FileInputStream(f)) {
props.load(fis);
}
osName = extractInfo(props.getProperty("NAME"));
osName = extractInfo(props.getProperty("ID"));
osVersion = extractInfo(props.getProperty("VERSION_ID"));
if (osName.equals("SLES")) {
osName = "SuSE";
} else {
osName = extractInfo(props.getProperty("ID"));
}
}
} catch (Exception e) {
if (FontUtilities.debugFonts()) {

View File

@ -91,42 +91,14 @@ public final class MFontConfiguration extends FontConfiguration {
if (osName.equals("Linux")) {
try {
File f;
if ((f = new File("/etc/fedora-release")).canRead()) {
osName = "Fedora";
osVersion = getVersionString(f);
} else if ((f = new File("/etc/redhat-release")).canRead()) {
osName = "RedHat";
osVersion = getVersionString(f);
} else if ((f = new File("/etc/turbolinux-release")).canRead()) {
osName = "Turbo";
osVersion = getVersionString(f);
} else if ((f = new File("/etc/SuSE-release")).canRead()) {
osName = "SuSE";
osVersion = getVersionString(f);
} else if ((f = new File("/etc/lsb-release")).canRead()) {
/* Ubuntu and (perhaps others) use only lsb-release.
* Syntax and encoding is compatible with java properties.
* For Ubuntu the ID is "Ubuntu".
*/
File f = new File("/etc/os-release");
if (f.canRead()) {
Properties props = new Properties();
try (FileInputStream fis = new FileInputStream(f)) {
props.load(fis);
}
osName = extractInfo(props.getProperty("DISTRIB_ID"));
osVersion = extractInfo(props.getProperty("DISTRIB_RELEASE"));
} else if ((f = new File("/etc/os-release")).canRead()) {
Properties props = new Properties();
try (FileInputStream fis = new FileInputStream(f)) {
props.load(fis);
}
osName = extractInfo(props.getProperty("NAME"));
osName = extractInfo(props.getProperty("ID"));
osVersion = extractInfo(props.getProperty("VERSION_ID"));
if (osName.equals("SLES")) {
osName = "SuSE";
} else {
osName = extractInfo(props.getProperty("ID"));
}
}
} catch (Exception e) {
}