[gnome-control-center/wip/lantw/info-allow-specifying-the-path-of-etc-os-release] info: Allow specifying the path of /etc/os-release



commit e3586ca94fd5b7eaa1dd067eb98e05c161db65e1
Author: Ting-Wei Lan <lantw src gnome org>
Date:   Wed Jul 24 15:26:58 2019 +0800

    info: Allow specifying the path of /etc/os-release
    
    /etc/os-release is a specification invented on Linux. It is adopted by
    most Linux distributions, but it haven't been considered important
    enough for other non-Linux systems to implement it. On FreeBSD, the base
    system doesn't include an os-release file. To get an os-release file,
    users can install an additional package called 'etc_os-release'. Since
    it isn't considered as a part of the system, it can't be put in /etc and
    gnome-control-center is unable to find it.
    
    Therefore, to allow gnome-control-center finding os-release file in a
    different location, we have to add an option to allow changing the
    default path. An alternative solution is to use 'uname' function when
    os-release can't be opened, but the proposal was rejected.

 meson.build                          | 4 +++-
 meson_options.txt                    | 3 ++-
 panels/info/cc-info-overview-panel.c | 2 +-
 3 files changed, 6 insertions(+), 3 deletions(-)
---
diff --git a/meson.build b/meson.build
index 95f9b25ba..0eae13a95 100644
--- a/meson.build
+++ b/meson.build
@@ -42,7 +42,9 @@ set_defines = [
   ['PACKAGE_VERSION', meson.project_version()],
   ['VERSION', meson.project_version()],
   # i18n
-  ['GETTEXT_PACKAGE', control_center_gettext]
+  ['GETTEXT_PACKAGE', control_center_gettext],
+  # /etc/os-release
+  ['ETC_OS_RELEASE', get_option('etc_os_release')]
 ]
 
 foreach define: set_defines
diff --git a/meson_options.txt b/meson_options.txt
index a347168b7..29d549a29 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -1,6 +1,7 @@
 option('cheese', type: 'boolean', value: true, description: 'build with cheese webcam support')
 option('documentation', type: 'boolean', value: false, description: 'build documentation')
+option('etc_os_release', type: 'string', value: '/etc/os-release', description: 'Path to /etc/os-release 
file')
 option('gnome_session_libexecdir', type: 'string', value: '', description: 'Directory for gnome-session\'s 
libexecdir')
 option('ibus', type: 'boolean', value: true, description: 'build with IBus support')
 option('tracing', type: 'boolean', value: false, description: 'add extra debugging information')
-option('wayland', type: 'boolean', value: true, description: 'build with Wayland support')
\ No newline at end of file
+option('wayland', type: 'boolean', value: true, description: 'build with Wayland support')
diff --git a/panels/info/cc-info-overview-panel.c b/panels/info/cc-info-overview-panel.c
index 0d0a17fcf..2c8ff0bca 100644
--- a/panels/info/cc-info-overview-panel.c
+++ b/panels/info/cc-info-overview-panel.c
@@ -379,7 +379,7 @@ get_os_info (void)
 
   hashtable = NULL;
 
-  if (g_file_get_contents ("/etc/os-release", &buffer, NULL, NULL))
+  if (g_file_get_contents (ETC_OS_RELEASE, &buffer, NULL, NULL))
     {
       g_auto(GStrv) lines = NULL;
       gint i;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]