Skip to content

Commit

Permalink
utils: Add a lifecycle_bind helper for Command
Browse files Browse the repository at this point in the history
Followup to the previous code where we'd end up forking a copy
of our own binary in the deploy path, but also preparation for
more similar code.

Signed-off-by: Colin Walters <[email protected]>
  • Loading branch information
cgwalters committed Dec 6, 2024
1 parent ea4a62e commit 62e186d
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion lib/src/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -840,7 +840,8 @@ async fn install_container(
/// Run a command in the host mount namespace
pub(crate) fn run_in_host_mountns(cmd: &str) -> Command {
let mut c = Command::new("/proc/self/exe");
c.args(["exec-in-host-mount-namespace", cmd]);
c.lifecycle_bind()
.args(["exec-in-host-mount-namespace", cmd]);
c
}

Expand Down
2 changes: 2 additions & 0 deletions lib/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use std::process::Command;
use std::time::Duration;

use anyhow::{Context, Result};
use bootc_utils::CommandRunExt;
#[cfg(feature = "install")]
use camino::Utf8Path;
use cap_std_ext::cap_std::fs::Dir;
Expand Down Expand Up @@ -119,6 +120,7 @@ pub(crate) fn spawn_editor(tmpf: &tempfile::NamedTempFile) -> Result<()> {
let status = Command::new(argv0)
.args(editor_args)
.arg(tmpf.path())
.lifecycle_bind()
.status()
.context("Spawning editor")?;
if !status.success() {
Expand Down
1 change: 1 addition & 0 deletions ostree-ext/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ ostree = { features = ["v2022_6"], version = "0.19.0" }

# Private dependencies
anyhow = { workspace = true }
bootc-utils = { path = "../utils" }
camino = { workspace = true, features = ["serde1"] }
chrono = { workspace = true }
olpc-cjson = "0.1.1"
Expand Down
2 changes: 2 additions & 0 deletions ostree-ext/src/container/deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use std::os::fd::BorrowedFd;
use std::process::Command;

use anyhow::Result;
use bootc_utils::CommandRunExt;
use cap_std_ext::cmdext::CapStdExtCommandExt;
use fn_error_context::context;
use ocidir::cap_std::fs::Dir;
Expand Down Expand Up @@ -148,6 +149,7 @@ pub async fn deploy(
let st = Command::new("/proc/self/exe")
.args(["internals", "bootc-install-completion", ".", stateroot])
.cwd_dir(sysroot_dir.try_clone()?)
.lifecycle_bind()
.status()?;
if !st.success() {
anyhow::bail!("Failed to complete bootc install");
Expand Down

0 comments on commit 62e186d

Please sign in to comment.