diff --git a/src/efi.rs b/src/efi.rs index 6cd077a52..a8b7d5286 100644 --- a/src/efi.rs +++ b/src/efi.rs @@ -25,6 +25,10 @@ pub(crate) const ESP_MOUNTS: &[&str] = &["boot/efi", "efi", "boot"]; /// The binary to change EFI boot ordering const EFIBOOTMGR: &str = "efibootmgr"; +#[cfg(target_arch = "aarch64")] +pub(crate) const SHIM: &str = "shimaa64.efi"; + +#[cfg(target_arch = "x86_64")] pub(crate) const SHIM: &str = "shimx64.efi"; /// The ESP partition label on Fedora CoreOS derivatives @@ -484,7 +488,7 @@ pub(crate) fn set_efi_current(device: &str, espdir: &openat::Dir, vendordir: &st if espdir.exists(&shim)? { anyhow::bail!("Failed to find {SHIM}"); } - let loader = format!("\\EFI\\{}\\shimx64.efi", vendordir); + let loader = format!("\\EFI\\{}\\{SHIM}", vendordir); let st = Command::new(EFIBOOTMGR) .args([ "--create", diff --git a/src/grubconfigs.rs b/src/grubconfigs.rs index 38c65501a..1ba9832be 100644 --- a/src/grubconfigs.rs +++ b/src/grubconfigs.rs @@ -5,6 +5,8 @@ use anyhow::{anyhow, Context, Result}; use fn_error_context::context; use openat_ext::OpenatDirExt; +use crate::efi::SHIM; + /// The subdirectory of /boot we use const GRUB2DIR: &str = "grub2"; const CONFIGDIR: &str = "/usr/lib/bootupd/grub2-static"; @@ -22,13 +24,13 @@ pub(crate) fn find_efi_vendordir(efidir: &openat::Dir) -> Result { let dir = efidir.sub_dir(d.file_name())?; for entry in dir.list_dir(".")? { let entry = entry?; - if entry.file_name() != super::efi::SHIM { + if entry.file_name() != SHIM { continue; } return Ok(d.file_name().into()); } } - anyhow::bail!("Failed to find EFI vendor dir") + anyhow::bail!("Failed to find EFI vendor dir that contains {SHIM}") } /// Install the static GRUB config files. @@ -159,15 +161,15 @@ mod tests { std::fs::write(efidir.join("dell").join("foo"), "foo data")?; std::fs::write(efidir.join("fedora").join("grub.cfg"), "grub config")?; - std::fs::write(efidir.join("fedora").join("shimx64.efi"), "shim data")?; + std::fs::write(efidir.join("fedora").join(SHIM), "shim data")?; assert!(td.exists("BOOT")?); assert!(td.exists("dell/foo")?); assert!(td.exists("fedora/grub.cfg")?); - assert!(td.exists("fedora/shimx64.efi")?); + assert!(td.exists(format!("fedora/{SHIM}"))?); assert_eq!(find_efi_vendordir(&td)?.to_str(), Some("fedora")); - std::fs::remove_file(efidir.join("fedora").join("shimx64.efi"))?; + std::fs::remove_file(efidir.join("fedora").join(SHIM))?; let x = find_efi_vendordir(&td); assert_eq!(x.is_err(), true); Ok(())