diff --git a/src/runtime.c b/src/runtime.c index f6ae88183c8bb4f5d099e74600f1e38c3fdafa8d..a670ddec4751aff489bc340548276bce1d04de94 100644 --- a/src/runtime.c +++ b/src/runtime.c @@ -77,6 +77,8 @@ struct _PvRuntime gboolean any_libc_from_provider; gboolean all_libc_from_provider; gboolean runtime_is_just_usr; + gboolean is_steamrt; + gboolean is_scout; }; struct _PvRuntimeClass @@ -703,7 +705,10 @@ pv_runtime_initable_init (GInitable *initable, GError **error) { PvRuntime *self = PV_RUNTIME (initable); + g_autofree gchar *contents = NULL; g_autofree gchar *files_ref = NULL; + g_autofree gchar *os_release = NULL; + gsize len; g_return_val_if_fail (PV_IS_RUNTIME (self), FALSE); g_return_val_if_fail (error == NULL || *error == NULL, FALSE); @@ -801,6 +806,43 @@ pv_runtime_initable_init (GInitable *initable, if (!g_file_test (self->libcapsule_knowledge, G_FILE_TEST_EXISTS)) g_clear_pointer (&self->libcapsule_knowledge, g_free); + os_release = g_build_filename (self->runtime_usr, "lib", "os-release", NULL); + + /* TODO: Teach SrtSystemInfo to be able to load lib/os-release from + * a merged-/usr, so we don't need to open-code this here */ + if (g_file_get_contents (os_release, &contents, &len, NULL)) + { + gsize i; + g_autofree gchar *id = NULL; + g_autofree gchar *version_id = NULL; + char *beginning_of_line = contents; + + for (i = 0; i < len; i++) + { + if (contents[i] == '\n') + { + contents[i] = '\0'; + + if (id == NULL && + g_str_has_prefix (beginning_of_line, "ID=")) + id = g_shell_unquote (beginning_of_line + strlen ("ID="), NULL); + else if (version_id == NULL && + g_str_has_prefix (beginning_of_line, "VERSION_ID=")) + version_id = g_shell_unquote (beginning_of_line + strlen ("VERSION_ID="), NULL); + + beginning_of_line = contents + i + 1; + } + } + + if (g_strcmp0 (id, "steamrt") == 0) + { + self->is_steamrt = TRUE; + + if (g_strcmp0 (version_id, "1") == 0) + self->is_scout = TRUE; + } + } + /* Path that, when resolved in the host namespace, points to the provider */ self->provider_in_host_namespace = pv_current_namespace_path_to_host_path (self->provider_in_current_namespace);