[gnome-system-monitor] Fix display of release information

Matthias Clasen mclasen at fedoraproject.org
Sat Nov 24 17:34:01 UTC 2012


commit 1ce5a35e4e6664a3107aaa27e5ddcfd12a80a8b5
Author: Matthias Clasen <mclasen at redhat.com>
Date:   Sat Nov 24 12:34:20 2012 -0500

    Fix display of release information

 0001-Fix-system-information-on-Fedora.patch |   65 +++++++++++++++++++++++++++
 gnome-system-monitor.spec                   |    9 +++-
 2 files changed, 73 insertions(+), 1 deletions(-)
---
diff --git a/0001-Fix-system-information-on-Fedora.patch b/0001-Fix-system-information-on-Fedora.patch
new file mode 100644
index 0000000..c7a28e3
--- /dev/null
+++ b/0001-Fix-system-information-on-Fedora.patch
@@ -0,0 +1,65 @@
+From 8ecf9d4feca66b6dec751e8931116ad1e0969b7c Mon Sep 17 00:00:00 2001
+From: Matthias Clasen <mclasen at redhat.com>
+Date: Sat, 24 Nov 2012 11:59:20 -0500
+Subject: [PATCH] Fix system information on Fedora
+
+lsb_release may not be present, and in that case, we should read
+/etc/os-release, which is present on all systemd-using distributions
+and contains the information we need in an easy to parse format.
+---
+ src/sysinfo.cpp | 37 ++++++++++++++++++++++++++++++++++++-
+ 1 file changed, 36 insertions(+), 1 deletion(-)
+
+diff --git a/src/sysinfo.cpp b/src/sysinfo.cpp
+index 51e7b44..fd2cf66 100644
+--- a/src/sysinfo.cpp
++++ b/src/sysinfo.cpp
+@@ -536,9 +536,44 @@ namespace {
+         }
+     };
+ 
++    class GenericSysInfo
++        : public SysInfo
++    {
++    public:
++        GenericSysInfo()
++        {
++            this->load_os_release();
++        }
++
++    private:
++        void load_os_release()
++        {
++            std::ifstream input("/etc/os-release");
++
++            if (input) {
++                while (!input.eof()) {
++                    string s;
++                    int len;
++                    std::getline(input, s);
++                    if (s.find("NAME=") == 0) {
++                        len = strlen("NAME=");
++                        this->distro_name = s.substr(len);
++                    } else if (s.find("VERSION=") == 0) {
++                        len = strlen("VERSION=");
++                        // also strip the surrounding quotes
++                        this->distro_release = s.substr(len + 1, s.size() - len - 2);
++                    }
++                }
++            }
++        }
++    };
++
+     SysInfo* get_sysinfo()
+     {
+-        if (char *p = g_find_program_in_path("lsb_release")) {
++        if (g_file_test ("/etc/os-release", G_FILE_TEST_EXISTS)) {
++            return new GenericSysInfo;
++        }
++        else if (char *p = g_find_program_in_path("lsb_release")) {
+             g_free(p);
+             return new LSBSysInfo;
+         }
+-- 
+1.8.0
+
diff --git a/gnome-system-monitor.spec b/gnome-system-monitor.spec
index a6303e8..b59f91e 100644
--- a/gnome-system-monitor.spec
+++ b/gnome-system-monitor.spec
@@ -10,13 +10,16 @@
 Summary: Process and resource monitor
 Name: gnome-system-monitor
 Version: 3.6.1
-Release: 2%{?dist}
+Release: 3%{?dist}
 License: GPLv2+
 Group: Applications/System
 URL: http://www.gnome.org/
 #VCS: git:git://git.gnome.org/gnome-system-monitor
 Source: http://download.gnome.org/sources/gnome-system-monitor/3.6/%{name}-%{version}.tar.xz
 
+# https://bugzilla.gnome.org/show_bug.cgi?id=688981
+Patch0: 0001-Fix-system-information-on-Fedora.patch
+
 BuildRequires: libgtop2-devel >= %{libgtop2_version}
 BuildRequires: libwnck3-devel >= %{libwnck_version}
 BuildRequires: gtk3-devel
@@ -40,6 +43,7 @@ such as CPU and memory.
 
 %prep
 %setup -q
+%patch0 -p1
 
 %build
 %configure --enable-systemd
@@ -76,6 +80,9 @@ glib-compile-schemas %{_datadir}/glib-2.0/schemas &>/dev/null || :
 
 
 %changelog
+* Sat Nov 24 2012 Matthias Clasen <mclasen at redhat.com> - 3.6.1-3
+- Fix display of distro information
+
 * Mon Oct 29 2012 Matthias Clasen <mclasen at redhat.com> - 3.6.1-2
 - Display systemd information
 


More information about the scm-commits mailing list