Skip to content

Commit ffbce7d

Browse files
authored
Merge pull request #667 from sacsant/powerpc64
lib/bootloader: Write to PReP partition on ppc64le
2 parents ec088bd + 7f90550 commit ffbce7d

File tree

2 files changed

+27
-4
lines changed

2 files changed

+27
-4
lines changed

lib/src/bootloader.rs

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,34 @@
11
use anyhow::Result;
2-
use camino::Utf8Path;
2+
use camino::{Utf8Path, Utf8PathBuf};
33
use fn_error_context::context;
44

55
use crate::blockdev::PartitionTable;
66
use crate::task::Task;
77

88
/// The name of the mountpoint for efi (as a subdirectory of /boot, or at the toplevel)
99
pub(crate) const EFI_DIR: &str = "efi";
10+
pub(crate) const PREPBOOT_GUID: &str = "9E1A2D38-C612-4316-AA26-8B49521E5A8B";
11+
pub(crate) const PREPBOOT_LABEL: &str = "PowerPC-PReP-boot";
12+
13+
/// Find the device to pass to bootupd. Only on powerpc64 right now
14+
/// we explicitly find one with a specific label.
15+
///
16+
/// This should get fixed once we execute on https://github.com/coreos/bootupd/issues/432
17+
fn get_bootupd_device(device: &PartitionTable) -> Result<Utf8PathBuf> {
18+
#[cfg(target_arch = "powerpc64")]
19+
{
20+
return device
21+
.partitions
22+
.iter()
23+
.find(|p| p.parttype.as_str() == PREPBOOT_GUID)
24+
.ok_or_else(|| {
25+
anyhow::anyhow!("Failed to find PReP partition with GUID {PREPBOOT_GUID}")
26+
})
27+
.map(|dev| dev.node.as_str().into());
28+
}
29+
#[cfg(not(target_arch = "powerpc64"))]
30+
return Ok(device.path().into());
31+
}
1032

1133
#[context("Installing bootloader")]
1234
pub(crate) fn install_via_bootupd(
@@ -17,7 +39,8 @@ pub(crate) fn install_via_bootupd(
1739
let verbose = std::env::var_os("BOOTC_BOOTLOADER_DEBUG").map(|_| "-vvvv");
1840
// bootc defaults to only targeting the platform boot method.
1941
let bootupd_opts = (!configopts.generic_image).then_some(["--update-firmware", "--auto"]);
20-
let devpath = device.path();
42+
43+
let devpath = get_bootupd_device(device)?;
2144
let args = ["backend", "install", "--write-uuid"]
2245
.into_iter()
2346
.chain(verbose)

lib/src/install/baseline.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,8 @@ pub(crate) fn install_create_rootfs(
261261
&mut sgdisk.cmd,
262262
partno,
263263
"0:+4M",
264-
"PowerPC-PReP-boot",
265-
Some("9E1A2D38-C612-4316-AA26-8B49521E5A8B"),
264+
crate::bootloader::PREPBOOT_LABEL,
265+
Some(crate::bootloader::PREPBOOT_GUID),
266266
);
267267
} else {
268268
anyhow::bail!("Unsupported architecture: {}", std::env::consts::ARCH);

0 commit comments

Comments
 (0)