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]>
  • Loading branch information
sacsant committed Jul 12, 2024
1 parent 26bc174 commit 9103908
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion lib/src/bootloader.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::process::Command;
use std::str;
use anyhow::Result;
use camino::Utf8Path;
use fn_error_context::context;
Expand All @@ -13,14 +15,39 @@ pub(crate) fn install_via_bootupd(
rootfs: &Utf8Path,
configopts: &crate::install::InstallConfigOpts,
) -> Result<()> {
let device_str: &str;
let prepboot_dir;
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"]);

if cfg!(target_arch = "powerpc64") {
// get PowerPC-PReP-boot device information
let result = Command::new("lsblk")
.args([
"--noheadings",
"--paths",
"--filter",
&(format!(r#"'PARTLABEL=="PowerPC-PReP-boot"'"#)),
"--output",
&(format!("NAME")),
])
.arg(device)
.output()?;
if !result.status.success() {
println!("{}", String::from_utf8_lossy(&result.stderr));
anyhow::bail!("lsblkh failed with {}", result.status);
}
prepboot_dir = String::from_utf8(result.stdout)?;
device_str = prepboot_dir.trim();
} else {
device_str = device.as_str()
}
let args = ["backend", "install", "--write-uuid"]
.into_iter()
.chain(verbose)
.chain(bootupd_opts.iter().copied().flatten())
.chain(["--device", device.as_str(), rootfs.as_str()]);
.chain(["--device", device_str, rootfs.as_str()]);
Task::new("Running bootupctl to install bootloader", "bootupctl")
.args(args)
.verbose()
Expand Down

0 comments on commit 9103908

Please sign in to comment.