Skip to content

Commit 221e382

Browse files
authored
Merge pull request #109 from cgwalters/bump-ostree-ext
deploy: Use new ostree API to GC images
2 parents a100269 + 98eaf32 commit 221e382

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

lib/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ rust-version = "1.64.0"
1111
[dependencies]
1212
anyhow = "1.0"
1313
camino = { version = "1.0.4", features = ["serde1"] }
14-
ostree-ext = "0.11"
14+
ostree-ext = "0.11.2"
1515
clap = { version= "4.2", features = ["derive"] }
1616
clap_mangen = { version = "0.2", optional = true }
1717
cap-std-ext = "2"

lib/src/cli.rs

+3-8
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,8 @@ async fn stage(
263263
if let Some(imgref) = ostree_imgref.as_ref() {
264264
println!("Queued for next boot: {imgref}");
265265
}
266+
ostree_container::deploy::remove_undeployed_images(sysroot).context("Pruning images")?;
267+
266268
Ok(())
267269
}
268270

@@ -368,8 +370,6 @@ async fn switch(opts: SwitchOpts) -> Result<()> {
368370
let repo = &sysroot.repo();
369371
let booted_deployment = &sysroot.require_booted_deployment()?;
370372
let (_deployments, host) = crate::status::get_status(sysroot, Some(booted_deployment))?;
371-
// SAFETY: There must be a status if we have a booted deployment
372-
let status = host.status.unwrap();
373373

374374
let transport = ostree_container::Transport::try_from(opts.transport.as_str())?;
375375
let imgref = ostree_container::ImageReference {
@@ -399,17 +399,12 @@ async fn switch(opts: SwitchOpts) -> Result<()> {
399399
let fetched = pull(repo, &target, opts.quiet).await?;
400400

401401
if !opts.retain {
402-
// By default, we prune the previous ostree ref or container image
402+
// By default, we prune the previous ostree ref so it will go away after later upgrades
403403
if let Some(booted_origin) = booted_deployment.origin() {
404404
if let Some(ostree_ref) = booted_origin.optional_string("origin", "refspec")? {
405405
let (remote, ostree_ref) =
406406
ostree::parse_refspec(&ostree_ref).context("Failed to parse ostree ref")?;
407407
repo.set_ref_immediate(remote.as_deref(), &ostree_ref, None, cancellable)?;
408-
} else if let Some(booted_image) = status.booted.as_ref().and_then(|b| b.image.as_ref())
409-
{
410-
let imgref = OstreeImageReference::from(booted_image.image.clone());
411-
ostree_container::store::remove_image(repo, &imgref.imgref)?;
412-
let _nlayers: u32 = ostree_container::store::gc_image_layers(repo)?;
413408
}
414409
}
415410
}

0 commit comments

Comments
 (0)