Skip to content

Commit e15b3d0

Browse files
committed
install: check mounted ESP firstly for efi
When building a live image without a device (e.g., metal4k), a mounted directory will be used to continue the process. See coreos/coreos-assembler#4161
1 parent 766bb80 commit e15b3d0

1 file changed

Lines changed: 12 additions & 7 deletions

File tree

src/efi.rs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -345,14 +345,19 @@ impl Component for Efi {
345345
let srcdir_name = component_updatedirname(self);
346346
let ft = crate::filetree::FileTree::new_from_dir(&src_root.sub_dir(&srcdir_name)?)?;
347347

348-
// Using `blockdev` to find the partition instead of partlabel because
349-
// we know the target install toplevel device already.
350-
let esp_device = blockdev::get_esp_partition(device)?
351-
.ok_or_else(|| anyhow::anyhow!("Failed to find ESP device"))?;
352-
353-
let destpath = &self.ensure_mounted_esp(Path::new(dest_root), Path::new(&esp_device))?;
348+
// When building live image without device, eg. metal4k
349+
// will use mounted point to continue the process
350+
let destpath = if let Some(destdir) = self.get_mounted_esp(Path::new(dest_root))? {
351+
destdir
352+
} else {
353+
// Using `blockdev` to find the partition instead of partlabel because
354+
// we know the target install toplevel device already.
355+
let esp_device = blockdev::get_esp_partition(device)?
356+
.ok_or_else(|| anyhow::anyhow!("Failed to find ESP device"))?;
357+
self.mount_esp_device(Path::new(dest_root), Path::new(&esp_device))?
358+
};
354359

355-
let destd = &openat::Dir::open(destpath)
360+
let destd = &openat::Dir::open(&destpath)
356361
.with_context(|| format!("opening dest dir {}", destpath.display()))?;
357362
validate_esp_fstype(destd)?;
358363

0 commit comments

Comments
 (0)