tool: improve command error messages
This commit is contained in:
parent
36adaf5a9e
commit
30ddfcd2ce
|
@ -71,7 +71,7 @@ fn wrap_in_pe(stub: &Path, sections: Vec<Section>, output: &Path) -> Result<()>
|
|||
let status = Command::new("objcopy")
|
||||
.args(&args)
|
||||
.status()
|
||||
.context("Failed to run objcopy command")?;
|
||||
.context("Failed to run objcopy. Most likely, the binary is not on PATH.")?;
|
||||
if !status.success() {
|
||||
return Err(anyhow::anyhow!(
|
||||
"Failed to wrap in pe with args `{:?}`",
|
||||
|
|
|
@ -29,7 +29,10 @@ impl KeyPair {
|
|||
to.as_os_str().to_owned(),
|
||||
];
|
||||
|
||||
let output = Command::new("sbsign").args(&args).output()?;
|
||||
let output = Command::new("sbsign")
|
||||
.args(&args)
|
||||
.output()
|
||||
.context("Failed to run sbsign. Most likely, the binary is not on PATH.")?;
|
||||
|
||||
if !output.status.success() {
|
||||
std::io::stderr()
|
||||
|
@ -50,10 +53,10 @@ impl KeyPair {
|
|||
path.as_os_str().to_owned(),
|
||||
];
|
||||
|
||||
let output = match Command::new("sbverify").args(&args).output() {
|
||||
Ok(output) => output,
|
||||
Err(_) => return false,
|
||||
};
|
||||
let output = Command::new("sbverify")
|
||||
.args(&args)
|
||||
.output()
|
||||
.expect("Failed to run sbverify. Most likely, the binary is not on PATH.");
|
||||
|
||||
if !output.status.success() {
|
||||
if std::io::stderr().write_all(&output.stderr).is_err() {
|
||||
|
|
|
@ -182,7 +182,8 @@ pub fn remove_signature(path: &Path) -> Result<()> {
|
|||
let output = Command::new("sbattach")
|
||||
.arg("--remove")
|
||||
.arg(path.as_os_str())
|
||||
.output()?;
|
||||
.output()
|
||||
.context("Failed to run sbattach. Most likely, the binary is not on PATH.")?;
|
||||
print!("{}", String::from_utf8(output.stdout)?);
|
||||
print!("{}", String::from_utf8(output.stderr)?);
|
||||
Ok(())
|
||||
|
@ -194,7 +195,8 @@ pub fn verify_signature(path: &Path) -> Result<bool> {
|
|||
.arg(path.as_os_str())
|
||||
.arg("--cert")
|
||||
.arg("tests/fixtures/uefi-keys/db.pem")
|
||||
.output()?;
|
||||
.output()
|
||||
.context("Failed to run sbverify. Most likely, the binary is not on PATH.")?;
|
||||
print!("{}", String::from_utf8(output.stdout)?);
|
||||
print!("{}", String::from_utf8(output.stderr)?);
|
||||
Ok(output.status.success())
|
||||
|
|
Loading…
Reference in New Issue