From 591046ecee50cdb6cd4e2d8f367df802baad1ac5 Mon Sep 17 00:00:00 2001 From: Michael Gratton Date: Sat, 22 Aug 2020 10:45:25 +1000 Subject: [PATCH] Application.Client: Use GLib rather than lsb-release for OS info Use `g_get_os_info()` instead of exec'ing lsb-release, bump min GLib version req to ensure we have the function available. Fixes #800 --- .../application/application-client.vala | 45 ++++--------------- 1 file changed, 8 insertions(+), 37 deletions(-) diff --git a/src/client/application/application-client.vala b/src/client/application/application-client.vala index e9648397..a56206d7 100644 --- a/src/client/application/application-client.vala +++ b/src/client/application/application-client.vala @@ -289,44 +289,15 @@ public class Application.Client : Gtk.Application { _("Unknown") }); - // Distro name and version using LSB util + /// Application runtime information label + info.add({ _("Distribution name"), + GLib.Environment.get_os_info(GLib.OsInfoKey.NAME) + }); - GLib.SubprocessLauncher launcher = new GLib.SubprocessLauncher( - GLib.SubprocessFlags.STDOUT_PIPE | - GLib.SubprocessFlags.STDERR_SILENCE - ); - // Reset lang vars so we can guess the strings below - launcher.setenv("LANGUAGE", "C", true); - launcher.setenv("LANG", "C", true); - launcher.setenv("LC_ALL", "C", true); - - string lsb_output = ""; - try { - GLib.Subprocess lsb_release = launcher.spawnv( - { "lsb_release", "-ir" } - ); - lsb_release.communicate_utf8(null, null, out lsb_output, null); - } catch (GLib.Error err) { - warning("Failed to exec lsb_release: %s", err.message); - } - if (lsb_output != "") { - foreach (string line in lsb_output.split("\n")) { - string[] parts = line.split(":", 2); - if (parts.length > 1) { - if (parts[0].has_prefix("Distributor ID")) { - /// Application runtime information label - info.add( - { _("Distribution name"), parts[1].strip() } - ); - } else if (parts[0].has_prefix("Release")) { - /// Application runtime information label - info.add( - { _("Distribution release"), parts[1].strip() } - ); - } - } - } - } + /// Application runtime information label + info.add({_("Distribution release"), + GLib.Environment.get_os_info(GLib.OsInfoKey.VERSION) + }); /// Application runtime information label info.add({ _("Installation prefix"), INSTALL_PREFIX });