Skip to content

Commit 47aad72

Browse files
authored
Merge pull request #1459 from cgwalters/command-run-cleanups
command: Split up run() method
2 parents cff9730 + 634e038 commit 47aad72

File tree

12 files changed

+147
-35
lines changed

12 files changed

+147
-35
lines changed

crates/blockdev/src/blockdev.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,9 @@ impl LoopbackDevice {
322322
let _ = cleanup_handle.child.kill();
323323
}
324324

325-
Command::new("losetup").args(["-d", dev.as_str()]).run()
325+
Command::new("losetup")
326+
.args(["-d", dev.as_str()])
327+
.run_capture_stderr()
326328
}
327329

328330
/// Consume this device, unmounting it.

crates/lib/src/image.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,5 +178,5 @@ pub(crate) async fn imgcmd_entrypoint(
178178
let mut cmd = storage.new_image_cmd()?;
179179
cmd.arg(arg);
180180
cmd.args(args);
181-
cmd.run()
181+
cmd.run_capture_stderr()
182182
}

crates/lib/src/imgstorage.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ pub(crate) fn ensure_floating_c_storage_initialized() {
138138
if let Err(e) = Command::new("podman")
139139
.args(["system", "info"])
140140
.stdout(Stdio::null())
141-
.run()
141+
.run_capture_stderr()
142142
{
143143
// Out of conservatism we don't make this operation fatal right now.
144144
// If something went wrong, then we'll probably fail on a later operation
@@ -220,7 +220,7 @@ impl Storage {
220220
new_podman_cmd_in(&storage_root, &run)?
221221
.stdout(Stdio::null())
222222
.arg("images")
223-
.run()
223+
.run_capture_stderr()
224224
.context("Initializing images")?;
225225
Self::ensure_labeled(&storage_root, sepolicy)?;
226226
drop(storage_root);
@@ -273,7 +273,7 @@ impl Storage {
273273
AsyncCommand::from(cmd)
274274
.status()
275275
.await?
276-
.check_status(stderr)?;
276+
.check_status_with_stderr(stderr)?;
277277
// Spawn a helper thread to avoid blocking the main thread
278278
// parsing JSON.
279279
tokio::task::spawn_blocking(move || -> Result<_> {

crates/lib/src/install.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,7 @@ async fn initialize_ostree_root(
670670
Command::new("ostree")
671671
.args(["config", "--repo", "ostree/repo", "set", k, v])
672672
.cwd_dir(rootfs_dir.try_clone()?)
673-
.run()?;
673+
.run_capture_stderr()?;
674674
}
675675

676676
let sysroot = {

crates/lib/src/install/completion.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ fn bind_from_host(
152152
.args(["-m", "-t", "1", "--", "mount", "--bind"])
153153
.arg(src)
154154
.arg(&target)
155-
.run()?;
155+
.run_capture_stderr()?;
156156
Ok(())
157157
}
158158

crates/lib/src/install/osbuild.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ fn adjust_etc_containers(tempdir: &Dir) -> Result<()> {
3636
.args(["-t", "overlay", "overlay", "-o", opts.as_str()])
3737
.arg(etc_containers)
3838
.cwd_dir(tempdir.try_clone()?)
39-
.run()?;
39+
.run_capture_stderr()?;
4040
Ok(())
4141
}
4242

@@ -59,7 +59,7 @@ fn propagate_run_osbuild_containers(root: &Dir) -> Result<()> {
5959
.arg("--rbind")
6060
.args([osbuild_run_containers, relative_storage])
6161
.cwd_dir(root.try_clone()?)
62-
.run()?;
62+
.run_capture_stderr()?;
6363
Ok(())
6464
}
6565

crates/lib/src/utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ pub(crate) fn spawn_editor(tmpf: &tempfile::NamedTempFile) -> Result<()> {
119119
.args(editor_args)
120120
.arg(tmpf.path())
121121
.lifecycle_bind()
122-
.run()
122+
.run_inherited()
123123
.with_context(|| format!("Invoking editor {editor} failed"))
124124
}
125125

crates/mount/src/mount.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ pub fn is_source_mounted(path: &str, mounted_fs: &Filesystem) -> bool {
117117
pub fn mount(dev: &str, target: &Utf8Path) -> Result<()> {
118118
Command::new("mount")
119119
.args([dev, target.as_str()])
120-
.run_with_cmd_context()
120+
.run_inherited_with_cmd_context()
121121
}
122122

123123
/// If the fsid of the passed path matches the fsid of the same path rooted

crates/ostree-ext/src/fixture.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -769,7 +769,7 @@ impl Fixture {
769769
let _ = Command::new("ostree")
770770
.arg(format!("--repo={}", self.path.join("src/repo")))
771771
.args(["ls", "-X", "-C", "-R", commit.as_str()])
772-
.run();
772+
.run_capture_stderr();
773773
});
774774
}
775775
assert_eq!(CONTENTS_CHECKSUM_V0, content_checksum.as_str());

crates/system-reinstall-bootc/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,12 @@ fn run() -> Result<()> {
5555
prompt::temporary_developer_protection_prompt()?;
5656

5757
reinstall_podman_command
58-
.run_with_cmd_context()
58+
.run_inherited_with_cmd_context()
5959
.context("running reinstall command")?;
6060

6161
prompt::reboot()?;
6262

63-
std::process::Command::new("reboot").run()?;
63+
std::process::Command::new("reboot").run_capture_stderr()?;
6464

6565
Ok(())
6666
}

0 commit comments

Comments
 (0)