cleanup: Rebase spawn API on top of libgsystem GSSubprocess
We didn't need most the parameters anyways, so this is fewer lines of code. It also helps me test GSubprocess.
This commit is contained in:
parent
b423ea2041
commit
7fcebed4e8
|
|
@ -1 +1 @@
|
|||
Subproject commit 6956ab38077c65ffda21c30bcc4adee2d4826146
|
||||
Subproject commit c17376d4acbddfa1909d24167d3ce24531b3db1a
|
||||
|
|
@ -29,27 +29,21 @@
|
|||
gboolean
|
||||
ot_spawn_sync_checked (const char *cwd,
|
||||
char **argv,
|
||||
char **envp,
|
||||
GSpawnFlags flags,
|
||||
GSpawnChildSetupFunc child_setup,
|
||||
gpointer user_data,
|
||||
char **stdout_data,
|
||||
char **stderr_data,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
gint exit_status;
|
||||
char *ret_stdout_data = NULL;
|
||||
char *ret_stderr_data = NULL;
|
||||
gs_lobj GSSubprocessContext *context = NULL;
|
||||
gs_lobj GSSubprocess *proc = NULL;
|
||||
|
||||
if (!g_spawn_sync (cwd, argv, envp, flags, child_setup, user_data,
|
||||
stdout_data ? &ret_stdout_data : NULL,
|
||||
stderr_data ? &ret_stderr_data : NULL,
|
||||
&exit_status,
|
||||
error))
|
||||
context = gs_subprocess_context_new (argv);
|
||||
if (cwd)
|
||||
gs_subprocess_context_set_cwd (context, cwd);
|
||||
|
||||
if ((proc = gs_subprocess_new (context, error)) == NULL)
|
||||
goto out;
|
||||
|
||||
if (!g_spawn_check_exit_status (exit_status, error))
|
||||
if (!gs_subprocess_wait_sync_check (proc, cancellable, error))
|
||||
goto out;
|
||||
|
||||
ret = TRUE;
|
||||
|
|
|
|||
|
|
@ -29,12 +29,7 @@ G_BEGIN_DECLS
|
|||
|
||||
gboolean ot_spawn_sync_checked (const char *cwd,
|
||||
char **argv,
|
||||
char **envp,
|
||||
GSpawnFlags flags,
|
||||
GSpawnChildSetupFunc child_setup,
|
||||
gpointer user_data,
|
||||
char **stdout_data,
|
||||
char **stderr_data,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
|
||||
GThreadPool * ot_thread_pool_new_nproc (GFunc func,
|
||||
|
|
|
|||
|
|
@ -553,8 +553,7 @@ do_update_kernel (OtAdminDeploy *self,
|
|||
g_ptr_array_add (args, NULL);
|
||||
|
||||
if (!ot_spawn_sync_checked (gs_file_get_path_cached (self->ostree_dir),
|
||||
(char**)args->pdata, NULL, G_SPAWN_SEARCH_PATH,
|
||||
NULL, NULL, NULL, NULL, error))
|
||||
(char**)args->pdata, cancellable, error))
|
||||
goto out;
|
||||
|
||||
ret = TRUE;
|
||||
|
|
|
|||
|
|
@ -166,8 +166,8 @@ ot_admin_builtin_prune (int argc, char **argv, GFile *ostree_dir, GError **error
|
|||
g_ptr_array_add (prune_argv, NULL);
|
||||
|
||||
if (!ot_spawn_sync_checked (gs_file_get_path_cached (ostree_dir),
|
||||
(char**)prune_argv->pdata, NULL, G_SPAWN_SEARCH_PATH,
|
||||
NULL, NULL, NULL, NULL, error))
|
||||
(char**)prune_argv->pdata,
|
||||
cancellable, error))
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -153,8 +153,8 @@ ot_admin_builtin_pull_deploy (int argc, char **argv, GFile *ostree_dir, GError *
|
|||
g_ptr_array_add (subproc_args, NULL);
|
||||
|
||||
if (!ot_spawn_sync_checked (gs_file_get_path_cached (ostree_dir),
|
||||
(char**)subproc_args->pdata, NULL, G_SPAWN_SEARCH_PATH,
|
||||
NULL, NULL, NULL, NULL, error))
|
||||
(char**)subproc_args->pdata,
|
||||
cancellable, error))
|
||||
goto out;
|
||||
|
||||
g_clear_pointer (&subproc_args, (GDestroyNotify)g_ptr_array_unref);
|
||||
|
|
@ -170,8 +170,8 @@ ot_admin_builtin_pull_deploy (int argc, char **argv, GFile *ostree_dir, GError *
|
|||
g_ptr_array_add (subproc_args, NULL);
|
||||
|
||||
if (!ot_spawn_sync_checked (gs_file_get_path_cached (ostree_dir),
|
||||
(char**)subproc_args->pdata, NULL, G_SPAWN_SEARCH_PATH,
|
||||
NULL, NULL, NULL, NULL, error))
|
||||
(char**)subproc_args->pdata,
|
||||
cancellable, error))
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -129,9 +129,8 @@ update_initramfs (OtAdminUpdateKernel *self,
|
|||
g_ptr_array_add (mkinitramfs_args, NULL);
|
||||
|
||||
g_print ("Generating initramfs using %s...\n", deploy_path);
|
||||
if (!ot_spawn_sync_checked (NULL, (char**)mkinitramfs_args->pdata, NULL,
|
||||
G_SPAWN_SEARCH_PATH,
|
||||
NULL, NULL, NULL, NULL, error))
|
||||
if (!ot_spawn_sync_checked (NULL, (char**)mkinitramfs_args->pdata,
|
||||
cancellable, error))
|
||||
goto out;
|
||||
|
||||
initramfs_tmp_file = g_file_get_child (tmpdir, "initramfs-ostree.img");
|
||||
|
|
@ -266,8 +265,8 @@ update_grub (OtAdminUpdateKernel *self,
|
|||
g_ptr_array_add (grubby_args, NULL);
|
||||
|
||||
g_print ("Adding OSTree grub entry...\n");
|
||||
if (!ot_spawn_sync_checked (NULL, (char**)grubby_args->pdata, NULL, G_SPAWN_SEARCH_PATH,
|
||||
NULL, NULL, NULL, NULL, error))
|
||||
if (!ot_spawn_sync_checked (NULL, (char**)grubby_args->pdata,
|
||||
cancellable, error))
|
||||
goto out;
|
||||
}
|
||||
else
|
||||
|
|
|
|||
|
|
@ -57,8 +57,7 @@ ot_admin_ensure_initialized (GFile *ostree_dir,
|
|||
gs_file_get_path_cached (ostree_dir));
|
||||
const char *child_argv[] = { "ostree", opt_repo_arg, "init", NULL };
|
||||
|
||||
if (!ot_spawn_sync_checked (NULL, (char**)child_argv, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL,
|
||||
NULL, NULL, error))
|
||||
if (!ot_spawn_sync_checked (NULL, (char**)child_argv, cancellable, error))
|
||||
{
|
||||
g_prefix_error (error, "Failed to initialize repository: ");
|
||||
goto out;
|
||||
|
|
|
|||
Loading…
Reference in New Issue