mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2025-12-31 14:40:08 +01:00
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>
This commit is contained in:
parent
7198e33ecf
commit
428acee867
2 changed files with 29 additions and 1 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue