Skip to content
Snippets Groups Projects
Commit 7c2de73b authored by Simon McVittie's avatar Simon McVittie
Browse files

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: default avatarSimon McVittie <smcv@collabora.com>
parent 804934e1
No related branches found
No related tags found
1 merge request!525pv-wrap: Replace --deterministic with SRT_LOG=diffable
Pipeline #37088 passed
...@@ -46,11 +46,6 @@ pressure-vessel-wrap - run programs in a bubblewrap container ...@@ -46,11 +46,6 @@ pressure-vessel-wrap - run programs in a bubblewrap container
: If *DIR* is an empty string, equivalent to `--no-copy-runtime`. : If *DIR* is an empty string, equivalent to `--no-copy-runtime`.
Otherwise, equivalent to `--copy-runtime --variable-dir=DIR`. 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* `--env-if-host` *VAR=VAL*
: If *COMMAND* is run with `/usr` from the host system, set : If *COMMAND* is run with `/usr` from the host system, set
environment variable *VAR* to *VAL*. If not, leave *VAR* unchanged. environment variable *VAR* to *VAL*. If not, leave *VAR* unchanged.
...@@ -335,10 +330,6 @@ The following environment variables (among others) are read by ...@@ -335,10 +330,6 @@ The following environment variables (among others) are read by
`--no-copy-runtime`. Otherwise, it is a deprecated equivalent of `--no-copy-runtime`. Otherwise, it is a deprecated equivalent of
`--copy-runtime --variable-dir="$PRESSURE_VESSEL_COPY_RUNTIME_INTO"`. `--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) `PRESSURE_VESSEL_FILESYSTEMS_RO` (`:`-separated list of paths)
: Make these paths available read-only inside the container if they : Make these paths available read-only inside the container if they
exist, similar to `--filesystem` but read-only. exist, similar to `--filesystem` but read-only.
......
...@@ -384,7 +384,6 @@ typedef enum ...@@ -384,7 +384,6 @@ typedef enum
static gboolean opt_batch = FALSE; static gboolean opt_batch = FALSE;
static gboolean opt_copy_runtime = FALSE; static gboolean opt_copy_runtime = FALSE;
static gboolean opt_deterministic = FALSE;
static gboolean opt_devel = FALSE; static gboolean opt_devel = FALSE;
static char **opt_env_if_host = NULL; static char **opt_env_if_host = NULL;
static char **opt_filesystems = NULL; static char **opt_filesystems = NULL;
...@@ -754,11 +753,6 @@ static GOptionEntry options[] = ...@@ -754,11 +753,6 @@ static GOptionEntry options[] =
G_OPTION_FLAG_FILENAME|G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_CALLBACK, G_OPTION_FLAG_FILENAME|G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_CALLBACK,
&opt_copy_runtime_into_cb, &opt_copy_runtime_into_cb,
"Deprecated alias for --copy-runtime and --variable-dir", "DIR" }, "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', { "devel", '\0',
G_OPTION_FLAG_NONE, G_OPTION_ARG_NONE, &opt_devel, G_OPTION_FLAG_NONE, G_OPTION_ARG_NONE, &opt_devel,
"Use a more permissive configuration that is helpful during development " "Use a more permissive configuration that is helpful during development "
...@@ -1108,8 +1102,6 @@ main (int argc, ...@@ -1108,8 +1102,6 @@ main (int argc,
NULL, NULL); NULL, NULL);
opt_copy_runtime = _srt_boolean_environment ("PRESSURE_VESSEL_COPY_RUNTIME", opt_copy_runtime = _srt_boolean_environment ("PRESSURE_VESSEL_COPY_RUNTIME",
opt_copy_runtime); opt_copy_runtime);
opt_deterministic = _srt_boolean_environment ("PRESSURE_VESSEL_DETERMINISTIC",
FALSE);
opt_devel = _srt_boolean_environment ("PRESSURE_VESSEL_DEVEL", FALSE); opt_devel = _srt_boolean_environment ("PRESSURE_VESSEL_DEVEL", FALSE);
opt_runtime_id = g_strdup (g_getenv ("PRESSURE_VESSEL_RUNTIME_ID")); opt_runtime_id = g_strdup (g_getenv ("PRESSURE_VESSEL_RUNTIME_ID"));
...@@ -1168,9 +1160,6 @@ main (int argc, ...@@ -1168,9 +1160,6 @@ main (int argc,
log_flags = SRT_LOG_FLAGS_DIVERT_STDOUT | SRT_LOG_FLAGS_OPTIONALLY_JOURNAL; log_flags = SRT_LOG_FLAGS_DIVERT_STDOUT | SRT_LOG_FLAGS_OPTIONALLY_JOURNAL;
if (opt_deterministic)
log_flags |= SRT_LOG_FLAGS_DIFFABLE;
if (opt_verbose) if (opt_verbose)
log_flags |= SRT_LOG_FLAGS_DEBUG; log_flags |= SRT_LOG_FLAGS_DEBUG;
...@@ -1178,6 +1167,8 @@ main (int argc, ...@@ -1178,6 +1167,8 @@ main (int argc,
NULL, NULL, error)) NULL, NULL, error))
goto out; goto out;
log_flags = _srt_util_get_log_flags ();
pv_wrap_detect_virtualization (&interpreter_root, &host_machine); pv_wrap_detect_virtualization (&interpreter_root, &host_machine);
/* Specifying either one of these mutually-exclusive options as a /* Specifying either one of these mutually-exclusive options as a
...@@ -1645,7 +1636,7 @@ main (int argc, ...@@ -1645,7 +1636,7 @@ main (int argc,
{ {
SrtDirentCompareFunc cmp = NULL; SrtDirentCompareFunc cmp = NULL;
if (opt_deterministic) if (log_flags & SRT_LOG_FLAGS_DIFFABLE)
cmp = _srt_dirent_strcmp; cmp = _srt_dirent_strcmp;
if (!pv_runtime_garbage_collect_legacy (opt_variable_dir, if (!pv_runtime_garbage_collect_legacy (opt_variable_dir,
...@@ -1669,7 +1660,7 @@ main (int argc, ...@@ -1669,7 +1660,7 @@ main (int argc,
g_autofree gchar *runtime_resolved = NULL; g_autofree gchar *runtime_resolved = NULL;
const char *runtime_path = NULL; const char *runtime_path = NULL;
if (opt_deterministic) if (log_flags & SRT_LOG_FLAGS_DIFFABLE)
flags |= PV_RUNTIME_FLAGS_DETERMINISTIC; flags |= PV_RUNTIME_FLAGS_DETERMINISTIC;
if (opt_gc_runtimes) if (opt_gc_runtimes)
...@@ -1698,7 +1689,7 @@ main (int argc, ...@@ -1698,7 +1689,7 @@ main (int argc,
if (opt_copy_runtime) if (opt_copy_runtime)
flags |= PV_RUNTIME_FLAGS_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; flags |= PV_RUNTIME_FLAGS_SINGLE_THREAD;
if (flatpak_subsandbox != NULL) if (flatpak_subsandbox != NULL)
...@@ -1796,7 +1787,7 @@ main (int argc, ...@@ -1796,7 +1787,7 @@ main (int argc,
{ {
SrtDirentCompareFunc cmp = NULL; SrtDirentCompareFunc cmp = NULL;
if (opt_deterministic) if (log_flags & SRT_LOG_FLAGS_DIFFABLE)
cmp = _srt_dirent_strcmp; cmp = _srt_dirent_strcmp;
g_assert (!is_flatpak_env); g_assert (!is_flatpak_env);
......
...@@ -61,3 +61,4 @@ gboolean _srt_util_set_glib_log_handler (const char *prgname, ...@@ -61,3 +61,4 @@ gboolean _srt_util_set_glib_log_handler (const char *prgname,
gboolean _srt_util_restore_saved_fd (int saved_fd, gboolean _srt_util_restore_saved_fd (int saved_fd,
int target_fd, int target_fd,
GError **error); GError **error);
SrtLogFlags _srt_util_get_log_flags (void);
...@@ -680,3 +680,12 @@ _srt_util_set_glib_log_handler (const char *prgname, ...@@ -680,3 +680,12 @@ _srt_util_set_glib_log_handler (const char *prgname,
return TRUE; return TRUE;
} }
/*
* Return the log flags that are currently active.
*/
SrtLogFlags
_srt_util_get_log_flags (void)
{
return log_settings.flags;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment