Skip to content

Commit

Permalink
karg-delete: support multiple times
Browse files Browse the repository at this point in the history
  • Loading branch information
HuijingHei committed Oct 17, 2023
1 parent 5d92407 commit a46a5fa
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
12 changes: 8 additions & 4 deletions src/ostree/ot-admin-builtin-deploy.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ static gboolean opt_no_prune;
static gboolean opt_no_merge;
static char **opt_kernel_argv;
static char **opt_kernel_argv_append;
static char *opt_kernel_argv_delete;
static char **opt_kernel_argv_delete;
static gboolean opt_kernel_proc_cmdline;
static char *opt_osname;
static char *opt_origin_path;
Expand Down Expand Up @@ -79,7 +79,7 @@ static GOptionEntry options[] = {
"NAME=VALUE" },
{ "karg-none", 0, 0, G_OPTION_ARG_NONE, &opt_kernel_arg_none, "Do not import kernel arguments",
NULL },
{ "karg-delete", 0, 0, G_OPTION_ARG_STRING, &opt_kernel_argv_delete,
{ "karg-delete", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_kernel_argv_delete,
"Delete kernel argument if exists", "NAME=VALUE" },
{ "overlay-initrd", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_overlay_initrds,
"Overlay iniramfs file", "FILE" },
Expand Down Expand Up @@ -207,8 +207,12 @@ ot_admin_builtin_deploy (int argc, char **argv, OstreeCommandInvocation *invocat

if (opt_kernel_argv_delete)
{
if (!ostree_kernel_args_delete (kargs, opt_kernel_argv_delete, error))
return FALSE;
for (char **strviter = opt_kernel_argv_delete; strviter && *strviter; strviter++)
{
const char *arg = *strviter;
if (!ostree_kernel_args_delete_if_present (kargs, arg, error))
return FALSE;
}
}

g_autoptr (GPtrArray) overlay_initrd_chksums = NULL;
Expand Down
4 changes: 1 addition & 3 deletions tests/test-admin-deploy-karg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,9 @@ assert_file_has_content sysroot/boot/loader/entries/ostree-2-testos.conf 'option
echo "ok deploy --karg-append"

assert_file_has_content sysroot/boot/loader/entries/ostree-2-testos.conf 'options.*quiet .*TESTARG=TESTVALUE .*APPENDARG=VALAPPEND .*APPENDARG=2NDAPPEND'
${CMD_PREFIX} ostree admin deploy --os=testos --karg-delete=TESTARG=TESTVALUE testos:testos/buildmain/x86_64-runtime
${CMD_PREFIX} ostree admin deploy --os=testos --karg-delete=TESTARG=TESTVALUE --karg-delete=quiet --karg-delete=APPENDARG=VALAPPEND testos:testos/buildmain/x86_64-runtime
assert_not_file_has_content sysroot/boot/loader/entries/ostree-2-testos.conf 'options.*TESTARG=TESTVALUE'
${CMD_PREFIX} ostree admin deploy --os=testos --karg-delete=quiet testos:testos/buildmain/x86_64-runtime
assert_not_file_has_content sysroot/boot/loader/entries/ostree-2-testos.conf 'options.*quiet'
${CMD_PREFIX} ostree admin deploy --os=testos --karg-delete=APPENDARG=VALAPPEND testos:testos/buildmain/x86_64-runtime
assert_not_file_has_content sysroot/boot/loader/entries/ostree-2-testos.conf 'options.*APPENDARG=VALAPPEND'

echo "ok deploy --karg-delete"

0 comments on commit a46a5fa

Please sign in to comment.