From 7c2de73b4fc3ec4adbb197c2c3a323be913e3d11 Mon Sep 17 00:00:00 2001 From: Simon McVittie <smcv@collabora.com> Date: Mon, 21 Nov 2022 13:33:25 +0000 Subject: [PATCH] pv-wrap: Replace --deterministic with SRT_LOG=diffable This serves the same function: sacrifice speed for predictability in order to get logs that can be compared line-by-line. Signed-off-by: Simon McVittie <smcv@collabora.com> --- pressure-vessel/wrap.1.md | 9 --------- pressure-vessel/wrap.c | 21 ++++++--------------- steam-runtime-tools/log-internal.h | 1 + steam-runtime-tools/log.c | 9 +++++++++ 4 files changed, 16 insertions(+), 24 deletions(-) diff --git a/pressure-vessel/wrap.1.md b/pressure-vessel/wrap.1.md index a684b80ea..7712b9d9e 100644 --- a/pressure-vessel/wrap.1.md +++ b/pressure-vessel/wrap.1.md @@ -46,11 +46,6 @@ pressure-vessel-wrap - run programs in a bubblewrap container : If *DIR* is an empty string, equivalent to `--no-copy-runtime`. Otherwise, equivalent to `--copy-runtime --variable-dir=DIR`. -`--deterministic` -: Process directories in a deterministic order. - This debugging option will make **pressure-vessel-wrap** slightly slower, - but makes it easier to compare log files. - `--env-if-host` *VAR=VAL* : If *COMMAND* is run with `/usr` from the host system, set environment variable *VAR* to *VAL*. If not, leave *VAR* unchanged. @@ -335,10 +330,6 @@ The following environment variables (among others) are read by `--no-copy-runtime`. Otherwise, it is a deprecated equivalent of `--copy-runtime --variable-dir="$PRESSURE_VESSEL_COPY_RUNTIME_INTO"`. -`PRESSURE_VESSEL_DETERMINISTIC` (boolean) -: If set to `1`, equivalent to `--deterministic`. - If set to `0`, no effect. - `PRESSURE_VESSEL_FILESYSTEMS_RO` (`:`-separated list of paths) : Make these paths available read-only inside the container if they exist, similar to `--filesystem` but read-only. diff --git a/pressure-vessel/wrap.c b/pressure-vessel/wrap.c index acadbcab1..7f9172136 100644 --- a/pressure-vessel/wrap.c +++ b/pressure-vessel/wrap.c @@ -384,7 +384,6 @@ typedef enum static gboolean opt_batch = FALSE; static gboolean opt_copy_runtime = FALSE; -static gboolean opt_deterministic = FALSE; static gboolean opt_devel = FALSE; static char **opt_env_if_host = NULL; static char **opt_filesystems = NULL; @@ -754,11 +753,6 @@ static GOptionEntry options[] = G_OPTION_FLAG_FILENAME|G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_CALLBACK, &opt_copy_runtime_into_cb, "Deprecated alias for --copy-runtime and --variable-dir", "DIR" }, - { "deterministic", '\0', - G_OPTION_FLAG_NONE, G_OPTION_ARG_NONE, &opt_deterministic, - "Enforce a deterministic sort order on arbitrarily-ordered things, " - "even if that's slower. [Default if $PRESSURE_VESSEL_DETERMINISTIC is 1]", - NULL }, { "devel", '\0', G_OPTION_FLAG_NONE, G_OPTION_ARG_NONE, &opt_devel, "Use a more permissive configuration that is helpful during development " @@ -1108,8 +1102,6 @@ main (int argc, NULL, NULL); opt_copy_runtime = _srt_boolean_environment ("PRESSURE_VESSEL_COPY_RUNTIME", opt_copy_runtime); - opt_deterministic = _srt_boolean_environment ("PRESSURE_VESSEL_DETERMINISTIC", - FALSE); opt_devel = _srt_boolean_environment ("PRESSURE_VESSEL_DEVEL", FALSE); opt_runtime_id = g_strdup (g_getenv ("PRESSURE_VESSEL_RUNTIME_ID")); @@ -1168,9 +1160,6 @@ main (int argc, log_flags = SRT_LOG_FLAGS_DIVERT_STDOUT | SRT_LOG_FLAGS_OPTIONALLY_JOURNAL; - if (opt_deterministic) - log_flags |= SRT_LOG_FLAGS_DIFFABLE; - if (opt_verbose) log_flags |= SRT_LOG_FLAGS_DEBUG; @@ -1178,6 +1167,8 @@ main (int argc, NULL, NULL, error)) goto out; + log_flags = _srt_util_get_log_flags (); + pv_wrap_detect_virtualization (&interpreter_root, &host_machine); /* Specifying either one of these mutually-exclusive options as a @@ -1645,7 +1636,7 @@ main (int argc, { SrtDirentCompareFunc cmp = NULL; - if (opt_deterministic) + if (log_flags & SRT_LOG_FLAGS_DIFFABLE) cmp = _srt_dirent_strcmp; if (!pv_runtime_garbage_collect_legacy (opt_variable_dir, @@ -1669,7 +1660,7 @@ main (int argc, g_autofree gchar *runtime_resolved = NULL; const char *runtime_path = NULL; - if (opt_deterministic) + if (log_flags & SRT_LOG_FLAGS_DIFFABLE) flags |= PV_RUNTIME_FLAGS_DETERMINISTIC; if (opt_gc_runtimes) @@ -1698,7 +1689,7 @@ main (int argc, if (opt_copy_runtime) flags |= PV_RUNTIME_FLAGS_COPY_RUNTIME; - if (opt_deterministic || opt_single_thread) + if ((log_flags & SRT_LOG_FLAGS_DIFFABLE) || opt_single_thread) flags |= PV_RUNTIME_FLAGS_SINGLE_THREAD; if (flatpak_subsandbox != NULL) @@ -1796,7 +1787,7 @@ main (int argc, { SrtDirentCompareFunc cmp = NULL; - if (opt_deterministic) + if (log_flags & SRT_LOG_FLAGS_DIFFABLE) cmp = _srt_dirent_strcmp; g_assert (!is_flatpak_env); diff --git a/steam-runtime-tools/log-internal.h b/steam-runtime-tools/log-internal.h index a4bca7b4d..d1a0e4daf 100644 --- a/steam-runtime-tools/log-internal.h +++ b/steam-runtime-tools/log-internal.h @@ -61,3 +61,4 @@ gboolean _srt_util_set_glib_log_handler (const char *prgname, gboolean _srt_util_restore_saved_fd (int saved_fd, int target_fd, GError **error); +SrtLogFlags _srt_util_get_log_flags (void); diff --git a/steam-runtime-tools/log.c b/steam-runtime-tools/log.c index 8b834e16a..cc8cc0907 100644 --- a/steam-runtime-tools/log.c +++ b/steam-runtime-tools/log.c @@ -680,3 +680,12 @@ _srt_util_set_glib_log_handler (const char *prgname, return TRUE; } + +/* + * Return the log flags that are currently active. + */ +SrtLogFlags +_srt_util_get_log_flags (void) +{ + return log_settings.flags; +} -- GitLab