diff --git a/lib/src/mount.rs b/lib/src/mount.rs index f91bf31bd..4acb90b11 100644 --- a/lib/src/mount.rs +++ b/lib/src/mount.rs @@ -1,11 +1,13 @@ //! Helpers for interacting with mountpoints -use anyhow::{anyhow, Context, Result}; +use std::process::Command; + +use anyhow::{anyhow, Result}; use camino::Utf8Path; use fn_error_context::context; use serde::Deserialize; -use crate::task::Task; +use crate::{cmdutils::CommandRunExt, task::Task}; #[derive(Deserialize, Debug)] #[serde(rename_all = "kebab-case")] @@ -26,8 +28,7 @@ pub(crate) struct Findmnt { } fn run_findmnt(args: &[&str], path: &str) -> Result { - let desc = format!("Inspecting {path}"); - let o = Task::new(desc, "findmnt") + let o: Findmnt = Command::new("findmnt") .args([ "-J", "-v", @@ -36,9 +37,7 @@ fn run_findmnt(args: &[&str], path: &str) -> Result { ]) .args(args) .arg(path) - .quiet() - .read()?; - let o: Findmnt = serde_json::from_str(&o).context("Parsing findmnt output")?; + .run_and_parse_json()?; o.filesystems .into_iter() .next() diff --git a/lib/src/podman.rs b/lib/src/podman.rs index 4e2d40445..d10457e95 100644 --- a/lib/src/podman.rs +++ b/lib/src/podman.rs @@ -3,8 +3,6 @@ use camino::Utf8Path; use cap_std_ext::cap_std::fs::Dir; use serde::Deserialize; -use crate::task::Task; - /// Where we look inside our container to find our own image /// for use with `bootc install`. pub(crate) const CONTAINER_STORAGE: &str = "/var/lib/containers"; @@ -26,12 +24,10 @@ pub(crate) struct ImageListEntry { /// Given an image ID, return its manifest digest #[cfg(feature = "install")] pub(crate) fn imageid_to_digest(imgid: &str) -> Result { - use crate::install::run_in_host_mountns; - let out = Task::new_cmd("podman inspect", run_in_host_mountns("podman")) + use crate::cmdutils::CommandRunExt; + let o: Vec = crate::install::run_in_host_mountns("podman") .args(["inspect", imgid]) - .quiet() - .read()?; - let o: Vec = serde_json::from_str(&out)?; + .run_and_parse_json()?; let i = o .into_iter() .next()