1
0
forked from brl/citadel-tools

Use $PATH lookup for xz and sha256sum when building image

This commit is contained in:
Bruce Leidl 2019-01-05 20:40:07 -05:00
parent c580d784ff
commit c992b32946

View File

@ -4,7 +4,7 @@ use std::fs::{self,File};
use std::io::{self,Write}; use std::io::{self,Write};
use failure::ResultExt; use failure::ResultExt;
use libcitadel::{Result,ImageHeader,util,verity}; use libcitadel::{Result,ImageHeader,verity,util,devkeys};
use BuildConfig; use BuildConfig;
@ -85,7 +85,10 @@ impl UpdateBuilder {
} }
fn calculate_shasum(&mut self) -> Result<()> { fn calculate_shasum(&mut self) -> Result<()> {
let shasum = util::sha256(&self.target)?; let output = util::exec_cmdline_with_output("sha256sum", format!("{}", self.target.display()))
.context(format!("failed to calculate sha256 on {}", self.target.display()))?;
let v: Vec<&str> = output.split_whitespace().collect();
let shasum = v[0].trim().to_owned();
info!("Sha256 of image data is {}", shasum); info!("Sha256 of image data is {}", shasum);
self.shasum = Some(shasum); self.shasum = Some(shasum);
Ok(()) Ok(())
@ -97,7 +100,6 @@ impl UpdateBuilder {
let verity = verity::generate_initial_hashtree(&self.target, &hashfile)?; let verity = verity::generate_initial_hashtree(&self.target, &hashfile)?;
fs::write(outfile, verity.output()) fs::write(outfile, verity.output())
.context("failed to write veritysetup command output to a file")?; .context("failed to write veritysetup command output to a file")?;
@ -122,7 +124,9 @@ impl UpdateBuilder {
fn compress_image(&self) -> Result<()> { fn compress_image(&self) -> Result<()> {
info!("Compressing image data"); info!("Compressing image data");
util::xz_compress(&self.target) util::exec_cmdline("xz", format!("-T0 {}", self.target.display()))
.context(format!("failed to decompress {}", self.target.display()))?;
Ok(())
} }
fn write_final_image(&self) -> Result<()> { fn write_final_image(&self) -> Result<()> {