[ostree] cleanup: Rebase spawn API on top of libgsystem GSSubprocess



commit 7fcebed4e88151ce97a0cc4e61ca0f6b0bb4bcdf
Author: Colin Walters <walters verbum org>
Date:   Sat Dec 1 16:53:06 2012 -0500

    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.

 src/libgsystem                              |    2 +-
 src/libotutil/ot-spawn-utils.c              |   24 +++++++++---------------
 src/libotutil/ot-spawn-utils.h              |    7 +------
 src/ostree/ot-admin-builtin-deploy.c        |    3 +--
 src/ostree/ot-admin-builtin-prune.c         |    4 ++--
 src/ostree/ot-admin-builtin-pull-deploy.c   |    8 ++++----
 src/ostree/ot-admin-builtin-update-kernel.c |    9 ++++-----
 src/ostree/ot-admin-functions.c             |    3 +--
 8 files changed, 23 insertions(+), 37 deletions(-)
---
diff --git a/src/libgsystem b/src/libgsystem
index 6956ab3..c17376d 160000
--- a/src/libgsystem
+++ b/src/libgsystem
@@ -1 +1 @@
-Subproject commit 6956ab38077c65ffda21c30bcc4adee2d4826146
+Subproject commit c17376d4acbddfa1909d24167d3ce24531b3db1a
diff --git a/src/libotutil/ot-spawn-utils.c b/src/libotutil/ot-spawn-utils.c
index c05ac3b..5a551fe 100644
--- a/src/libotutil/ot-spawn-utils.c
+++ b/src/libotutil/ot-spawn-utils.c
@@ -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;
diff --git a/src/libotutil/ot-spawn-utils.h b/src/libotutil/ot-spawn-utils.h
index 6bd4058..4673e27 100644
--- a/src/libotutil/ot-spawn-utils.h
+++ b/src/libotutil/ot-spawn-utils.h
@@ -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,
diff --git a/src/ostree/ot-admin-builtin-deploy.c b/src/ostree/ot-admin-builtin-deploy.c
index 92026e7..924640d 100644
--- a/src/ostree/ot-admin-builtin-deploy.c
+++ b/src/ostree/ot-admin-builtin-deploy.c
@@ -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;
diff --git a/src/ostree/ot-admin-builtin-prune.c b/src/ostree/ot-admin-builtin-prune.c
index 3465417..3e5d755 100644
--- a/src/ostree/ot-admin-builtin-prune.c
+++ b/src/ostree/ot-admin-builtin-prune.c
@@ -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;
     }
 
diff --git a/src/ostree/ot-admin-builtin-pull-deploy.c b/src/ostree/ot-admin-builtin-pull-deploy.c
index 10a5d54..7fed1e6 100644
--- a/src/ostree/ot-admin-builtin-pull-deploy.c
+++ b/src/ostree/ot-admin-builtin-pull-deploy.c
@@ -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;
   }
 
diff --git a/src/ostree/ot-admin-builtin-update-kernel.c b/src/ostree/ot-admin-builtin-update-kernel.c
index c2f7226..8d6774e 100644
--- a/src/ostree/ot-admin-builtin-update-kernel.c
+++ b/src/ostree/ot-admin-builtin-update-kernel.c
@@ -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
diff --git a/src/ostree/ot-admin-functions.c b/src/ostree/ot-admin-functions.c
index c291e9e..e7e3e5a 100644
--- a/src/ostree/ot-admin-functions.c
+++ b/src/ostree/ot-admin-functions.c
@@ -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;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]