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>
This commit is contained in:
Dirk Hohndel 2015-02-18 07:41:28 -08:00
parent 25d2f187e0
commit caa153af79

View file

@ -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