From caa153af79d7650181e4fdbbef281ac1bbca4bfd Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Wed, 18 Feb 2015 07:41:28 -0800 Subject: Correctly detect more Linux distributions I don't think there's a way we can track all of the variations here, but this supports any distribution that supports the lsb-release standard and adds extra detection to correctly decode the PCLinuxOS version as they neither implement /etc/os-release nor completely implement /etc/lsb-release Signed-off-by: Dirk Hohndel --- subsurfacesysinfo.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'subsurfacesysinfo.cpp') diff --git a/subsurfacesysinfo.cpp b/subsurfacesysinfo.cpp index 2458d2880..4a55e7315 100644 --- a/subsurfacesysinfo.cpp +++ b/subsurfacesysinfo.cpp @@ -44,6 +44,7 @@ #include #include #include +#include #ifndef QStringLiteral # define QStringLiteral QString::fromUtf8 @@ -234,6 +235,26 @@ static bool readEtcOsRelease(QUnixOSVersion &v) } return true; } + QFile lsbRelease("/etc/lsb-release"); + if (lsbRelease.exists()) { + QSettings parse("/etc/lsb-release", QSettings::IniFormat); + if (parse.contains("DISTRIB_DESCRIPTION")) { + v.versionText = parse.value("DISTRIB_DESCRIPTION").toString(); + if (v.versionText == "PCLinuxOS") { + QFile release("/etc/release"); + if (release.exists()) { + if (release.open(QFile::ReadOnly | QFile::Text)) { + QTextStream in(&release); + v.versionText = in.readAll(); + // need to get rid of the redundant text after '(' + int i = v.versionText.indexOf('('); + v.versionText.remove(i, 1000); + } + } + } + } + return true; + } return false; } #endif // USE_ETC_OS_RELEASE -- cgit v1.2.3-70-g09d2