Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kargs: Support --append and --delete simultaneously #1940

Merged
merged 1 commit into from
Dec 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions src/app/rpmostree-builtin-kargs.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,12 +196,6 @@ rpmostree_builtin_kargs (int argc,
"Cannot specify both --delete and --replace");
return FALSE;
}
if (opt_kernel_delete_strings && opt_kernel_append_strings)
{
g_set_error (error, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT,
"Cannot specify both --delete and --append");
return FALSE;
}
if (opt_import_proc_cmdline && opt_deploy_index)
{
g_set_error (error, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT,
Expand Down
20 changes: 10 additions & 10 deletions src/daemon/rpmostreed-transaction-types.c
Original file line number Diff line number Diff line change
Expand Up @@ -2449,20 +2449,20 @@ kernel_arg_transaction_execute (RpmostreedTransaction *transaction,
return FALSE;
}
}
else

if (self->kernel_args_replaced)
{
if (self->kernel_args_replaced)
for (char **iter = self->kernel_args_replaced; iter && *iter; iter++)
{
for (char **iter = self->kernel_args_replaced; iter && *iter; iter++)
{
const char *arg = *iter;
if (!ostree_kernel_args_new_replace (kargs, arg, error))
return FALSE;
}
const char *arg = *iter;
if (!ostree_kernel_args_new_replace (kargs, arg, error))
return FALSE;
}
}

if (self->kernel_args_added)
ostree_kernel_args_append_argv (kargs, self->kernel_args_added);
if (self->kernel_args_added)
{
ostree_kernel_args_append_argv (kargs, self->kernel_args_added);
}

/* After all the arguments are processed earlier, we convert it to a string list*/
Expand Down
9 changes: 9 additions & 0 deletions tests/vmcheck/test-kernel-args.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@ assert_file_has_content_literal kargs.txt 'FOO=BAR'
assert_file_has_content_literal kargs.txt 'APPENDARG=VALAPPEND APPENDARG=2NDAPPEND'
echo "ok kargs append"

# Ensure the result flows through with rpm-ostree kargs
vm_rpmostree kargs --append=APPENDARG=3RDAPPEND --delete=APPENDARG=VALAPPEND
vm_rpmostree kargs > kargs.txt
assert_not_file_has_content kargs.txt 'APPENDARG=VALAPPEND'
assert_file_has_content_literal kargs.txt 'APPENDARG=3RDAPPEND'
# And reset to previous state
vm_rpmostree cleanup -p
echo "ok kargs append and delete"

# Test for rpm-ostree kargs delete
vm_kargs_now kargs --delete FOO
vm_cmd grep ^options /boot/loader/entries/ostree-2-$osname.conf > tmp_conf.txt
Expand Down