Skip to content

Commit

Permalink
Merge pull request containers#571 from cgwalters/no-bootcurrent-no-pr…
Browse files Browse the repository at this point in the history
…oblem

efi: Gracefully no-op if there's no `BootCurrent`
  • Loading branch information
cgwalters authored Nov 21, 2023
2 parents 6b780ab + dab28bc commit 60a45ee
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/efi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -443,12 +443,17 @@ pub(crate) fn clear_efi_current() -> Result<()> {
anyhow::bail!("Failed to invoke {EFIBOOTMGR}")
}
let output = String::from_utf8(output.stdout)?;
let current = output
let current = if let Some(current) = output
.lines()
.filter_map(|l| l.split_once(':'))
.filter_map(|(k, v)| (k == BOOTCURRENT).then_some(v.trim()))
.next()
.ok_or_else(|| anyhow::anyhow!("Failed to find BootCurrent"))?;
{
current
} else {
log::debug!("No EFI {BOOTCURRENT} found");
return Ok(());
};
let output = Command::new(EFIBOOTMGR)
.args(["-b", current, "-B"])
.output()?;
Expand Down

0 comments on commit 60a45ee

Please sign in to comment.