diff --git a/lib/src/container/deploy.rs b/lib/src/container/deploy.rs index c3649653..410da1d6 100644 --- a/lib/src/container/deploy.rs +++ b/lib/src/container/deploy.rs @@ -42,6 +42,9 @@ pub struct DeployOpts<'a> { /// to a different container image, the fetch process will reuse shared layers, but /// it will not be necessary to remove the previous image. pub no_imgref: bool, + + /// Do not cleanup deployments + pub no_clean: bool, } /// Write a container image to an OSTree deployment. @@ -106,7 +109,11 @@ pub async fn deploy( Some(&opts), cancellable, )?; - let flags = ostree::SysrootSimpleWriteDeploymentFlags::NONE; + let flags = if options.no_clean { + ostree::SysrootSimpleWriteDeploymentFlags::NO_CLEAN + } else { + ostree::SysrootSimpleWriteDeploymentFlags::NONE + }; sysroot.simple_write_deployment( Some(stateroot), deployment, @@ -114,7 +121,9 @@ pub async fn deploy( flags, cancellable, )?; - sysroot.cleanup(cancellable)?; + if !options.no_clean { + sysroot.cleanup(cancellable)?; + } } Ok(state)