diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2015-02-18 07:41:28 -0800 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2015-02-18 07:42:48 -0800 |
commit | caa153af79d7650181e4fdbbef281ac1bbca4bfd (patch) | |
tree | 9c2b3ddde2f173ac7f3cd1f19b71de5afd4c868d | |
parent | 25d2f187e0301d858ab55772fa89edc29fb693d2 (diff) | |
download | subsurface-caa153af79d7650181e4fdbbef281ac1bbca4bfd.tar.gz |
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 <dirk@hohndel.org>
-rw-r--r-- | subsurfacesysinfo.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/subsurfacesysinfo.cpp b/subsurfacesysinfo.cpp index 2458d2880..4a55e7315 100644 --- a/subsurfacesysinfo.cpp +++ b/subsurfacesysinfo.cpp @@ -44,6 +44,7 @@ #include <QString> #include <QFile> #include <QSettings> +#include <QTextStream> #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 |