mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
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:
parent
25d2f187e0
commit
caa153af79
1 changed files with 21 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue