Commit 2f4f9a48 authored by Antonio Rojas's avatar Antonio Rojas

Query os-release for distro name

Look for the distro name in /etc/os-release and /usr/lib/os-release instead of relying on the external lsb-release tool, which may not be installed on the system. The lsb-release method is kept as a fallback.

Differential Revision:
parent dc87d64e
......@@ -38,6 +38,7 @@
#include <QDebug>
#include <QTimer>
#include <QStandardPaths>
#include <QFile>
#include <PackageKit/Transaction>
#include <PackageKit/Daemon>
......@@ -564,6 +565,25 @@ AbstractResource * PackageKitBackend::resourceForFile(const QUrl& file)
static QString readDistroName()
const QStringList osreleasenames = (QStringList() << QStringLiteral("/etc/os-release")
<< QStringLiteral("/usr/lib/os-release"));
foreach (QString osrelease, osreleasenames)
QFile file(osrelease);
if ( | QIODevice::Text))
QByteArray line;
while (!file.atEnd()) {
line = file.readLine().trimmed();
if (line.startsWith("NAME=")) {
auto output = line.right(line.length()-5);
output = output.replace('\"',"");
return QString::fromLocal8Bit(output);
QProcess process;
process.start(QStringLiteral("lsb_release"), {QStringLiteral("-sd")});
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment