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

switch: Be idempotent #274

Merged
merged 1 commit into from
Jan 22, 2024
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
4 changes: 2 additions & 2 deletions docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ on the target, use
bootc switch --transport oci /var/mnt/usb/myos.oci
```

The above command can only be invoked once currently; thereafter, use `bootc upgrade`
as normal to fetch updates from the USB device.
The above command is only necessary once, and thereafter will be idempotent.
Then, use `bootc upgrade --apply` to fetch and apply the update from the USB device.

This process can all be automated by creating systemd
units that look for a USB device with a specific label, mount (optionally with LUKS
Expand Down
3 changes: 2 additions & 1 deletion lib/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,8 @@ async fn switch(opts: SwitchOpts) -> Result<()> {
};

if new_spec == host.spec {
anyhow::bail!("No changes in current host spec");
println!("Image specification is unchanged.");
return Ok(());
}
let new_spec = RequiredHostSpec::from_spec(&new_spec)?;

Expand Down
9 changes: 8 additions & 1 deletion tests/kolainst/basic
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,17 @@ case "${AUTOPKGTEST_REBOOT_MARK:-}" in
bootc status > status.txt
grep 'Version:' status.txt
bootc status --json > status.json
image=$(jq -r '.status.booted.image.image' < status.json)
image=$(jq '.status.booted.image.image' < status.json)
echo "booted into $image"
echo "ok status test"

# Switch should be idempotent
# (also TODO, get rid of the crazy .image.image.image nesting)
name=$(echo "${image}" | jq -r '.image')
bootc switch $name
staged=$(bootc status --json | jq .status.staged)
test "$staged" = "null"

host_ty=$(jq -r '.status.type' < status.json)
test "${host_ty}" = "bootcHost"
# Now fake things out with an empty /run
Expand Down
Loading