Skip to content

Commit

Permalink
bios.rs: detect when payload is missing grub2-modules
Browse files Browse the repository at this point in the history
Fixes #787
  • Loading branch information
HuijingHei committed Dec 4, 2024
1 parent 822640c commit 12f9ae7
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/bios.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,27 @@ impl Bios {
Ok(device)
}

// Return `true` if grub2-modules installed
fn check_grub_modules(&self) -> Result<bool> {
let usr_path = Path::new("/usr/lib/grub");
#[cfg(target_arch = "x86_64")]
{
usr_path.join("i386-pc").try_exists().map_err(Into::into)
}
#[cfg(target_arch = "powerpc64")]
{
usr_path
.join("powerpc-ieee1275")
.try_exists()
.map_err(Into::into)
}
}

// Run grub2-install
fn run_grub_install(&self, dest_root: &str, device: &str) -> Result<()> {
if !self.check_grub_modules()? {
bail!("Failed to find grub2-modules");
}
let grub_install = Path::new("/").join(GRUB_BIN);
if !grub_install.exists() {
bail!("Failed to find {:?}", grub_install);
Expand Down

0 comments on commit 12f9ae7

Please sign in to comment.