diff --git a/src/libostree/ostree-sysroot-deploy.c b/src/libostree/ostree-sysroot-deploy.c index d37861b7ba..a3eb4311fc 100644 --- a/src/libostree/ostree-sysroot-deploy.c +++ b/src/libostree/ostree-sysroot-deploy.c @@ -2470,6 +2470,7 @@ _ostree_deployment_set_bootconfig_from_kargs (OstreeDeployment *deployment, _ostree_kernel_args_append_argv (kargs, override_kernel_argv); g_autofree char *new_options = _ostree_kernel_args_to_string (kargs); ostree_bootconfig_parser_set (bootconfig, "options", new_options); + ostree_bootconfig_parser_set (bootconfig, "ostree-kargs-override", "true"); } } @@ -2580,17 +2581,26 @@ sysroot_finalize_deployment (OstreeSysroot *self, if (!glnx_opendirat (self->sysroot_fd, deployment_path, TRUE, &deployment_dfd, error)) return FALSE; - /* Only use the merge if we didn't get an override */ - if (!override_kernel_argv && merge_deployment) + /* If we didn't get an override in this deployment, copy kargs directly from + * the merge deployment. */ + if (!override_kernel_argv) { - /* Override the bootloader arguments */ - OstreeBootconfigParser *merge_bootconfig = ostree_deployment_get_bootconfig (merge_deployment); - if (merge_bootconfig) + OstreeBootconfigParser *merge_bootconfig = NULL; + gboolean kargs_overridden = FALSE; + if (merge_deployment) { - const char *opts = ostree_bootconfig_parser_get (merge_bootconfig, "options"); - ostree_bootconfig_parser_set (ostree_deployment_get_bootconfig (deployment), "options", opts); + merge_bootconfig = ostree_deployment_get_bootconfig (merge_deployment); + if (merge_bootconfig) + { + /* Copy kargs from the merge deployment. */ + const char *opts = ostree_bootconfig_parser_get (merge_bootconfig, "options"); + ostree_bootconfig_parser_set (ostree_deployment_get_bootconfig (deployment), "options", opts); + kargs_overridden = g_strcmp0 (ostree_bootconfig_parser_get (merge_bootconfig, "ostree-kargs-override"), + "true") == 0; + } + if (kargs_overridden) + ostree_bootconfig_parser_set (ostree_deployment_get_bootconfig (deployment), "ostree-kargs-override", "true"); } - } if (merge_deployment) diff --git a/tests/test-admin-deploy-karg.sh b/tests/test-admin-deploy-karg.sh index aade011ce9..b41ab5858c 100755 --- a/tests/test-admin-deploy-karg.sh +++ b/tests/test-admin-deploy-karg.sh @@ -26,7 +26,7 @@ set -euo pipefail # Exports OSTREE_SYSROOT so --sysroot not needed. setup_os_repository "archive" "syslinux" -echo "1..3" +echo "1..7" ${CMD_PREFIX} ostree --repo=sysroot/ostree/repo pull-local --remote=testos testos-repo testos/buildmaster/x86_64-runtime rev=$(${CMD_PREFIX} ostree --repo=sysroot/ostree/repo rev-parse testos/buildmaster/x86_64-runtime) @@ -61,9 +61,38 @@ echo "ok deploy --karg-proc-cmdline" ${CMD_PREFIX} ostree admin status ${CMD_PREFIX} ostree admin undeploy 0 -${CMD_PREFIX} ostree admin deploy --os=testos --karg-append=APPENDARG=VALAPPEND --karg-append=APPENDARG=2NDAPPEND testos:testos/buildmaster/x86_64-runtime +${CMD_PREFIX} ostree admin deploy --os=testos --karg-append=APPENDARG=VALAPPEND --karg-append=APPENDARG=2NDAPPEND testos:testos/buildmaster/x86_64-runtime assert_file_has_content sysroot/boot/loader/entries/ostree-2-testos.conf 'options.*FOO=BAR' assert_file_has_content sysroot/boot/loader/entries/ostree-2-testos.conf 'options.*TESTARG=TESTVALUE' assert_file_has_content sysroot/boot/loader/entries/ostree-2-testos.conf 'options.*APPENDARG=VALAPPEND .*APPENDARG=2NDAPPEND' echo "ok deploy --karg-append" + +${CMD_PREFIX} ostree admin status +${CMD_PREFIX} ostree admin undeploy 0 + +${CMD_PREFIX} ostree admin deploy --os=testos --karg-append=APPENDARG=VALAPPEND --karg-append=APPENDARG=2NDAPPEND testos:testos/buildmaster/x86_64-runtime +assert_file_has_content sysroot/boot/loader/entries/ostree-2-testos.conf 'ostree-kargs-override.*true' + +echo "ok kargs override flag" + +${CMD_PREFIX} ostree admin deploy --os=testos testos:testos/buildmaster/x86_64-runtime +assert_file_has_content sysroot/boot/loader/entries/ostree-2-testos.conf 'ostree-kargs-override.*true' + +echo "ok kargs override flag persists" + +${CMD_PREFIX} ostree admin status +# Clear both previous deployments, to start with clean bootconfig. +${CMD_PREFIX} ostree admin undeploy 1 +${CMD_PREFIX} ostree admin undeploy 0 + +# Create an extra deployment to use as the merge deployment. +${CMD_PREFIX} ostree admin deploy --os=testos testos:testos/buildmaster/x86_64-runtime +assert_not_file_has_content sysroot/boot/loader/entries/ostree-2-testos.conf 'ostree-kargs-override' + +echo "ok no kargs override flag" + +${CMD_PREFIX} ostree admin deploy --os=testos testos:testos/buildmaster/x86_64-runtime +assert_not_file_has_content sysroot/boot/loader/entries/ostree-2-testos.conf 'ostree-kargs-override' + +echo "ok no kargs override flag persists"