diff --git a/bootpkg/src/main.rs b/bootpkg/src/main.rs index 6bc16a8..ffd4338 100644 --- a/bootpkg/src/main.rs +++ b/bootpkg/src/main.rs @@ -65,13 +65,13 @@ fn main() { let mut tmp_dir = temp_dir(); tmp_dir.push(format!("{}", Uuid::new_v4())); - create_dir_all(&tmp_dir) - .expect("Could not create tmp dir."); + create_dir_all(&tmp_dir).expect("Could not create tmp dir."); println!("** extracting pkgtar..."); { let mut archive = tar::Archive::new(Cursor::new(pkg.data)); - archive.unpack(format!("{}/contents", &tmp_dir.to_str().unwrap())) + archive + .unpack(format!("{}/contents", &tmp_dir.to_str().unwrap())) .expect("Could not extract archive"); } @@ -81,9 +81,16 @@ fn main() { println!("** running bootstrap commands..."); let res_bootstrap = run_bootstrap(mani); println!("** removing temporary directory..."); - remove_dir_all(&tmp_dir) - .expect(&*format!("Could not remove tmp dir: {}", &tmp_dir.to_str().unwrap())); - exit(if res_bootstrap { println!("!! bootstrap success"); 0 } else { 1 }) + remove_dir_all(&tmp_dir).expect(&*format!( + "Could not remove tmp dir: {}", + &tmp_dir.to_str().unwrap() + )); + exit(if res_bootstrap { + println!("!! bootstrap success"); + 0 + } else { + 1 + }) } _ => { println!("Unsupported command, allowed commands: strap."); diff --git a/bootpkg/src/prelude.rs b/bootpkg/src/prelude.rs index aff3164..b82b62a 100644 --- a/bootpkg/src/prelude.rs +++ b/bootpkg/src/prelude.rs @@ -13,7 +13,7 @@ pub struct PKGR { #[derive(Serialize, Deserialize)] pub struct Bootstrap { pub check_installed_commands: Vec, - pub commands: Vec + pub commands: Vec, } #[derive(Serialize, Deserialize)] @@ -30,7 +30,7 @@ pub fn mani_from_str(s: &str) -> Manifest> { fs: mani.fs, bin: mani.bin, build: mani.build, - pkgr: bmani.pkgr + pkgr: bmani.pkgr, } } @@ -41,26 +41,29 @@ pub fn run_bootstrap(mani: Manifest>) -> bool { std::process::Command::new("sh") .arg("-c") .arg(s.into()) - .spawn().expect("Could not spawn process.") - .wait().expect("Could not wait for process.") - .code().expect("Could not fetch exit code.") + .spawn() + .expect("Could not spawn process.") + .wait() + .expect("Could not wait for process.") + .code() + .expect("Could not fetch exit code.") } for command in &bootstrap.check_installed_commands { if run_command(command) != 0 { println!("!! Command failed: {}", command); println!("!! Already installed."); - return false + return false; } } for command in &bootstrap.commands { if run_command(command) != 0 { println!("!! Command failed: {}", command); println!("!! Bootstrap failed!!!"); - return false + return false; } } } } - return true + return true; }