deploy: add --karg-none argument
authorGatis Paeglis <gatis.paeglis@qt.io>
Fri, 12 Aug 2016 09:51:04 +0000 (11:51 +0200)
committerAtomic Bot <atomic-devel@projectatomic.io>
Wed, 10 Jan 2018 13:52:58 +0000 (13:52 +0000)
If the current deployment has "rootwait root=/dev/sda2",
but the new deployment does not need "rootwait" anymore,
there is no way to clear this arg at the moment (as opposed
to "karg=root=", which overrides any earlier argument with
the same name). With "--karg-none" users can now clear all
the previous args and set new "root=":

ostree admin deploy --karg-none --karg=root=LABEL=rootfs

Closes: #1401
Approved by: cgwalters

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

index 83550331d45e6b0230220c7d78734949454ef184..8da9dbc3eb74b5c847e6c590314d350ffec91c74 100644 (file)
@@ -40,6 +40,7 @@ static char **opt_kernel_argv_append;
 static gboolean opt_kernel_proc_cmdline;
 static char *opt_osname;
 static char *opt_origin_path;
+static gboolean opt_kernel_arg_none;
 
 /* ATTENTION:
  * Please remember to update the bash-completion script (bash/ostree) and
@@ -56,6 +57,7 @@ static GOptionEntry options[] = {
   { "karg-proc-cmdline", 0, 0, G_OPTION_ARG_NONE, &opt_kernel_proc_cmdline, "Import current /proc/cmdline", NULL },
   { "karg", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_kernel_argv, "Set kernel argument, like root=/dev/sda1; this overrides any earlier argument with the same name", "NAME=VALUE" },
   { "karg-append", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_kernel_argv_append, "Append kernel argument; useful with e.g. console= that can be used multiple times", "NAME=VALUE" },
+  { "karg-none", 0, 0, G_OPTION_ARG_NONE, &opt_kernel_arg_none, "Do not import kernel arguments", NULL },
   { NULL }
 };
 
@@ -79,6 +81,12 @@ ot_admin_builtin_deploy (int argc, char **argv, OstreeCommandInvocation *invocat
       return FALSE;
     }
 
+  if (opt_kernel_proc_cmdline && opt_kernel_arg_none)
+  {
+    ot_util_usage_error (context, "Can't specify both --karg-proc-cmdline and --karg-none", error);
+    return FALSE;
+  }
+
   const char *refspec = argv[1];
 
   OstreeRepo *repo = ostree_sysroot_repo (sysroot);
@@ -130,7 +138,7 @@ ot_admin_builtin_deploy (int argc, char **argv, OstreeCommandInvocation *invocat
       if (!_ostree_kernel_args_append_proc_cmdline (kargs, cancellable, error))
         return FALSE;
     }
-  else if (merge_deployment)
+  else if (merge_deployment && !opt_kernel_arg_none)
     {
       OstreeBootconfigParser *bootconfig = ostree_deployment_get_bootconfig (merge_deployment);
       g_auto(GStrv) previous_args = g_strsplit (ostree_bootconfig_parser_get (bootconfig, "options"), " ", -1);