Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aa64: Minor fix for efi vendordir #634

Merged
merged 1 commit into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/efi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Copy link
Member Author

@HuijingHei HuijingHei Mar 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cgwalters update this to sync with SHIM, or might have issue on aarch64 as it does not have shimx64.efi when called by --update-firmware?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this looks right. I suspect the only reason it may have appeared to work on aarch64 is because we ended up using the fallback path.

let st = Command::new(EFIBOOTMGR)
.args([
"--create",
Expand Down
12 changes: 7 additions & 5 deletions src/grubconfigs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -22,13 +24,13 @@ pub(crate) fn find_efi_vendordir(efidir: &openat::Dir) -> Result<PathBuf> {
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.
Expand Down Expand Up @@ -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(())
Expand Down
Loading