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:
1 parent
b423ea2041
commit
7fcebed4e8
8 files changed
+23
-37
No files matched your search
+1
-1
Submodule src/libgsystem updated: 6956ab3807...c17376d4ac.
@@ -29,27 +29,21 @@
|
|||||||
gboolean
|
gboolean
|
||||||
ot_spawn_sync_checked (const char *cwd,
|
ot_spawn_sync_checked (const char *cwd,
|
||||||
char **argv,
|
char **argv,
|
||||||
char **envp,
|
GCancellable *cancellable,
|
||||||
GSpawnFlags flags,
|
|
||||||
GSpawnChildSetupFunc child_setup,
|
|
||||||
gpointer user_data,
|
|
||||||
char **stdout_data,
|
|
||||||
char **stderr_data,
|
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
gboolean ret = FALSE;
|
gboolean ret = FALSE;
|
||||||
gint exit_status;
|
gs_lobj GSSubprocessContext *context = NULL;
|
||||||
char *ret_stdout_data = NULL;
|
gs_lobj GSSubprocess *proc = NULL;
|
||||||
char *ret_stderr_data = NULL;
|
|
||||||
|
|
||||||
if (!g_spawn_sync (cwd, argv, envp, flags, child_setup, user_data,
|
context = gs_subprocess_context_new (argv);
|
||||||
stdout_data ? &ret_stdout_data : NULL,
|
if (cwd)
|
||||||
stderr_data ? &ret_stderr_data : NULL,
|
gs_subprocess_context_set_cwd (context, cwd);
|
||||||
&exit_status,
|
|
||||||
error))
|
if ((proc = gs_subprocess_new (context, error)) == NULL)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
if (!g_spawn_check_exit_status (exit_status, error))
|
if (!gs_subprocess_wait_sync_check (proc, cancellable, error))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
ret = TRUE;
|
ret = TRUE;
|
||||||
|
|||||||
@@ -29,12 +29,7 @@ G_BEGIN_DECLS
|
|||||||
|
|
||||||
gboolean ot_spawn_sync_checked (const char *cwd,
|
gboolean ot_spawn_sync_checked (const char *cwd,
|
||||||
char **argv,
|
char **argv,
|
||||||
char **envp,
|
GCancellable *cancellable,
|
||||||
GSpawnFlags flags,
|
|
||||||
GSpawnChildSetupFunc child_setup,
|
|
||||||
gpointer user_data,
|
|
||||||
char **stdout_data,
|
|
||||||
char **stderr_data,
|
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
GThreadPool * ot_thread_pool_new_nproc (GFunc func,
|
GThreadPool * ot_thread_pool_new_nproc (GFunc func,
|
||||||
|
|||||||
@@ -553,8 +553,7 @@ do_update_kernel (OtAdminDeploy *self,
|
|||||||
g_ptr_array_add (args, NULL);
|
g_ptr_array_add (args, NULL);
|
||||||
|
|
||||||
if (!ot_spawn_sync_checked (gs_file_get_path_cached (self->ostree_dir),
|
if (!ot_spawn_sync_checked (gs_file_get_path_cached (self->ostree_dir),
|
||||||
(char**)args->pdata, NULL, G_SPAWN_SEARCH_PATH,
|
(char**)args->pdata, cancellable, error))
|
||||||
NULL, NULL, NULL, NULL, error))
|
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
ret = TRUE;
|
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);
|
g_ptr_array_add (prune_argv, NULL);
|
||||||
|
|
||||||
if (!ot_spawn_sync_checked (gs_file_get_path_cached (ostree_dir),
|
if (!ot_spawn_sync_checked (gs_file_get_path_cached (ostree_dir),
|
||||||
(char**)prune_argv->pdata, NULL, G_SPAWN_SEARCH_PATH,
|
(char**)prune_argv->pdata,
|
||||||
NULL, NULL, NULL, NULL, error))
|
cancellable, error))
|
||||||
goto out;
|
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);
|
g_ptr_array_add (subproc_args, NULL);
|
||||||
|
|
||||||
if (!ot_spawn_sync_checked (gs_file_get_path_cached (ostree_dir),
|
if (!ot_spawn_sync_checked (gs_file_get_path_cached (ostree_dir),
|
||||||
(char**)subproc_args->pdata, NULL, G_SPAWN_SEARCH_PATH,
|
(char**)subproc_args->pdata,
|
||||||
NULL, NULL, NULL, NULL, error))
|
cancellable, error))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
g_clear_pointer (&subproc_args, (GDestroyNotify)g_ptr_array_unref);
|
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);
|
g_ptr_array_add (subproc_args, NULL);
|
||||||
|
|
||||||
if (!ot_spawn_sync_checked (gs_file_get_path_cached (ostree_dir),
|
if (!ot_spawn_sync_checked (gs_file_get_path_cached (ostree_dir),
|
||||||
(char**)subproc_args->pdata, NULL, G_SPAWN_SEARCH_PATH,
|
(char**)subproc_args->pdata,
|
||||||
NULL, NULL, NULL, NULL, error))
|
cancellable, error))
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -129,9 +129,8 @@ update_initramfs (OtAdminUpdateKernel *self,
|
|||||||
g_ptr_array_add (mkinitramfs_args, NULL);
|
g_ptr_array_add (mkinitramfs_args, NULL);
|
||||||
|
|
||||||
g_print ("Generating initramfs using %s...\n", deploy_path);
|
g_print ("Generating initramfs using %s...\n", deploy_path);
|
||||||
if (!ot_spawn_sync_checked (NULL, (char**)mkinitramfs_args->pdata, NULL,
|
if (!ot_spawn_sync_checked (NULL, (char**)mkinitramfs_args->pdata,
|
||||||
G_SPAWN_SEARCH_PATH,
|
cancellable, error))
|
||||||
NULL, NULL, NULL, NULL, error))
|
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
initramfs_tmp_file = g_file_get_child (tmpdir, "initramfs-ostree.img");
|
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_ptr_array_add (grubby_args, NULL);
|
||||||
|
|
||||||
g_print ("Adding OSTree grub entry...\n");
|
g_print ("Adding OSTree grub entry...\n");
|
||||||
if (!ot_spawn_sync_checked (NULL, (char**)grubby_args->pdata, NULL, G_SPAWN_SEARCH_PATH,
|
if (!ot_spawn_sync_checked (NULL, (char**)grubby_args->pdata,
|
||||||
NULL, NULL, NULL, NULL, error))
|
cancellable, error))
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -57,8 +57,7 @@ ot_admin_ensure_initialized (GFile *ostree_dir,
|
|||||||
gs_file_get_path_cached (ostree_dir));
|
gs_file_get_path_cached (ostree_dir));
|
||||||
const char *child_argv[] = { "ostree", opt_repo_arg, "init", NULL };
|
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,
|
if (!ot_spawn_sync_checked (NULL, (char**)child_argv, cancellable, error))
|
||||||
NULL, NULL, error))
|
|
||||||
{
|
{
|
||||||
g_prefix_error (error, "Failed to initialize repository: ");
|
g_prefix_error (error, "Failed to initialize repository: ");
|
||||||
goto out;
|
goto out;
|
||||||
|
|||||||
Reference in new issue
Block a user