Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib/bootloader: Write to PReP partition on ppc64le #667

Merged
merged 1 commit into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 25 additions & 2 deletions lib/src/bootloader.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,34 @@
use anyhow::Result;
use camino::Utf8Path;
use camino::{Utf8Path, Utf8PathBuf};
use fn_error_context::context;

use crate::blockdev::PartitionTable;
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_GUID: &str = "9E1A2D38-C612-4316-AA26-8B49521E5A8B";
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: &PartitionTable) -> Result<Utf8PathBuf> {
#[cfg(target_arch = "powerpc64")]
{
return device
.partitions
.iter()
.find(|p| p.parttype.as_str() == PREPBOOT_GUID)
.ok_or_else(|| {
anyhow::anyhow!("Failed to find PReP partition with GUID {PREPBOOT_GUID}")
})
.map(|dev| dev.node.as_str().into());
}
#[cfg(not(target_arch = "powerpc64"))]
return Ok(device.path().into());
}

#[context("Installing bootloader")]
pub(crate) fn install_via_bootupd(
Expand All @@ -17,7 +39,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)
Expand Down
4 changes: 2 additions & 2 deletions lib/src/install/baseline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,8 @@ pub(crate) fn install_create_rootfs(
&mut sgdisk.cmd,
partno,
"0:+4M",
"PowerPC-PReP-boot",
Some("9E1A2D38-C612-4316-AA26-8B49521E5A8B"),
crate::bootloader::PREPBOOT_LABEL,
Some(crate::bootloader::PREPBOOT_GUID),
);
} else {
anyhow::bail!("Unsupported architecture: {}", std::env::consts::ARCH);
Expand Down