Skip to content

Commit 4212eb8

Browse files
committed
copy-to-boot: caller-provided root, require trait impl, error on no components
Implementing code review changes
1 parent 4d6a9db commit 4212eb8

4 files changed

Lines changed: 12 additions & 10 deletions

File tree

src/bios.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,4 +276,9 @@ impl Component for Bios {
276276
fn get_efi_vendor(&self, _: &Path) -> Result<Option<String>> {
277277
Ok(None)
278278
}
279+
280+
/// Package mode copy is EFI-only
281+
fn package_mode_copy_to_boot(&self, _root: &Path) -> Result<()> {
282+
Ok(())
283+
}
279284
}

src/bootupd.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -689,16 +689,15 @@ pub(crate) fn client_run_migrate_static_grub_config() -> Result<()> {
689689
}
690690

691691
/// Copy bootloader files from /usr/lib/efi to boot/ESP for package mode installations.
692-
pub(crate) fn copy_to_boot() -> Result<()> {
692+
pub(crate) fn copy_to_boot(root: &Path) -> Result<()> {
693693
let all_components = get_components_impl(false);
694694
if all_components.is_empty() {
695-
println!("No components available for this platform.");
696-
return Ok(());
695+
anyhow::bail!("No components available for this platform.");
697696
}
698697

699698
for component in all_components.values() {
700699
component
701-
.package_mode_copy_to_boot()
700+
.package_mode_copy_to_boot(root)
702701
.with_context(|| format!("Failed to copy component {} to boot", component.name()))?;
703702
}
704703

src/cli/bootupd.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ pub enum DVerb {
3737
Install(InstallOpts),
3838
#[clap(
3939
name = "copy-to-boot",
40-
about = "Copy bootloader files from /usr/lib/efi to boot/ESP (package mode)"
40+
about = "Copy bootloader files from /usr/lib/efi to ESP (package mode), EFI only"
4141
)]
4242
CopyToBoot,
4343
}
@@ -130,7 +130,7 @@ impl DCommand {
130130
}
131131

132132
pub(crate) fn run_copy_to_boot() -> Result<()> {
133-
bootupd::copy_to_boot().context("copying to boot failed")?;
133+
bootupd::copy_to_boot(std::path::Path::new("/")).context("copying to boot failed")?;
134134
Ok(())
135135
}
136136
}

src/component.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,8 @@ pub(crate) trait Component {
8080
/// Locating efi vendor dir
8181
fn get_efi_vendor(&self, sysroot: &Path) -> Result<Option<String>>;
8282

83-
/// Copy from /usr/lib/efi to boot/ESP.
84-
fn package_mode_copy_to_boot(&self) -> Result<()> {
85-
Ok(())
86-
}
83+
/// Copy from /usr/lib/efi to boot/ESP (package mode)
84+
fn package_mode_copy_to_boot(&self, root: &Path) -> Result<()>;
8785
}
8886

8987
/// Given a component name, create an implementation.

0 commit comments

Comments
 (0)