Skip to content

Commit da80a87

Browse files
committed
efi: update adopt_update() to support on all esps
1 parent 2caa73b commit da80a87

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

src/efi.rs

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -289,16 +289,32 @@ impl Component for Efi {
289289
anyhow::bail!("Failed to find adoptable system")
290290
};
291291

292-
let esp = self.open_esp()?;
293-
validate_esp_fstype(&esp)?;
294292
let updated = sysroot
295293
.sub_dir(&component_updatedirname(self))
296294
.context("opening update dir")?;
297295
let updatef = filetree::FileTree::new_from_dir(&updated).context("reading update dir")?;
298-
// For adoption, we should only touch files that we know about.
299-
let diff = updatef.relative_diff_to(&esp)?;
300-
log::trace!("applying adoption diff: {}", &diff);
301-
filetree::apply_diff(&updated, &esp, &diff, None).context("applying filesystem changes")?;
296+
let esp_devices = self
297+
.get_all_esp_devices()
298+
.expect("get esp devices before adopt");
299+
let sysroot = sysroot.recover_path()?;
300+
301+
for esp_dev in esp_devices {
302+
let dest_path = if let Some(dest_path) = self.get_mounted_esp(&sysroot)? {
303+
dest_path.join("EFI")
304+
} else {
305+
self.ensure_mounted_esp(&sysroot, &esp_dev)?.join("EFI")
306+
};
307+
308+
let esp = openat::Dir::open(&dest_path).context("opening EFI dir")?;
309+
validate_esp_fstype(&esp)?;
310+
311+
// For adoption, we should only touch files that we know about.
312+
let diff = updatef.relative_diff_to(&esp)?;
313+
log::trace!("applying adoption diff: {}", &diff);
314+
filetree::apply_diff(&updated, &esp, &diff, None)
315+
.context("applying filesystem changes")?;
316+
self.unmount().context("unmount after adopt")?;
317+
}
302318
Ok(InstalledContent {
303319
meta: updatemeta.clone(),
304320
filetree: Some(updatef),

0 commit comments

Comments
 (0)