Skip to content

Commit

Permalink
lib/bootloader: Write to PReP partition for ppc64le
Browse files Browse the repository at this point in the history
Bootloader code currently writes required data to base/parent
device (eg /dev/sda). This logic does not work for ppc64le
architecture as bootloader configuration has to be written
to PRePboot partition(typically first partition of disk).

This patch adds code to identify PowerPC-PReP-boot partition
(for ppc64le architecture) using lsblk command and writes
bootloader data to it.

Signed-off-by: Sachin Sant <[email protected]>
Signed-off-by: Colin Walters <[email protected]>
  • Loading branch information
sacsant authored and cgwalters committed Jul 13, 2024
1 parent 3be47ba commit 47e882d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
25 changes: 23 additions & 2 deletions lib/src/bootloader.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,32 @@
use anyhow::Result;
use camino::Utf8Path;
use camino::{Utf8Path, Utf8PathBuf};
use fn_error_context::context;

use crate::blockdev::Device;
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<Utf8PathBuf> {
#[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(
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion lib/src/install/baseline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 47e882d

Please sign in to comment.