diff --git a/Modules/about-distro/autotests/OSReleaseTest.cpp b/Modules/about-distro/autotests/OSReleaseTest.cpp --- a/Modules/about-distro/autotests/OSReleaseTest.cpp +++ b/Modules/about-distro/autotests/OSReleaseTest.cpp @@ -49,6 +49,8 @@ QCOMPARE(r.variant(), "Test Edition"); QCOMPARE(r.variantId(), "test"); QCOMPARE(r.logo(), "start-here-test"); + QCOMPARE(r.extraKeys(), QStringList({"DEBIAN_BTS"})); + QCOMPARE(r.extraValue("DEBIAN_BTS"), "debbugs://bugs.debian.org/"); } }; diff --git a/Modules/about-distro/autotests/data/os-release b/Modules/about-distro/autotests/data/os-release --- a/Modules/about-distro/autotests/data/os-release +++ b/Modules/about-distro/autotests/data/os-release @@ -13,6 +13,9 @@ BUG_REPORT_URL="https://url.bugs" PRIVACY_POLICY_URL="https://url.privacy" BUILD_ID="105.5" +# comment VARIANT="Test Edition" VARIANT_ID=test + # indented comment LOGO=start-here-test +DEBIAN_BTS="debbugs://bugs.debian.org/" diff --git a/Modules/about-distro/src/OSRelease.h b/Modules/about-distro/src/OSRelease.h --- a/Modules/about-distro/src/OSRelease.h +++ b/Modules/about-distro/src/OSRelease.h @@ -86,6 +86,14 @@ /** @see https://www.freedesktop.org/software/systemd/man/os-release.html#LOGO= */ QString logo() const; + /** + * Extra keys are keys that are unknown or specified by a vendor. + */ + QStringList extraKeys() const; + + /** Extra values are values assoicated with keys that are unknown. */ + QString extraValue(const QString &key) const; + private: static QString defaultFilePath(); diff --git a/Modules/about-distro/src/OSRelease.cpp b/Modules/about-distro/src/OSRelease.cpp --- a/Modules/about-distro/src/OSRelease.cpp +++ b/Modules/about-distro/src/OSRelease.cpp @@ -140,8 +140,11 @@ continue; } - // os-release explicitly allows for vendor specific aditions. We have no - // interest in those right now. + // os-release explicitly allows for vendor specific additions, we'll + // collect them as strings and exposes them as "extras". + QString parsedValue; + setVar(&parsedValue, value); + extras.insert(key, parsedValue); } } @@ -163,6 +166,8 @@ QString variant; QString variantId; QString logo; + + QHash extras; }; OSRelease::OSRelease(const QString &filePath) @@ -265,6 +270,16 @@ return d->logo; } +QStringList OSRelease::extraKeys() const +{ + return d->extras.keys(); +} + +QString OSRelease::extraValue(const QString &key) const +{ + return d->extras.value(key); +} + QString OSRelease::defaultFilePath() { if (QFile::exists(QStringLiteral("/etc/os-release"))) {