report: Try /etc/lsb-release for OS information
Namhyung Kim
PATCH 1/1 report: Try /etc/lsb-release for OS information
Ubuntu doesn't provide /etc/{system,redhat,os}-release but /etc/lsb-release file. Since it's present on any LSB (Linux Standard Base) compliant distributions, it'd better to try to read it.
To this end, change read_os_release to receive an additional argument to find the right line - in this case it's "DISTRIB_DESCRIPTION".
--- src/report.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
src/report.cpp +4 -3
@@ -83,12 +83,11 @@ string cpu_model(void) return ""; } -static string read_os_release(const string &filename) +static string read_os_release(const string &filename, const char *pname) { ifstream file; char content[4096]; char *c; - const char *pname = "PRETTY_NAME="; string os(""); file.open(filename.c_str(), ios::in);
@@ -160,7 +159,9 @@ static void system_info(void) if (str.length() < 1) str = read_sysfs_string("/etc/redhat-release"); if (str.length() < 1) - str = read_os_release("/etc/os-release"); + str = read_os_release("/etc/os-release", "PRETTY_NAME="); + if (str.length() < 1) + str = read_os_release("/etc/lsb-release", "DISTRIB_DESCRIPTION="); if (reporttype) { fprintf(reportout.http_report, "<tr class=\"system_even\"><td>OS Information</td><td>%s</td></tr>\n",
Signature · 1 line
1.7.9.2
Arjan van de Ven
Quoted 3 lines · Namhyung Kim
Ubuntu doesn't provide
/etc/{system,redhat,os}-releasebut/etc/lsb-releasefile. Since it's present on any LSB (Linux Standard Base) compliant distributions, it'd better to try to read it.
it's obsolete though
everyone has moved (or is moving) to /etc/os-release, which is a freedesktop standard and has pretty decent semantics...
Namhyung Kim
2012-09-20 (목), 17:01 +0200, Arjan van de Ven:
Quoted 8 lines · Namhyung Kim
Quoted 3 lines
Ubuntu doesn't provide
/etc/{system,redhat,os}-releasebut/etc/lsb-releasefile. Since it's present on any LSB (Linux Standard Base) compliant distributions, it'd better to try to read it.it's obsolete though
everyone has moved (or is moving) to/etc/os-release, which is a freedesktop standard and has pretty decent semantics...
Didn't know that. But at least my desktop box doesn't have the os-release yet. Do you mind if we try the lsb-release file as a fallback (as does in this patch)?
Thanks,
Namhyung