diff --git a/lib/src/cli.rs b/lib/src/cli.rs index 97fa35d9..a336246e 100644 --- a/lib/src/cli.rs +++ b/lib/src/cli.rs @@ -549,7 +549,7 @@ async fn upgrade(opts: UpgradeOpts) -> Result<()> { } } } else { - let fetched = crate::deploy::pull(repo, imgref, opts.quiet).await?; + let fetched = crate::deploy::pull(repo, imgref, None, opts.quiet).await?; let staged_digest = staged_image.as_ref().map(|s| s.image_digest.as_str()); let fetched_digest = fetched.manifest_digest.as_str(); tracing::debug!("staged: {staged_digest:?}"); @@ -642,7 +642,7 @@ async fn switch(opts: SwitchOpts) -> Result<()> { } let new_spec = RequiredHostSpec::from_spec(&new_spec)?; - let fetched = crate::deploy::pull(repo, &target, opts.quiet).await?; + let fetched = crate::deploy::pull(repo, &target, None, opts.quiet).await?; if !opts.retain { // By default, we prune the previous ostree ref so it will go away after later upgrades @@ -700,7 +700,7 @@ async fn edit(opts: EditOpts) -> Result<()> { return crate::deploy::rollback(sysroot).await; } - let fetched = crate::deploy::pull(repo, new_spec.image, opts.quiet).await?; + let fetched = crate::deploy::pull(repo, new_spec.image, None, opts.quiet).await?; // TODO gc old layers here diff --git a/lib/src/deploy.rs b/lib/src/deploy.rs index 59325b26..6f9e7d30 100644 --- a/lib/src/deploy.rs +++ b/lib/src/deploy.rs @@ -223,10 +223,14 @@ async fn handle_layer_progress_print( pub(crate) async fn pull( repo: &ostree::Repo, imgref: &ImageReference, + target_imgref: Option<&OstreeImageReference>, quiet: bool, ) -> Result> { let ostree_imgref = &OstreeImageReference::from(imgref.clone()); let mut imp = new_importer(repo, ostree_imgref).await?; + if let Some(target) = target_imgref { + imp.set_target(target); + } let prep = match imp.prepare().await? { PrepareResult::AlreadyPresent(c) => { println!("No changes in {imgref:#} => {}", c.manifest_digest); @@ -254,8 +258,10 @@ pub(crate) async fn pull( let _ = printer.await; } let import = import?; + let wrote_imgref = target_imgref.as_ref().unwrap_or(&ostree_imgref); if let Some(msg) = - ostree_container::store::image_filtered_content_warning(repo, &ostree_imgref.imgref)? + ostree_container::store::image_filtered_content_warning(repo, &wrote_imgref.imgref) + .context("Image content warning")? { crate::journal::journal_print(libsystemd::logging::Priority::Notice, &msg); } diff --git a/lib/src/install.rs b/lib/src/install.rs index 66139ecd..ae68f352 100644 --- a/lib/src/install.rs +++ b/lib/src/install.rs @@ -668,7 +668,7 @@ async fn install_container( let spec_imgref = ImageReference::from(src_imageref.clone()); let repo = &sysroot.repo(); repo.set_disable_fsync(true); - crate::deploy::pull(repo, &spec_imgref, false).await?; + crate::deploy::pull(repo, &spec_imgref, Some(&state.target_imgref), false).await?; repo.set_disable_fsync(false); }