lib/deploy: Throw an error if trying to stage when not ostree-booted

There's no reason to do this.  I didn't actually hit this problem,
but it's a corner case that just occurred to me while working on
the code.

I think callers should be adapted to skip trying to use staging
if there's no booted deployment.

Closes: #1568
Approved by: jlebon
This commit is contained in:
Colin Walters authored and Atomic Bot committed 2018-05-02 13:27:01 +00:00
1 parent f5f8e2c540
commit 25ba8db987
2 files changed
+11 -1

No files matched your search

+7 -1
View File
@@ -21,7 +21,7 @@
set -euo pipefail
echo "1..$((23 + ${extra_admin_tests:-0}))"
echo "1..$((24 + ${extra_admin_tests:-0}))"
function validate_bootloader() {
cd ${test_tmpdir};
@@ -78,6 +78,12 @@ assert_ostree_deployment_refs 1/1/0
${CMD_PREFIX} ostree admin status
echo "ok layout"
if ${CMD_PREFIX} ostree admin deploy --stage --os=testos testos:testos/buildmaster/x86_64-runtime 2>err.txt; then
fatal "staged when not booted"
fi
assert_file_has_content_literal err.txt "Cannot stage a deployment when not currently booted into an OSTree system"
echo "ok staging does not work when not booted"
orig_mtime=$(stat -c '%.Y' sysroot/ostree/deploy)
${CMD_PREFIX} ostree admin deploy --os=testos testos:testos/buildmaster/x86_64-runtime
new_mtime=$(stat -c '%.Y' sysroot/ostree/deploy)