Skip to content

Commit 61aad1c

Browse files
committed
fix: lint issues
1 parent f57f247 commit 61aad1c

File tree

2 files changed

+43
-41
lines changed

2 files changed

+43
-41
lines changed

src/bootupd.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -692,9 +692,9 @@ pub(crate) fn copy_to_boot() -> Result<()> {
692692
}
693693

694694
for component in all_components.values() {
695-
component.package_mode_copy_to_boot().with_context(|| {
696-
format!("Failed to copy component {} to boot", component.name())
697-
})?;
695+
component
696+
.package_mode_copy_to_boot()
697+
.with_context(|| format!("Failed to copy component {} to boot", component.name()))?;
698698
}
699699

700700
Ok(())

src/efi.rs

Lines changed: 40 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,8 @@ impl Efi {
187187
/// Package mode copy: Simple copy from /usr/lib/efi to boot/ESP.
188188
fn package_mode_copy_to_boot_impl(&self) -> Result<()> {
189189
let sysroot = Path::new("/");
190-
let sysroot_path = Utf8Path::from_path(sysroot)
191-
.context("Sysroot path is not valid UTF-8")?;
190+
let sysroot_path =
191+
Utf8Path::from_path(sysroot).context("Sysroot path is not valid UTF-8")?;
192192

193193
// Find components in /usr/lib/efi
194194
let efi_comps = match get_efi_component_from_usr(sysroot_path, EFILIB)? {
@@ -199,53 +199,55 @@ impl Efi {
199199
}
200200
};
201201

202-
// Find the ESP
203-
let esp_path = match self.get_mounted_esp(sysroot)? {
204-
Some(path) => path,
205-
None => {
206-
let devices = blockdev::get_devices(sysroot)?;
207-
let esp_devices = blockdev::find_colocated_esps(&devices)?;
208-
let Some(esp_devices) = esp_devices else {
209-
anyhow::bail!("No ESP found");
210-
};
211-
let esp_device = esp_devices
212-
.first()
213-
.context("No ESP devices found")?;
214-
self.ensure_mounted_esp(sysroot, Path::new(esp_device))?
215-
}
202+
// Find all ESP devices
203+
let devices = blockdev::get_devices(sysroot)?;
204+
let Some(esp_devices) = blockdev::find_colocated_esps(&devices)? else {
205+
anyhow::bail!("No ESP found");
216206
};
217207

218-
let esp_dir = openat::Dir::open(&esp_path)
219-
.with_context(|| format!("Opening ESP at {}", esp_path.display()))?;
220-
validate_esp_fstype(&esp_dir)?;
221-
222-
let sysroot_dir = openat::Dir::open(sysroot)
223-
.context("Opening sysroot for reading")?;
208+
let sysroot_dir = openat::Dir::open(sysroot).context("Opening sysroot for reading")?;
224209

225-
// Copy each component
226-
for efi_comp in &efi_comps {
227-
log::info!(
228-
"Copying EFI component {} version {} to ESP",
229-
efi_comp.name,
230-
efi_comp.version
231-
);
232-
233-
let dest_str = esp_path.to_str().context("ESP path contains invalid UTF-8")?;
234-
filetree::copy_dir_with_args(&sysroot_dir, efi_comp.path.as_str(), dest_str, OPTIONS)
210+
// Copy to all ESPs
211+
for esp in esp_devices {
212+
let esp_path = self.ensure_mounted_esp(sysroot, Path::new(&esp))?;
213+
214+
let esp_dir = openat::Dir::open(&esp_path)
215+
.with_context(|| format!("Opening ESP at {}", esp_path.display()))?;
216+
validate_esp_fstype(&esp_dir)?;
217+
218+
// Copy each component
219+
for efi_comp in &efi_comps {
220+
log::info!(
221+
"Copying EFI component {} version {} to ESP at {}",
222+
efi_comp.name,
223+
efi_comp.version,
224+
esp_path.display()
225+
);
226+
227+
let dest_str = esp_path
228+
.to_str()
229+
.context("ESP path contains invalid UTF-8")?;
230+
filetree::copy_dir_with_args(
231+
&sysroot_dir,
232+
efi_comp.path.as_str(),
233+
dest_str,
234+
OPTIONS,
235+
)
235236
.with_context(|| {
236237
format!(
237238
"Failed to copy {} from {} to {}",
238239
efi_comp.name, efi_comp.path, dest_str
239240
)
240241
})?;
241-
}
242+
}
242243

243-
// Sync filesystem
244-
let efidir = openat::Dir::open(&esp_path.join("EFI"))
245-
.context("Opening EFI directory for sync")?;
246-
fsfreeze_thaw_cycle(efidir.open_file(".")?)?;
244+
// Sync filesystem
245+
let efidir = openat::Dir::open(&esp_path.join("EFI"))
246+
.context("Opening EFI directory for sync")?;
247+
fsfreeze_thaw_cycle(efidir.open_file(".")?)?;
248+
}
247249

248-
log::info!("Successfully copied {} EFI component(s) to ESP", efi_comps.len());
250+
log::info!("Successfully copied {} EFI component(s) to all ESPs", efi_comps.len());
249251
Ok(())
250252
}
251253
}

0 commit comments

Comments
 (0)