From e15e6206b24c9191fab16385d80c0e47085deed6 Mon Sep 17 00:00:00 2001 From: Ludovico de Nittis <ludovico.denittis@collabora.com> Date: Fri, 24 Apr 2020 16:07:18 +0200 Subject: [PATCH] Add a function to return the absolute path to "ubuntu12_32" directory We already stored the path to "ubuntu12_32" but this information was kept private. Now we give a public function to access it and we also show this information in the JSON output. Signed-off-by: Ludovico de Nittis <ludovico.denittis@collabora.com> --- bin/system-info.c | 5 +++++ bin/system-info.md | 6 ++++++ steam-runtime-tools/system-info.c | 26 ++++++++++++++++++++++++++ steam-runtime-tools/system-info.h | 1 + tests/fake-home.c | 11 +++++------ tests/fake-home.h | 1 + tests/system-info.c | 7 +++++++ 7 files changed, 51 insertions(+), 6 deletions(-) diff --git a/bin/system-info.c b/bin/system-info.c index 903dde23e..de092fc91 100644 --- a/bin/system-info.c +++ b/bin/system-info.c @@ -808,6 +808,7 @@ main (int argc, gchar *version = NULL; gchar *inst_path = NULL; gchar *data_path = NULL; + gchar *bin32_path = NULL; gchar *rt_path = NULL; gchar **overrides = NULL; gchar **messages = NULL; @@ -891,6 +892,9 @@ main (int argc, json_builder_set_member_name (builder, "data_path"); data_path = srt_system_info_dup_steam_data_path (info); json_builder_add_string_value (builder, data_path); + json_builder_set_member_name (builder, "bin32_path"); + bin32_path = srt_system_info_dup_steam_bin32_path (info); + json_builder_add_string_value (builder, bin32_path); json_builder_set_member_name (builder, "issues"); json_builder_begin_array (builder); steam_issues = srt_system_info_get_steam_issues (info); @@ -1299,6 +1303,7 @@ main (int argc, json_node_free (root); g_object_unref (builder); g_object_unref (info); + g_free (bin32_path); g_free (rt_path); g_free (data_path); g_free (inst_path); diff --git a/bin/system-info.md b/bin/system-info.md index c0ee32e98..b921f4b18 100644 --- a/bin/system-info.md +++ b/bin/system-info.md @@ -51,6 +51,12 @@ keys: This is usually the same as **path** but can differ under some circumstances. + **bin32_path** + : A string: the absolute path to the Steam "ubuntu12_32" directory, + typically containing **steam-runtime** among others. + This is usually a direct subdirectory of **path** but can differ under + some circumstances. + **issues** : An array of strings representing problems with the Steam installation. If empty, no problems were found. diff --git a/steam-runtime-tools/system-info.c b/steam-runtime-tools/system-info.c index 93b4c7f01..749d6899c 100644 --- a/steam-runtime-tools/system-info.c +++ b/steam-runtime-tools/system-info.c @@ -1770,6 +1770,32 @@ srt_system_info_dup_steam_data_path (SrtSystemInfo *self) return g_strdup (srt_steam_get_data_path (self->steam_data)); } +/** + * srt_system_info_dup_steam_bin32_path: + * @self: The #SrtSystemInfo object + * + * Return the absolute path to the Steam `ubuntu12_32` directory in use + * (the directory containing `steam-runtime/` among other files and + * directories). + * + * Under normal circumstances, this is a `ubuntu12_32` direct subdirectory + * under the srt_system_info_dup_steam_installation_path(). + * Typically of the form `/home/me/.local/share/Steam/ubuntu12_32`. + * It is canonically accessed via the symbolic link `~/.steam/bin32`. + * + * Returns: (transfer full) (type filename) (nullable): The absolute path + * to the Steam `ubuntu12_32` directory, or %NULL if it could not be + * determined. Free with g_free(). + */ +gchar * +srt_system_info_dup_steam_bin32_path (SrtSystemInfo *self) +{ + g_return_val_if_fail (SRT_IS_SYSTEM_INFO (self), NULL); + + ensure_steam_cached (self); + return g_strdup (srt_steam_get_bin32_path (self->steam_data)); +} + static void ensure_os_cached (SrtSystemInfo *self) { diff --git a/steam-runtime-tools/system-info.h b/steam-runtime-tools/system-info.h index 08ecca115..cb3717b90 100644 --- a/steam-runtime-tools/system-info.h +++ b/steam-runtime-tools/system-info.h @@ -169,6 +169,7 @@ SrtSteamIssues srt_system_info_get_steam_issues (SrtSystemInfo *self); SrtSteam *srt_system_info_get_steam_details (SrtSystemInfo *self); gchar *srt_system_info_dup_steam_installation_path (SrtSystemInfo *self); gchar *srt_system_info_dup_steam_data_path (SrtSystemInfo *self); +gchar *srt_system_info_dup_steam_bin32_path (SrtSystemInfo *self); gchar ** srt_system_info_list_pressure_vessel_overrides (SrtSystemInfo *self, gchar ***messages); diff --git a/tests/fake-home.c b/tests/fake-home.c index 7bb855b9e..a1f59352e 100644 --- a/tests/fake-home.c +++ b/tests/fake-home.c @@ -106,7 +106,6 @@ fake_home_create_structure (FakeHome *f) gchar *local_share = NULL; gchar *ld_path = NULL; gchar *prepended_path = NULL; - gchar *ubuntu12_32 = NULL; gchar *app_home = NULL; gchar *data_name = NULL; GError *error = NULL; @@ -156,8 +155,9 @@ const gchar *mime_cache = f->steam_data = g_strdup (f->steam_install); } - f->runtime = g_build_filename (f->steam_install, "ubuntu12_32", - "steam-runtime", NULL); + f->ubuntu12_32 = g_build_filename (f->steam_install, "ubuntu12_32", NULL); + + f->runtime = g_build_filename (f->ubuntu12_32, "steam-runtime", NULL); scripts = g_build_filename (f->runtime, "scripts", NULL); @@ -249,8 +249,7 @@ const gchar *mime_cache = dot_steam_bin32 = g_build_filename (dot_steam, "bin32", NULL); symlink_gfile = g_file_new_for_path (dot_steam_bin32); - ubuntu12_32 = g_build_filename (f->steam_install, "ubuntu12_32", NULL); - g_file_make_symbolic_link (symlink_gfile, ubuntu12_32, NULL, &error); + g_file_make_symbolic_link (symlink_gfile, f->ubuntu12_32, NULL, &error); g_object_unref (symlink_gfile); g_assert_no_error (error); } @@ -355,7 +354,6 @@ const gchar *mime_cache = g_free (local_share); g_free (ld_path); g_free (prepended_path); - g_free (ubuntu12_32); g_free (app_home); g_free (data_name); @@ -382,6 +380,7 @@ fake_home_clean_up (FakeHome *f) g_free (f->home); g_free (f->steam_data); g_free (f->steam_install); + g_free (f->ubuntu12_32); g_free (f->runtime); g_free (f->pinned_32); g_free (f->pinned_64); diff --git a/tests/fake-home.h b/tests/fake-home.h index 2c74f07a2..58e3bb5a4 100644 --- a/tests/fake-home.h +++ b/tests/fake-home.h @@ -46,6 +46,7 @@ typedef struct gchar *home; gchar *steam_install; gchar *steam_data; + gchar *ubuntu12_32; gchar *runtime; gchar *pinned_32; gchar *pinned_64; diff --git a/tests/system-info.c b/tests/system-info.c index 02196391e..d894b517e 100644 --- a/tests/system-info.c +++ b/tests/system-info.c @@ -740,6 +740,7 @@ steam_runtime (Fixture *f, SrtSteam *steam_details; gchar *runtime_path = NULL; gchar *installation_path = NULL; + gchar *bin32_path = NULL; FakeHome *fake_home; fake_home = fake_home_new (fake_home_path); @@ -755,8 +756,11 @@ steam_runtime (Fixture *f, g_assert_cmpstr (runtime_path, ==, fake_home->runtime); installation_path = srt_system_info_dup_steam_installation_path (info); g_assert_cmpstr (installation_path, ==, fake_home->steam_install); + bin32_path = srt_system_info_dup_steam_bin32_path (info); + g_assert_cmpstr (bin32_path, ==, fake_home->ubuntu12_32); g_free (runtime_path); g_free (installation_path); + g_free (bin32_path); /* Do the check again, this time using the cache */ runtime_issues = srt_system_info_get_runtime_issues (info); @@ -765,6 +769,8 @@ steam_runtime (Fixture *f, g_assert_cmpstr (runtime_path, ==, fake_home->runtime); installation_path = srt_system_info_dup_steam_installation_path (info); g_assert_cmpstr (installation_path, ==, fake_home->steam_install); + bin32_path = srt_system_info_dup_steam_bin32_path (info); + g_assert_cmpstr (bin32_path, ==, fake_home->ubuntu12_32); /* Check for Steam issues */ steam_issues = srt_system_info_get_steam_issues (info); @@ -786,6 +792,7 @@ steam_runtime (Fixture *f, g_object_unref (steam_details); g_free (runtime_path); g_free (installation_path); + g_free (bin32_path); } static void -- GitLab