QSysInfo: fall back to /usr/lib/os-release if the /etc one is missing
Turns out that there are two files and while a lot of distros symlink one to the other, some distros lack the one in /etc. [ChangeLog][QtCore][QSysInfo] Fixed QSysInfo::productType() to properly detect some Linux distributions that ship with a minimal /etc. Change-Id: Ia741b559c24d46c78fb2fffd1548cab414037220 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io> Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
This commit is contained in:
parent
25feee4e06
commit
58b6b723de
@ -2211,10 +2211,19 @@ static bool readEtcFile(QUnixOSVersion &v, const char *filename,
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool readEtcOsRelease(QUnixOSVersion &v)
|
||||
static bool readOsRelease(QUnixOSVersion &v)
|
||||
{
|
||||
return readEtcFile(v, "/etc/os-release", QByteArrayLiteral("ID="),
|
||||
QByteArrayLiteral("VERSION_ID="), QByteArrayLiteral("PRETTY_NAME="));
|
||||
QByteArray id = QByteArrayLiteral("ID=");
|
||||
QByteArray versionId = QByteArrayLiteral("VERSION_ID=");
|
||||
QByteArray prettyName = QByteArrayLiteral("PRETTY_NAME=");
|
||||
|
||||
// man os-release(5) says:
|
||||
// The file /etc/os-release takes precedence over /usr/lib/os-release.
|
||||
// Applications should check for the former, and exclusively use its data
|
||||
// if it exists, and only fall back to /usr/lib/os-release if it is
|
||||
// missing.
|
||||
return readEtcFile(v, "/etc/os-release", id, versionId, prettyName) ||
|
||||
readEtcFile(v, "/usr/lib/os-release", id, versionId, prettyName);
|
||||
}
|
||||
|
||||
static bool readEtcLsbRelease(QUnixOSVersion &v)
|
||||
@ -2296,7 +2305,7 @@ static bool readEtcDebianVersion(QUnixOSVersion &v)
|
||||
|
||||
static bool findUnixOsVersion(QUnixOSVersion &v)
|
||||
{
|
||||
if (readEtcOsRelease(v))
|
||||
if (readOsRelease(v))
|
||||
return true;
|
||||
if (readEtcLsbRelease(v))
|
||||
return true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user