Skip to content

Commit

Permalink
lib/deploy: Add flag ostree-kargs-override to bootconfig
Browse files Browse the repository at this point in the history
Add an ostree-kargs-override flag which is set to true if the
kargs of the current deployment were overridden. The flag is
written to the bootconfig, and persists in subsequent deployments.

This is in preparation for ostreedev#1836 which needs a way to determine
whether the previous deployment's kargs were modified by the user,
so that user-modified kargs can be carried forward to the next
deployment.
  • Loading branch information
Robert Fairley committed Apr 10, 2019
1 parent da57956 commit 980621d
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/libostree/ostree-sysroot-deploy.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
}

Expand Down
33 changes: 31 additions & 2 deletions tests/test-admin-deploy-karg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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"

0 comments on commit 980621d

Please sign in to comment.