Returns the path to the first UKI found in the container root, if any. Looks in `/boot/EFI/Linux/*.efi`. If multiple UKIs are present, returns the first one in sorted order for determinism.
(root: &Dir)
| 137 | /// Looks in `/boot/EFI/Linux/*.efi`. If multiple UKIs are present, returns |
| 138 | /// the first one in sorted order for determinism. |
| 139 | fn find_uki_path(root: &Dir) -> Result<Option<Utf8PathBuf>> { |
| 140 | let Some(boot) = root.open_dir_optional(crate::install::BOOT)? else { |
| 141 | return Ok(None); |
| 142 | }; |
| 143 | let Some(efi_linux) = boot.open_dir_optional(EFI_LINUX)? else { |
| 144 | return Ok(None); |
| 145 | }; |
| 146 | |
| 147 | let mut uki_files = Vec::new(); |
| 148 | for entry in efi_linux.entries()? { |
| 149 | let entry = entry?; |
| 150 | let name = entry.file_name(); |
| 151 | let name_path = Path::new(&name); |
| 152 | let extension = name_path.extension().and_then(|v| v.to_str()); |
| 153 | if extension == Some("efi") { |
| 154 | if let Some(name_str) = name.to_str() { |
| 155 | uki_files.push(name_str.to_owned()); |
| 156 | } |
| 157 | } |
| 158 | } |
| 159 | |
| 160 | // Sort for deterministic behavior when multiple UKIs are present |
| 161 | uki_files.sort(); |
| 162 | Ok(uki_files |
| 163 | .into_iter() |
| 164 | .next() |
| 165 | .map(|filename| Utf8PathBuf::from(format!("boot/{EFI_LINUX}/{filename}")))) |
| 166 | } |
| 167 | |
| 168 | #[cfg(test)] |
| 169 | mod tests { |