ostree admin deploy: Add --no-prune option
authorWilliam Manley <will@williammanley.net>
Mon, 15 Jan 2018 20:53:54 +0000 (20:53 +0000)
committerAtomic Bot <atomic-devel@projectatomic.io>
Tue, 16 Jan 2018 18:59:06 +0000 (18:59 +0000)
If you want cleanup, but don't want to prune the repo.  Pruning can
be quite expensive so ostree admin deploy can be much faster without
pruning.

Closes: #1418
Approved by: cgwalters

src/ostree/ot-admin-builtin-deploy.c

index 68d17e954a53f0ad1bf212877493d99ed0c57337..a4aa3c3387cba3d3d03d1195612d1190687d1d11 100644 (file)
@@ -35,6 +35,7 @@ static gboolean opt_retain;
 static gboolean opt_retain_pending;
 static gboolean opt_retain_rollback;
 static gboolean opt_not_as_default;
+static gboolean opt_no_prune;
 static char **opt_kernel_argv;
 static char **opt_kernel_argv_append;
 static gboolean opt_kernel_proc_cmdline;
@@ -50,6 +51,7 @@ static gboolean opt_kernel_arg_none;
 static GOptionEntry options[] = {
   { "os", 0, 0, G_OPTION_ARG_STRING, &opt_osname, "Use a different operating system root than the current one", "OSNAME" },
   { "origin-file", 0, 0, G_OPTION_ARG_FILENAME, &opt_origin_path, "Specify origin file", "FILENAME" },
+  { "no-prune", 0, 0, G_OPTION_ARG_NONE, &opt_no_prune, "Don't prune the repo when done", NULL},
   { "retain", 0, 0, G_OPTION_ARG_NONE, &opt_retain, "Do not delete previous deployments", NULL },
   { "retain-pending", 0, 0, G_OPTION_ARG_NONE, &opt_retain_pending, "Do not delete pending deployments", NULL },
   { "retain-rollback", 0, 0, G_OPTION_ARG_NONE, &opt_retain_rollback, "Do not delete rollback deployments", NULL },
@@ -182,8 +184,16 @@ ot_admin_builtin_deploy (int argc, char **argv, OstreeCommandInvocation *invocat
 
   /* And finally, cleanup of any leftover data.
    */
-  if (!ostree_sysroot_cleanup (self, cancellable, error))
-    return FALSE;
+  if (opt_no_prune)
+    {
+      if (!ostree_sysroot_prepare_cleanup (sysroot, cancellable, error))
+        return FALSE;
+    }
+  else
+    {
+      if (!ostree_sysroot_cleanup (sysroot, cancellable, error))
+        return FALSE;
+    }
 
   return TRUE;
 }