Merge branch 'write_bootloader' into 'master'

Add flag to write bootloader to chosen location

See merge request redox-os/installer!46
This commit is contained in:
Jeremy Soller
2025-06-12 10:52:00 -06:00
3 changed files with 31 additions and 7 deletions
+8 -3
View File
@@ -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);
}
+11 -2
View File
@@ -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() {
+12 -2
View File
@@ -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<Path>,
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)
}