diff --git a/src/bin/installer.rs b/src/bin/installer.rs index 0b6190e5fd..49edfc40bc 100644 --- a/src/bin/installer.rs +++ b/src/bin/installer.rs @@ -19,6 +19,7 @@ fn main() { .add_opt("b", "cookbook") .add_opt("c", "config") .add_opt("o", "output-config") + .add_opt("", "write-bootloader") .add_flag(&["filesystem-size"]) .add_flag(&["r", "repo-binary"]) .add_flag(&["l", "list-packages"]) @@ -143,9 +144,13 @@ fn main() { }; if let Some(path) = parser.args.get(0) { - if let Err(err) = - redox_installer::install(config, path, cookbook.as_deref(), parser.found("live")) - { + if let Err(err) = redox_installer::install( + config, + path, + cookbook.as_deref(), + parser.found("live"), + parser.get_opt("write-bootloader").as_deref(), + ) { writeln!(stderr, "installer: failed to install: {}", err).unwrap(); process::exit(1); } diff --git a/src/bin/installer_tui.rs b/src/bin/installer_tui.rs index ebe304b191..554b644973 100644 --- a/src/bin/installer_tui.rs +++ b/src/bin/installer_tui.rs @@ -59,7 +59,11 @@ fn disk_paths(paths: &mut Vec<(PathBuf, u64)>) { } } Err(err) => { - eprintln!("installer_tui: failed to list '{}': {}", scheme.display(), err); + eprintln!( + "installer_tui: failed to list '{}': {}", + scheme.display(), + err + ); } } } @@ -208,7 +212,12 @@ fn choose_disk() -> PathBuf { disk_paths(&mut paths); loop { for (i, (path, size)) in paths.iter().enumerate() { - eprintln!("\x1B[1m{}\x1B[0m: {}: {}", i + 1, path.display(), format_size(*size)); + eprintln!( + "\x1B[1m{}\x1B[0m: {}: {}", + i + 1, + path.display(), + format_size(*size) + ); } if paths.is_empty() { diff --git a/src/lib.rs b/src/lib.rs index 0145225d6b..362867dac0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -712,13 +712,22 @@ where with_redoxfs(disk_redoxfs, disk_option.password_opt, callback) } -fn install_inner(config: Config, output: &Path, cookbook: Option<&str>, live: bool) -> Result<()> { +fn install_inner( + config: Config, + output: &Path, + cookbook: Option<&str>, + live: bool, + write_bootloader: Option<&str>, +) -> Result<()> { println!("Install {config:#?} to {}", output.display()); if output.is_dir() { install_dir(config, output, cookbook) } else { let (bootloader_bios, bootloader_efi) = fetch_bootloaders(&config, cookbook, live)?; + if let Some(write_bootloader) = write_bootloader { + std::fs::write(write_bootloader, &bootloader_efi).unwrap(); + } let disk_option = DiskOption { bootloader_bios: &bootloader_bios, bootloader_efi: &bootloader_efi, @@ -736,6 +745,7 @@ pub fn install( output: impl AsRef, cookbook: Option<&str>, live: bool, + write_bootloader: Option<&str>, ) -> Result<()> { - install_inner(config, output.as_ref(), cookbook, live) + install_inner(config, output.as_ref(), cookbook, live, write_bootloader) }