Port ostree-pull to GSConsole
As part of this, we need to ensure our streams are inherited across the chain of child processes.
This commit is contained in:
parent
fafb256f57
commit
6fde0b61a8
|
|
@ -1 +1 @@
|
||||||
Subproject commit 43a525fd40faf7dfd261bf3d7469f642a68fad68
|
Subproject commit 87bf968f3470657e5a80d3f937b2142f9f6fb53b
|
||||||
|
|
@ -118,7 +118,6 @@ typedef struct {
|
||||||
GError **async_error;
|
GError **async_error;
|
||||||
gboolean caught_error;
|
gboolean caught_error;
|
||||||
|
|
||||||
gboolean stdout_is_tty;
|
|
||||||
guint last_padding;
|
guint last_padding;
|
||||||
} OtPullData;
|
} OtPullData;
|
||||||
|
|
||||||
|
|
@ -238,7 +237,8 @@ uri_fetch_update_status (gpointer user_data)
|
||||||
diff--;
|
diff--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
g_print ("%c8%s", 0x1B, status->str);
|
|
||||||
|
gs_console_begin_status_line (gs_console_get (), status->str, NULL, NULL);
|
||||||
|
|
||||||
g_string_free (status, TRUE);
|
g_string_free (status, TRUE);
|
||||||
|
|
||||||
|
|
@ -289,10 +289,14 @@ static gboolean
|
||||||
run_mainloop_monitor_fetcher (OtPullData *pull_data)
|
run_mainloop_monitor_fetcher (OtPullData *pull_data)
|
||||||
{
|
{
|
||||||
GSource *update_timeout = NULL;
|
GSource *update_timeout = NULL;
|
||||||
|
GSConsole *console;
|
||||||
|
|
||||||
if (pull_data->stdout_is_tty)
|
console = gs_console_get ();
|
||||||
|
|
||||||
|
if (console)
|
||||||
{
|
{
|
||||||
g_print ("%c7", 0x1B);
|
gs_console_begin_status_line (console, "", NULL, NULL);
|
||||||
|
|
||||||
update_timeout = g_timeout_source_new_seconds (1);
|
update_timeout = g_timeout_source_new_seconds (1);
|
||||||
g_source_set_callback (update_timeout, uri_fetch_update_status, pull_data, NULL);
|
g_source_set_callback (update_timeout, uri_fetch_update_status, pull_data, NULL);
|
||||||
g_source_attach (update_timeout, g_main_loop_get_context (pull_data->loop));
|
g_source_attach (update_timeout, g_main_loop_get_context (pull_data->loop));
|
||||||
|
|
@ -301,9 +305,9 @@ run_mainloop_monitor_fetcher (OtPullData *pull_data)
|
||||||
|
|
||||||
g_main_loop_run (pull_data->loop);
|
g_main_loop_run (pull_data->loop);
|
||||||
|
|
||||||
if (pull_data->stdout_is_tty)
|
if (console)
|
||||||
{
|
{
|
||||||
g_print ("\n");
|
gs_console_end_status_line (console, NULL, NULL);
|
||||||
g_source_destroy (update_timeout);
|
g_source_destroy (update_timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1232,8 +1236,6 @@ ostree_builtin_pull (int argc, char **argv, GFile *repo_path, GError **error)
|
||||||
|
|
||||||
start_time = g_get_monotonic_time ();
|
start_time = g_get_monotonic_time ();
|
||||||
|
|
||||||
pull_data->stdout_is_tty = isatty (1);
|
|
||||||
|
|
||||||
pull_data->remote_name = g_strdup (argv[1]);
|
pull_data->remote_name = g_strdup (argv[1]);
|
||||||
pull_data->fetcher = ostree_fetcher_new (ostree_repo_get_tmpdir (pull_data->repo));
|
pull_data->fetcher = ostree_fetcher_new (ostree_repo_get_tmpdir (pull_data->repo));
|
||||||
config = ostree_repo_get_config (repo);
|
config = ostree_repo_get_config (repo);
|
||||||
|
|
|
||||||
|
|
@ -134,7 +134,7 @@ ot_admin_builtin_install (int argc, char **argv, OtAdminBuiltinOpts *admin_opts,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
if (!gs_subprocess_simple_run_sync (gs_file_get_path_cached (ostree_dir),
|
if (!gs_subprocess_simple_run_sync (gs_file_get_path_cached (ostree_dir),
|
||||||
GS_SUBPROCESS_STREAM_DISPOSITION_NULL,
|
GS_SUBPROCESS_STREAM_DISPOSITION_INHERIT,
|
||||||
cancellable, error,
|
cancellable, error,
|
||||||
"ostree", "admin", ostree_dir_arg, "os-init", osname, NULL))
|
"ostree", "admin", ostree_dir_arg, "os-init", osname, NULL))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
@ -172,7 +172,7 @@ ot_admin_builtin_install (int argc, char **argv, OtAdminBuiltinOpts *admin_opts,
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
if (!gs_subprocess_simple_run_sync (gs_file_get_path_cached (ostree_dir),
|
if (!gs_subprocess_simple_run_sync (gs_file_get_path_cached (ostree_dir),
|
||||||
GS_SUBPROCESS_STREAM_DISPOSITION_NULL,
|
GS_SUBPROCESS_STREAM_DISPOSITION_INHERIT,
|
||||||
cancellable, error,
|
cancellable, error,
|
||||||
"ostree", repoarg, "remote", "add",
|
"ostree", repoarg, "remote", "add",
|
||||||
osname, repourl, tree_to_deploy, NULL))
|
osname, repourl, tree_to_deploy, NULL))
|
||||||
|
|
@ -180,13 +180,13 @@ ot_admin_builtin_install (int argc, char **argv, OtAdminBuiltinOpts *admin_opts,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!gs_subprocess_simple_run_sync (gs_file_get_path_cached (ostree_dir),
|
if (!gs_subprocess_simple_run_sync (gs_file_get_path_cached (ostree_dir),
|
||||||
GS_SUBPROCESS_STREAM_DISPOSITION_NULL,
|
GS_SUBPROCESS_STREAM_DISPOSITION_INHERIT,
|
||||||
cancellable, error,
|
cancellable, error,
|
||||||
"ostree", "pull", repoarg, osname, NULL))
|
"ostree", "pull", repoarg, osname, NULL))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
if (!gs_subprocess_simple_run_sync (gs_file_get_path_cached (ostree_dir),
|
if (!gs_subprocess_simple_run_sync (gs_file_get_path_cached (ostree_dir),
|
||||||
GS_SUBPROCESS_STREAM_DISPOSITION_NULL,
|
GS_SUBPROCESS_STREAM_DISPOSITION_INHERIT,
|
||||||
cancellable, error,
|
cancellable, error,
|
||||||
"ostree", "admin", ostree_dir_arg, "deploy", osname,
|
"ostree", "admin", ostree_dir_arg, "deploy", osname,
|
||||||
tree_to_deploy, NULL))
|
tree_to_deploy, NULL))
|
||||||
|
|
|
||||||
|
|
@ -171,7 +171,7 @@ ot_admin_builtin_prune (int argc, char **argv, OtAdminBuiltinOpts *admin_opts, G
|
||||||
repo_arg = g_strconcat ("--repo=", gs_file_get_path_cached (repo_path), NULL);
|
repo_arg = g_strconcat ("--repo=", gs_file_get_path_cached (repo_path), NULL);
|
||||||
|
|
||||||
if (!gs_subprocess_simple_run_sync (gs_file_get_path_cached (ostree_dir),
|
if (!gs_subprocess_simple_run_sync (gs_file_get_path_cached (ostree_dir),
|
||||||
GS_SUBPROCESS_STREAM_DISPOSITION_NULL,
|
GS_SUBPROCESS_STREAM_DISPOSITION_INHERIT,
|
||||||
cancellable, error,
|
cancellable, error,
|
||||||
"ostree", repo_arg, "prune", "--refs-only",
|
"ostree", repo_arg, "prune", "--refs-only",
|
||||||
"--depth=0", NULL))
|
"--depth=0", NULL))
|
||||||
|
|
|
||||||
|
|
@ -106,7 +106,7 @@ ot_admin_builtin_pull_deploy (int argc, char **argv, OtAdminBuiltinOpts *admin_o
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
if (!gs_subprocess_simple_run_sync (gs_file_get_path_cached (ostree_dir),
|
if (!gs_subprocess_simple_run_sync (gs_file_get_path_cached (ostree_dir),
|
||||||
GS_SUBPROCESS_STREAM_DISPOSITION_NULL,
|
GS_SUBPROCESS_STREAM_DISPOSITION_INHERIT,
|
||||||
cancellable, error,
|
cancellable, error,
|
||||||
"ostree", "pull", repo_arg, osname, NULL))
|
"ostree", "pull", repo_arg, osname, NULL))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
@ -120,7 +120,7 @@ ot_admin_builtin_pull_deploy (int argc, char **argv, OtAdminBuiltinOpts *admin_o
|
||||||
gs_file_get_path_cached (admin_opts->boot_dir),
|
gs_file_get_path_cached (admin_opts->boot_dir),
|
||||||
NULL);
|
NULL);
|
||||||
if (!gs_subprocess_simple_run_sync (gs_file_get_path_cached (ostree_dir),
|
if (!gs_subprocess_simple_run_sync (gs_file_get_path_cached (ostree_dir),
|
||||||
GS_SUBPROCESS_STREAM_DISPOSITION_NULL,
|
GS_SUBPROCESS_STREAM_DISPOSITION_INHERIT,
|
||||||
cancellable, error,
|
cancellable, error,
|
||||||
"ostree", "admin", opt_ostree_dir_arg, opt_boot_dir_arg, "deploy", osname,
|
"ostree", "admin", opt_ostree_dir_arg, opt_boot_dir_arg, "deploy", osname,
|
||||||
deploy_name, NULL))
|
deploy_name, NULL))
|
||||||
|
|
|
||||||
|
|
@ -63,13 +63,13 @@ ot_admin_builtin_upgrade (int argc, char **argv, OtAdminBuiltinOpts *admin_opts,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
if (!gs_subprocess_simple_run_sync (gs_file_get_path_cached (ostree_dir),
|
if (!gs_subprocess_simple_run_sync (gs_file_get_path_cached (ostree_dir),
|
||||||
GS_SUBPROCESS_STREAM_DISPOSITION_NULL,
|
GS_SUBPROCESS_STREAM_DISPOSITION_INHERIT,
|
||||||
cancellable, error,
|
cancellable, error,
|
||||||
"ostree", "admin", ostree_dir_arg, "pull-deploy", osname, NULL))
|
"ostree", "admin", ostree_dir_arg, "pull-deploy", osname, NULL))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
if (!gs_subprocess_simple_run_sync (gs_file_get_path_cached (ostree_dir),
|
if (!gs_subprocess_simple_run_sync (gs_file_get_path_cached (ostree_dir),
|
||||||
GS_SUBPROCESS_STREAM_DISPOSITION_NULL,
|
GS_SUBPROCESS_STREAM_DISPOSITION_INHERIT,
|
||||||
cancellable, error,
|
cancellable, error,
|
||||||
"ostree", "admin", ostree_dir_arg, "prune", osname, NULL))
|
"ostree", "admin", ostree_dir_arg, "prune", osname, NULL))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue