Skip to content

Commit

Permalink
lichen_cli: Verify that partitions are usable, and we have ESP+Xbootl…
Browse files Browse the repository at this point in the history
…dr pairing

Signed-off-by: Ikey Doherty <[email protected]>
  • Loading branch information
ikeycode committed Jun 19, 2024
1 parent 19ad731 commit f786632
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions lichen_cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use std::fmt::Display;

use color_eyre::{eyre::eyre, Section};
use console::{set_colors_enabled, style};
use dialoguer::theme::ColorfulTheme;
use system::{
Expand Down Expand Up @@ -117,6 +118,26 @@ fn load_partitions() -> color_eyre::Result<Vec<InstallationPartiton>> {
partitions.extend(regulars.map(|p| InstallationPartiton::Normal(p.clone())))
}
}

if partitions.is_empty() {
return Err(eyre!("Cannot find any usable partitions")
.suggestion("The installer requires that disks are readable and using a GUID Partition Table"));
}

// ensure we have an ESP..
let esp = partitions
.iter()
.find(|p| matches!(p, InstallationPartiton::Boot { esp: _, xbootldr: _ }));
if let Some(InstallationPartiton::Boot { esp, xbootldr }) = esp {
if xbootldr.is_none() {
eprintln!("Warning: No XBOOTLDR available for ESP: {}", esp.path.display());
}
} else {
return Err(eyre!("No usable EFI System Partition").suggestion(
"The installer requires that an ESP is present, and will also use an XBOOTLDR partition if present",
));
}

Ok(partitions)
}

Expand Down

0 comments on commit f786632

Please sign in to comment.