* Re: [Powertop] [PATCH] report: Try /etc/lsb-release for OS information
@ 2012-09-20 15:07 Namhyung Kim
0 siblings, 0 replies; 3+ messages in thread
From: Namhyung Kim @ 2012-09-20 15:07 UTC (permalink / raw)
To: powertop
[-- Attachment #1: Type: text/plain, Size: 651 bytes --]
2012-09-20 (목), 17:01 +0200, Arjan van de Ven:
> On 9/20/2012 4:58 PM, Namhyung Kim wrote:
> > 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.
>
> 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
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [Powertop] [PATCH] report: Try /etc/lsb-release for OS information
@ 2012-09-20 15:01 Arjan van de Ven
0 siblings, 0 replies; 3+ messages in thread
From: Arjan van de Ven @ 2012-09-20 15:01 UTC (permalink / raw)
To: powertop
[-- Attachment #1: Type: text/plain, Size: 394 bytes --]
On 9/20/2012 4:58 PM, Namhyung Kim wrote:
> 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.
it's obsolete though
everyone has moved (or is moving) to /etc/os-release, which is a freedesktop standard
and has pretty decent semantics...
^ permalink raw reply [flat|nested] 3+ messages in thread* [Powertop] [PATCH] report: Try /etc/lsb-release for OS information
@ 2012-09-20 14:58 Namhyung Kim
0 siblings, 0 replies; 3+ messages in thread
From: Namhyung Kim @ 2012-09-20 14:58 UTC (permalink / raw)
To: powertop
[-- Attachment #1: Type: text/plain, Size: 1455 bytes --]
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".
Signed-off-by: Namhyung Kim <namhyung(a)gmail.com>
---
src/report.cpp | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/report.cpp b/src/report.cpp
index 6776b30..085e81b 100644
--- a/src/report.cpp
+++ b/src/report.cpp
@@ -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",
--
1.7.9.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-09-20 15:07 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-20 15:07 [Powertop] [PATCH] report: Try /etc/lsb-release for OS information Namhyung Kim
-- strict thread matches above, loose matches on Subject: below --
2012-09-20 15:01 Arjan van de Ven
2012-09-20 14:58 Namhyung Kim
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.