Skip to content

Commit 9103908

Browse files
committed
lib/bootloader: Write to PReP partition for ppc64le
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 <sachinp@linux.ibm.com>
1 parent 26bc174 commit 9103908

1 file changed

Lines changed: 28 additions & 1 deletion

File tree

lib/src/bootloader.rs

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use std::process::Command;
2+
use std::str;
13
use anyhow::Result;
24
use camino::Utf8Path;
35
use fn_error_context::context;
@@ -13,14 +15,39 @@ pub(crate) fn install_via_bootupd(
1315
rootfs: &Utf8Path,
1416
configopts: &crate::install::InstallConfigOpts,
1517
) -> Result<()> {
18+
let device_str: &str;
19+
let prepboot_dir;
1620
let verbose = std::env::var_os("BOOTC_BOOTLOADER_DEBUG").map(|_| "-vvvv");
1721
// bootc defaults to only targeting the platform boot method.
1822
let bootupd_opts = (!configopts.generic_image).then_some(["--update-firmware", "--auto"]);
23+
24+
if cfg!(target_arch = "powerpc64") {
25+
// get PowerPC-PReP-boot device information
26+
let result = Command::new("lsblk")
27+
.args([
28+
"--noheadings",
29+
"--paths",
30+
"--filter",
31+
&(format!(r#"'PARTLABEL=="PowerPC-PReP-boot"'"#)),
32+
"--output",
33+
&(format!("NAME")),
34+
])
35+
.arg(device)
36+
.output()?;
37+
if !result.status.success() {
38+
println!("{}", String::from_utf8_lossy(&result.stderr));
39+
anyhow::bail!("lsblkh failed with {}", result.status);
40+
}
41+
prepboot_dir = String::from_utf8(result.stdout)?;
42+
device_str = prepboot_dir.trim();
43+
} else {
44+
device_str = device.as_str()
45+
}
1946
let args = ["backend", "install", "--write-uuid"]
2047
.into_iter()
2148
.chain(verbose)
2249
.chain(bootupd_opts.iter().copied().flatten())
23-
.chain(["--device", device.as_str(), rootfs.as_str()]);
50+
.chain(["--device", device_str, rootfs.as_str()]);
2451
Task::new("Running bootupctl to install bootloader", "bootupctl")
2552
.args(args)
2653
.verbose()

0 commit comments

Comments
 (0)