diff --git a/src/systeminformation.cpp b/src/systeminformation.cpp --- a/src/systeminformation.cpp +++ b/src/systeminformation.cpp @@ -37,14 +37,15 @@ #include #include #include +#include #include static const QString OS_UNSPECIFIED = QStringLiteral("unspecified"); static const QString PLATFORM_UNSPECIFIED = QStringLiteral("unspecified"); SystemInformation::Config::Config() : lsbReleasePath(QStandardPaths::findExecutable(QLatin1String("lsb_release"))) - , osReleasePath(QStringLiteral("/etc/os-release")) + , osReleasePath(/* Use KOSRelease default */) { } @@ -247,31 +248,8 @@ QString SystemInformation::fetchOSReleaseInformation() const { - QFile data(m_infoConfig.osReleasePath); - if (!data.open(QIODevice::ReadOnly | QIODevice::Text)) { - return QString(); - } - - QMap distroInfos; - - QTextStream in(&data); - while (!in.atEnd()) { - const QString line = in.readLine(); - - // its format is one simple NAME=VALUE per line - // don't use QString.split() here since its value might contain '='' - const int index = line.indexOf(QLatin1Char('=')); - if ( index != -1 ) { - const QString key = line.left(index); - const QString value = line.mid(index+1); - distroInfos.insert(key, value); - } - } - - // the PRETTY_NAME entry should be the most appropriate one, - // but I could be wrong. - const QString prettyName = distroInfos.value(QStringLiteral("PRETTY_NAME"), QStringLiteral("Linux")); - return prettyName; + KOSRelease os(m_infoConfig.osReleasePath); + return os.prettyName(); } QString SystemInformation::operatingSystem() const diff --git a/src/tests/data/os-release b/src/tests/data/os-release --- a/src/tests/data/os-release +++ b/src/tests/data/os-release @@ -4,7 +4,7 @@ ID_LIKE="otherid otherotherid" VERSION_CODENAME=versioncodename VERSION_ID="500.1" -PRETTY_NAME="Pretty Name #1" +PRETTY_NAME="FreeBSD #1" ANSI_COLOR="1;34" CPE_NAME="cpe:/o:foo:bar:100" HOME_URL="https://url.home" diff --git a/src/tests/systeminformationtest.cpp b/src/tests/systeminformationtest.cpp --- a/src/tests/systeminformationtest.cpp +++ b/src/tests/systeminformationtest.cpp @@ -80,11 +80,9 @@ SystemInformation info(config); QTRY_VERIFY(info.complete()); - QEXPECT_FAIL("", "os release parser is garbage", Continue); QCOMPARE(info.bugzillaPlatform(), "FreeBSD Ports"); QCOMPARE(info.operatingSystem(), "FreeBSD 1.0.0 x86_64"); - QEXPECT_FAIL("", "os release parser is garbage", Continue); - QCOMPARE(info.lsbRelease(), "KDE SUSE User Edition 5.16"); + QCOMPARE(info.lsbRelease(), ""); // FIXME: should also be set, its used in the submitted report QCOMPARE(info.compiledSources(), false); QCOMPARE(info.qtVersion(), "5.12.3"); QCOMPARE(info.frameworksVersion(), "5.59.0");