diff --git a/lib/src/bootloader.rs b/lib/src/bootloader.rs index 810a2eb0..3a2e5360 100644 --- a/lib/src/bootloader.rs +++ b/lib/src/bootloader.rs @@ -1,5 +1,5 @@ use anyhow::Result; -use camino::Utf8Path; +use camino::{Utf8Path, Utf8PathBuf}; use fn_error_context::context; use crate::blockdev::Device; @@ -7,6 +7,26 @@ use crate::task::Task; /// The name of the mountpoint for efi (as a subdirectory of /boot, or at the toplevel) pub(crate) const EFI_DIR: &str = "efi"; +pub(crate) const PREPBOOT_LABEL: &str = "PowerPC-PReP-boot"; + +/// Find the device to pass to bootupd. Only on powerpc64 right now +/// we explicitly find one with a specific label. +/// +/// This should get fixed once we execute on https://github.com/coreos/bootupd/issues/432 +fn get_bootupd_device(device: &Device) -> Result { + #[cfg(target_arch = "powerpc64")] + { + return device + .children + .unwrap_or_default() + .into_iter() + .find(|dev| dev.partlabel.as_deref() == Some(PREPBOOT_LABEL)) + .ok_or_else(|| anyhow::anyhow!("Failed to find partition with label {PREPBOOT_LABEL}")) + .map(|dev| dev.path().into()); + } + #[cfg(not(target_arch = "powerpc64"))] + return Ok(device.path().into()); +} #[context("Installing bootloader")] pub(crate) fn install_via_bootupd( @@ -17,7 +37,8 @@ pub(crate) fn install_via_bootupd( let verbose = std::env::var_os("BOOTC_BOOTLOADER_DEBUG").map(|_| "-vvvv"); // bootc defaults to only targeting the platform boot method. let bootupd_opts = (!configopts.generic_image).then_some(["--update-firmware", "--auto"]); - let devpath = device.path(); + + let devpath = get_bootupd_device(device)?; let args = ["backend", "install", "--write-uuid"] .into_iter() .chain(verbose) diff --git a/lib/src/install/baseline.rs b/lib/src/install/baseline.rs index 31abbe6a..204ff5bd 100644 --- a/lib/src/install/baseline.rs +++ b/lib/src/install/baseline.rs @@ -261,7 +261,7 @@ pub(crate) fn install_create_rootfs( &mut sgdisk.cmd, partno, "0:+4M", - "PowerPC-PReP-boot", + crate::bootloader::PREPBOOT_LABEL, Some("9E1A2D38-C612-4316-AA26-8B49521E5A8B"), ); } else {