mirror of
https://github.com/ostreedev/ostree.git
synced 2024-12-22 17:35:55 +03:00
Teach --karg-delete option to ostree admin deploy
See https://github.com/ostreedev/ostree/issues/2586
This commit is contained in:
parent
e632e5f1f1
commit
0ba3bfe4fd
@ -41,6 +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 gboolean opt_kernel_proc_cmdline;
|
||||
static char *opt_osname;
|
||||
static char *opt_origin_path;
|
||||
@ -62,6 +63,7 @@ static GOptionEntry options[] = {
|
||||
{ "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 },
|
||||
{ "karg-delete", 0, 0, G_OPTION_ARG_STRING, &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" },
|
||||
{ NULL }
|
||||
};
|
||||
@ -90,6 +92,18 @@ ot_admin_builtin_deploy (int argc, char **argv, OstreeCommandInvocation *invocat
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (opt_kernel_arg_none && opt_kernel_argv_delete)
|
||||
{
|
||||
ot_util_usage_error (context, "Can't specify both --karg-none and --karg-delete", error);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (opt_no_merge && opt_kernel_argv_delete)
|
||||
{
|
||||
ot_util_usage_error (context, "Can't specify both --no-merge and --karg-delete", error);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
const char *refspec = argv[1];
|
||||
|
||||
OstreeRepo *repo = ostree_sysroot_repo (sysroot);
|
||||
@ -145,7 +159,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 && (opt_kernel_argv || opt_kernel_argv_append))
|
||||
else if (merge_deployment && (opt_kernel_argv || opt_kernel_argv_append || opt_kernel_argv_delete))
|
||||
{
|
||||
OstreeBootconfigParser *bootconfig = ostree_deployment_get_bootconfig (merge_deployment);
|
||||
g_auto(GStrv) previous_args = g_strsplit (ostree_bootconfig_parser_get (bootconfig, "options"), " ", -1);
|
||||
@ -171,6 +185,12 @@ 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)
|
||||
{
|
||||
if (!ostree_kernel_args_delete (kargs, opt_kernel_argv_delete, error))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
g_autoptr(GPtrArray) overlay_initrd_chksums = NULL;
|
||||
for (char **it = opt_overlay_initrds; it && *it; it++)
|
||||
{
|
||||
|
@ -24,7 +24,7 @@ set -euo pipefail
|
||||
# Exports OSTREE_SYSROOT so --sysroot not needed.
|
||||
setup_os_repository "archive" "syslinux"
|
||||
|
||||
echo "1..3"
|
||||
echo "1..4"
|
||||
|
||||
${CMD_PREFIX} ostree --repo=sysroot/ostree/repo pull-local --remote=testos testos-repo testos/buildmain/x86_64-runtime
|
||||
rev=$(${CMD_PREFIX} ostree --repo=sysroot/ostree/repo rev-parse testos/buildmain/x86_64-runtime)
|
||||
@ -69,3 +69,13 @@ ${CMD_PREFIX} ostree admin deploy --os=testos --karg-append=FOO=TESTORDERED --k
|
||||
assert_file_has_content sysroot/boot/loader/entries/ostree-2-testos.conf 'options.*APPENDARG=VALAPPEND .*APPENDARG=2NDAPPEND .*FOO=TESTORDERED .*APPENDARG=3RDAPPEND'
|
||||
|
||||
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
|
||||
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…
Reference in New Issue
Block a user