From 8fa019bfa821303cfb7a7f069ae2320f4c3800fa Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Sat, 30 Sep 2023 15:39:21 -0400 Subject: [PATCH] deploy: Add a no_clean option Looking at doing a bootc reinstall, we need the ability to retain existing deployments for this. --- lib/src/container/deploy.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) 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)