|
|
073af0 |
From f295f543064f1a0b5833fefccd6bb203b3527623 Mon Sep 17 00:00:00 2001
|
|
|
073af0 |
From: Colin Walters <walters@verbum.org>
|
|
|
073af0 |
Date: Sun, 17 Nov 2019 15:51:07 +0000
|
|
|
073af0 |
Subject: [PATCH] kargs: Support --append and --delete simultaneously
|
|
|
073af0 |
|
|
|
073af0 |
Code I wrote for the machine-config-operator expected it to
|
|
|
073af0 |
work, and I don't see a reason not to support it.
|
|
|
073af0 |
|
|
|
073af0 |
See https://github.com/openshift/machine-config-operator/issues/1265
|
|
|
073af0 |
---
|
|
|
073af0 |
src/app/rpmostree-builtin-kargs.c | 6 ------
|
|
|
073af0 |
src/daemon/rpmostreed-transaction-types.c | 20 ++++++++++----------
|
|
|
073af0 |
tests/vmcheck/test-kernel-args.sh | 9 +++++++++
|
|
|
073af0 |
3 files changed, 19 insertions(+), 16 deletions(-)
|
|
|
073af0 |
|
|
|
073af0 |
diff --git a/src/app/rpmostree-builtin-kargs.c b/src/app/rpmostree-builtin-kargs.c
|
|
|
073af0 |
index 359df946..fcfb727a 100644
|
|
|
073af0 |
--- a/src/app/rpmostree-builtin-kargs.c
|
|
|
073af0 |
+++ b/src/app/rpmostree-builtin-kargs.c
|
|
|
073af0 |
@@ -196,12 +196,6 @@ rpmostree_builtin_kargs (int argc,
|
|
|
073af0 |
"Cannot specify both --delete and --replace");
|
|
|
073af0 |
return FALSE;
|
|
|
073af0 |
}
|
|
|
073af0 |
- if (opt_kernel_delete_strings && opt_kernel_append_strings)
|
|
|
073af0 |
- {
|
|
|
073af0 |
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT,
|
|
|
073af0 |
- "Cannot specify both --delete and --append");
|
|
|
073af0 |
- return FALSE;
|
|
|
073af0 |
- }
|
|
|
073af0 |
if (opt_import_proc_cmdline && opt_deploy_index)
|
|
|
073af0 |
{
|
|
|
073af0 |
g_set_error (error, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT,
|
|
|
073af0 |
diff --git a/src/daemon/rpmostreed-transaction-types.c b/src/daemon/rpmostreed-transaction-types.c
|
|
|
073af0 |
index bc62b6c4..da432b83 100644
|
|
|
073af0 |
--- a/src/daemon/rpmostreed-transaction-types.c
|
|
|
073af0 |
+++ b/src/daemon/rpmostreed-transaction-types.c
|
|
|
073af0 |
@@ -2449,20 +2449,20 @@ kernel_arg_transaction_execute (RpmostreedTransaction *transaction,
|
|
|
073af0 |
return FALSE;
|
|
|
073af0 |
}
|
|
|
073af0 |
}
|
|
|
073af0 |
- else
|
|
|
073af0 |
+
|
|
|
073af0 |
+ if (self->kernel_args_replaced)
|
|
|
073af0 |
{
|
|
|
073af0 |
- if (self->kernel_args_replaced)
|
|
|
073af0 |
+ for (char **iter = self->kernel_args_replaced; iter && *iter; iter++)
|
|
|
073af0 |
{
|
|
|
073af0 |
- for (char **iter = self->kernel_args_replaced; iter && *iter; iter++)
|
|
|
073af0 |
- {
|
|
|
073af0 |
- const char *arg = *iter;
|
|
|
073af0 |
- if (!ostree_kernel_args_new_replace (kargs, arg, error))
|
|
|
073af0 |
- return FALSE;
|
|
|
073af0 |
- }
|
|
|
073af0 |
+ const char *arg = *iter;
|
|
|
073af0 |
+ if (!ostree_kernel_args_new_replace (kargs, arg, error))
|
|
|
073af0 |
+ return FALSE;
|
|
|
073af0 |
}
|
|
|
073af0 |
+ }
|
|
|
073af0 |
|
|
|
073af0 |
- if (self->kernel_args_added)
|
|
|
073af0 |
- ostree_kernel_args_append_argv (kargs, self->kernel_args_added);
|
|
|
073af0 |
+ if (self->kernel_args_added)
|
|
|
073af0 |
+ {
|
|
|
073af0 |
+ ostree_kernel_args_append_argv (kargs, self->kernel_args_added);
|
|
|
073af0 |
}
|
|
|
073af0 |
|
|
|
073af0 |
/* After all the arguments are processed earlier, we convert it to a string list*/
|
|
|
073af0 |
diff --git a/tests/vmcheck/test-kernel-args.sh b/tests/vmcheck/test-kernel-args.sh
|
|
|
073af0 |
index 570d986a..ca105ae3 100755
|
|
|
073af0 |
--- a/tests/vmcheck/test-kernel-args.sh
|
|
|
073af0 |
+++ b/tests/vmcheck/test-kernel-args.sh
|
|
|
073af0 |
@@ -48,6 +48,15 @@ assert_file_has_content_literal kargs.txt 'FOO=BAR'
|
|
|
073af0 |
assert_file_has_content_literal kargs.txt 'APPENDARG=VALAPPEND APPENDARG=2NDAPPEND'
|
|
|
073af0 |
echo "ok kargs append"
|
|
|
073af0 |
|
|
|
073af0 |
+# Ensure the result flows through with rpm-ostree kargs
|
|
|
073af0 |
+vm_rpmostree kargs --append=APPENDARG=3RDAPPEND --delete=APPENDARG=VALAPPEND
|
|
|
073af0 |
+vm_rpmostree kargs > kargs.txt
|
|
|
073af0 |
+assert_not_file_has_content kargs.txt 'APPENDARG=VALAPPEND'
|
|
|
073af0 |
+assert_file_has_content_literal kargs.txt 'APPENDARG=3RDAPPEND'
|
|
|
073af0 |
+# And reset to previous state
|
|
|
073af0 |
+vm_rpmostree cleanup -p
|
|
|
073af0 |
+echo "ok kargs append and delete"
|
|
|
073af0 |
+
|
|
|
073af0 |
# Test for rpm-ostree kargs delete
|
|
|
073af0 |
vm_kargs_now kargs --delete FOO
|
|
|
073af0 |
vm_cmd grep ^options /boot/loader/entries/ostree-2-$osname.conf > tmp_conf.txt
|
|
|
073af0 |
--
|
|
|
073af0 |
2.24.1
|
|
|
073af0 |
|