diff --git a/src/wrap.c b/src/wrap.c index 99bfd790431265bd15c625429fd3f57733807e21..168ddf09ff825d9d6ff4b8570af46c2fde7f170e 100644 --- a/src/wrap.c +++ b/src/wrap.c @@ -375,6 +375,7 @@ static gboolean opt_version = FALSE; static gboolean opt_version_only = FALSE; static gboolean opt_test = FALSE; static PvTerminal opt_terminal = PV_TERMINAL_AUTO; +static char *opt_write_bwrap = NULL; static gboolean opt_host_ld_preload_cb (const gchar *option_name, @@ -680,6 +681,10 @@ static GOptionEntry options[] = "If using --runtime, don't use the host graphics stack. " "This is likely to result in software rendering or a crash.", NULL }, + { "write-bwrap-arguments", '\0', + G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_FILENAME, &opt_write_bwrap, + "Write the final bwrap arguments, as null terminated strings, to the " + "given file path.", "PATH" }, { "test", '\0', G_OPTION_FLAG_NONE, G_OPTION_ARG_NONE, &opt_test, "Smoke test pressure-vessel-wrap and exit.", NULL }, @@ -1403,6 +1408,24 @@ main (int argc, flatpak_bwrap_finish (bwrap); + if (opt_write_bwrap != NULL) + { + FILE *file = fopen (opt_write_bwrap, "w"); + if (file == NULL) + { + g_warning ("An error occurred trying to write the bwrap arguments: %s", + g_strerror (errno)); + /* This is not a fatal error, try to continue */ + } + else + { + for (i = 0; i < bwrap->argv->len; i++) + fprintf (file, "%s%c", (gchar *)g_ptr_array_index (bwrap->argv, i), '\0'); + + fclose (file); + } + } + if (opt_only_prepare) ret = 0; else diff --git a/tests/containers.py b/tests/containers.py index 3a54a51049a674cc3f370a5a197cb09505ed90b7..a984763da906def529949f0c49d0688e9dcaf020 100755 --- a/tests/containers.py +++ b/tests/containers.py @@ -424,10 +424,13 @@ class TestContainers(BaseTest): ) os.makedirs(artifacts, exist_ok=True) + bwrap_temp_file = tempfile.NamedTemporaryFile() + argv = [ self.pv_wrap, '--runtime', runtime, '--verbose', + '--write-bwrap-arguments', bwrap_temp_file.name ] var = os.path.join(self.containers_dir, 'var') @@ -511,6 +514,14 @@ class TestContainers(BaseTest): ) self.assertEqual(completed.returncode, 0) + bwrap_arguments = bwrap_temp_file.read().decode().split("\0") + if locales: + self.assertIn("--generate-locales", bwrap_arguments) + else: + self.assertNotIn("--generate-locales", bwrap_arguments) + + bwrap_temp_file.close() + if copy: members = set(os.listdir(temp))