summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2020-02-18 17:35:58 +1000
committerBenjamin Tissoires <benjamin.tissoires@gmail.com>2020-02-19 08:31:18 +0000
commit428acee867d151da65dafb269618f29b0261327e (patch)
tree59816859fba801dc2e9608a55912550c52368943
parent7198e33ecf704e99011c7fc594eeef0cee178df6 (diff)
downloadlibinput-428acee867d151da65dafb269618f29b0261327e.tar.gz
tools: record: record basic os-release information as well
Because sometimes it's useful to know what distro a recording was made on, and the kernel version doesn't always reveal that. Fixes #428 Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r--tools/libinput-record.c26
-rw-r--r--tools/libinput-record.man4
2 files changed, 29 insertions, 1 deletions
diff --git a/tools/libinput-record.c b/tools/libinput-record.c
index 00aabe94..fd1ba926 100644
--- a/tools/libinput-record.c
+++ b/tools/libinput-record.c
@@ -1429,7 +1429,7 @@ print_system_header(struct record_context *ctx)
{
struct utsname u;
const char *kernel = "unknown";
- FILE *dmi;
+ FILE *dmi, *osrelease;
char buf[2048] = "unknown";
if (uname(&u) != -1)
@@ -1447,6 +1447,30 @@ print_system_header(struct record_context *ctx)
iprintf(ctx, "system:\n");
indent_push(ctx);
+
+ osrelease = fopen("/etc/os-release", "r");
+ if (!osrelease)
+ fopen("/usr/lib/os-release", "r");
+ if (osrelease) {
+ char *distro = NULL, *version = NULL;
+
+ while (fgets(buf, sizeof(buf), osrelease)) {
+ buf[strlen(buf) - 1] = '\0'; /* linebreak */
+
+ if (!distro && strneq(buf, "ID=", 3))
+ distro = safe_strdup(&buf[3]);
+ else if (!version && strneq(buf, "VERSION_ID=", 11))
+ version = safe_strdup(&buf[11]);
+
+ if (distro && version) {
+ iprintf(ctx, "os: \"%s:%s\"\n", distro, version);
+ break;
+ }
+ }
+ free(distro);
+ free(version);
+ fclose(osrelease);
+ }
iprintf(ctx, "kernel: \"%s\"\n", kernel);
iprintf(ctx, "dmi: \"%s\"\n", buf);
indent_pop(ctx);
diff --git a/tools/libinput-record.man b/tools/libinput-record.man
index 17cf5d3e..a537d15f 100644
--- a/tools/libinput-record.man
+++ b/tools/libinput-record.man
@@ -106,6 +106,7 @@ ndevices: 2
libinput:
version: 1.10.0
system:
+ os: "fedora:26"
kernel: "4.13.9-200.fc26.x86_64"
dmi: "dmi:bvnLENOVO:bvrGJET72WW(2.22):bd02/21/2014:svnLENOVO:..."
devices:
@@ -206,6 +207,9 @@ libinput version
.SS system
Information about the system
.TP 8
+.B os: string
+Distribution ID and version, see \fIos-release(5)\fR
+.TP 8
.B kernel: string
Kernel version, see \fIuname(1)\fR
.TP 8