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