From e8e4687c050f1fa783af783eac172e77ad3e752b Mon Sep 17 00:00:00 2001 From: Jeremy Soller <jeremy@system76.com> Date: Mon, 5 Sep 2022 09:10:46 -0600 Subject: [PATCH] Pass live argument from CLI to library --- src/bin/installer.rs | 7 ++++--- src/lib.rs | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/bin/installer.rs b/src/bin/installer.rs index bb15476..8da1b04 100644 --- a/src/bin/installer.rs +++ b/src/bin/installer.rs @@ -14,10 +14,11 @@ fn main() { let stderr = io::stderr(); let mut stderr = stderr.lock(); - let mut parser = ArgParser::new(3) + let mut parser = ArgParser::new(4) .add_opt("b", "cookbook") .add_opt("c", "config") - .add_flag(&["l", "list-packages"]); + .add_flag(&["l", "list-packages"]) + .add_flag(&["live"]); parser.parse(env::args()); let config = if let Some(path) = parser.get_opt("config") { @@ -68,7 +69,7 @@ fn main() { } } else { if let Some(path) = parser.args.get(0) { - if let Err(err) = redox_installer::install(config, path, cookbook) { + if let Err(err) = redox_installer::install(config, path, cookbook, parser.found("live")) { writeln!(stderr, "installer: failed to install: {}", err).unwrap(); process::exit(1); } diff --git a/src/lib.rs b/src/lib.rs index 29e8ad6..29cb806 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -525,7 +525,7 @@ pub fn with_whole_disk<P, F, T>(disk_path: P, bootloader_bios: &[u8], bootloader ) } -pub fn install<P, S>(config: Config, output: P, cookbook: Option<S>) +pub fn install<P, S>(config: Config, output: P, cookbook: Option<S>, live: bool) -> Result<()> where P: AsRef<Path>, S: AsRef<str>, @@ -535,7 +535,7 @@ pub fn install<P, S>(config: Config, output: P, cookbook: Option<S>) if output.as_ref().is_dir() { install_dir(config, output, cookbook) } else { - let (bootloader_bios, bootloader_efi) = fetch_bootloaders(cookbook.as_ref(), false)?; + let (bootloader_bios, bootloader_efi) = fetch_bootloaders(cookbook.as_ref(), live)?; with_whole_disk(output, &bootloader_bios, &bootloader_efi, None, move |mount_path| { install_dir(config, mount_path, cookbook) -- GitLab