diff --git a/lib/src/cli.rs b/lib/src/cli.rs index 8f19c7c6..50b4d71a 100644 --- a/lib/src/cli.rs +++ b/lib/src/cli.rs @@ -19,6 +19,7 @@ use ostree_container::store::PrepareResult; use ostree_ext::container as ostree_container; use ostree_ext::keyfileext::KeyFileExt; use ostree_ext::ostree; +use ostree_ext::ostree::Sysroot; use schemars::schema_for; use crate::deploy::RequiredHostSpec; @@ -927,7 +928,25 @@ async fn run_from_opt(opt: Opt) -> Result<()> { Opt::Man(manopts) => crate::docgen::generate_manpages(&manopts.directory), Opt::State(opts) => match opts { StateOpts::WipeOstree => { - let sysroot = get_storage().await?; + // let sysroot = match get_storage().await { + // Ok(storage) => { + // let storage: &Sysroot = &storage; + // storage + // } + // Err(_) => { + // // If we can't get the storage, we're likely in a container + // // or some other non-bootc environment. Just wipe the ostree + // // system root. + // let sysroot = ostree::Sysroot::new_default(); + // sysroot.set_mount_namespace_in_use(); + // &sysroot + // } + // }; + // + let sysroot = ostree::Sysroot::new_default(); + sysroot.set_mount_namespace_in_use(); + + sysroot.load(gio::Cancellable::NONE)?; crate::deploy::wipe_ostree(&sysroot).await } }, diff --git a/lib/src/deploy.rs b/lib/src/deploy.rs index 23a0b53d..67a5794e 100644 --- a/lib/src/deploy.rs +++ b/lib/src/deploy.rs @@ -16,8 +16,8 @@ use ostree_container::OstreeImageReference; use ostree_ext::container as ostree_container; use ostree_ext::container::store::{ImportProgress, PrepareResult}; use ostree_ext::oci_spec::image::Descriptor; -use ostree_ext::ostree; use ostree_ext::ostree::Deployment; +use ostree_ext::ostree::{self, Sysroot}; use ostree_ext::sysroot::SysrootLock; use crate::spec::ImageReference; @@ -288,7 +288,7 @@ pub(crate) async fn prune_container_store(sysroot: &Storage) -> Result<()> { Ok(()) } -pub(crate) async fn wipe_ostree(sysroot: &Storage) -> Result<()> { +pub(crate) async fn wipe_ostree(sysroot: &Sysroot) -> Result<()> { sysroot .write_deployments(&[], gio::Cancellable::NONE) .context("removing deployments")?;