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

karg-delete: support multiple times #3078

Merged
merged 2 commits into from
Oct 17, 2023
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
8 changes: 8 additions & 0 deletions man/ostree-admin-deploy.xml
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,14 @@ License along with this library. If not, see <https://www.gnu.org/licenses/>.
Append kernel argument; useful with e.g. console= that can be used multiple times.
</para></listitem>
</varlistentry>

<varlistentry>
<term><option>--karg-delete</option>="NAME=VALUE"</term>

<listitem><para>
Delete kernel argument if exists, can be used multiple times.
</para></listitem>
</varlistentry>
</variablelist>
</refsect1>

Expand Down
11 changes: 6 additions & 5 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,8 +79,8 @@ 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,
"Delete kernel argument if exists", "NAME=VALUE" },
{ "karg-delete", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_kernel_argv_delete,
"Delete kernel argument if exists, can be used multiple times", "NAME=VALUE" },
{ "overlay-initrd", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_overlay_initrds,
"Overlay iniramfs file", "FILE" },
{ NULL }
Expand Down Expand Up @@ -205,9 +205,10 @@ ot_admin_builtin_deploy (int argc, char **argv, OstreeCommandInvocation *invocat
ostree_kernel_args_append_argv (kargs, opt_kernel_argv_append);
}

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

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"
Loading