Skip to content

Commit 769b0fb

Browse files
committed
bootloader: Always pass full path to bootupd
This will depend on coreos/bootupd#839 And cleans up our bootloader code; move the bootloader partition definitions back to `install/baseline`. Conceptually now it's just the `to-disk` flow and bootupd that know about bootloader partition GUIDs which is how I think it should be - the bootc core is agnostic to bootloaders. Signed-off-by: Colin Walters <[email protected]>
1 parent 32d91ea commit 769b0fb

File tree

2 files changed

+11
-34
lines changed

2 files changed

+11
-34
lines changed

lib/src/bootloader.rs

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

55
use crate::task::Task;
66
use bootc_blockdev::PartitionTable;
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-
#[cfg(feature = "install-to-disk")]
11-
pub(crate) const ESP_GUID: &str = "C12A7328-F81F-11D2-BA4B-00A0C93EC93B";
12-
#[cfg(feature = "install-to-disk")]
13-
pub(crate) const PREPBOOT_GUID: &str = "9E1A2D38-C612-4316-AA26-8B49521E5A8B";
14-
#[cfg(feature = "install-to-disk")]
15-
pub(crate) const PREPBOOT_LABEL: &str = "PowerPC-PReP-boot";
16-
#[cfg(target_arch = "powerpc64")]
17-
/// We make a best-effort to support MBR partitioning too.
18-
pub(crate) const PREPBOOT_MBR_TYPE: &str = "41";
19-
20-
/// Find the device to pass to bootupd. Only on powerpc64 right now
21-
/// we explicitly find one with a specific label.
22-
///
23-
/// This should get fixed once we execute on https://github.com/coreos/bootupd/issues/432
24-
fn get_bootupd_device(device: &PartitionTable) -> Result<Utf8PathBuf> {
25-
#[cfg(target_arch = "powerpc64")]
26-
{
27-
return device
28-
.partitions
29-
.iter()
30-
.find(|p| matches!(p.parttype.as_str(), PREPBOOT_GUID | PREPBOOT_MBR_TYPE))
31-
.ok_or_else(|| {
32-
anyhow::anyhow!("Failed to find PReP partition with GUID {PREPBOOT_GUID}")
33-
})
34-
.map(|dev| dev.node.as_str().into());
35-
}
36-
#[cfg(not(target_arch = "powerpc64"))]
37-
return Ok(device.path().into());
38-
}
3910

4011
#[context("Installing bootloader")]
4112
pub(crate) fn install_via_bootupd(
@@ -47,7 +18,7 @@ pub(crate) fn install_via_bootupd(
4718
// bootc defaults to only targeting the platform boot method.
4819
let bootupd_opts = (!configopts.generic_image).then_some(["--update-firmware", "--auto"]);
4920

50-
let devpath = get_bootupd_device(device)?;
21+
let devpath = device.path();
5122
let args = ["backend", "install", "--write-uuid"]
5223
.into_iter()
5324
.chain(verbose)

lib/src/install/baseline.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ pub(crate) const BOOTPN_SIZE_MB: u32 = 510;
3737
pub(crate) const EFIPN_SIZE_MB: u32 = 512;
3838
/// The GPT type for "linux"
3939
pub(crate) const LINUX_PARTTYPE: &str = "0FC63DAF-8483-4772-8E79-3D69D8477DE4";
40+
#[cfg(feature = "install-to-disk")]
41+
pub(crate) const PREPBOOT_GUID: &str = "9E1A2D38-C612-4316-AA26-8B49521E5A8B";
42+
#[cfg(feature = "install-to-disk")]
43+
pub(crate) const PREPBOOT_LABEL: &str = "PowerPC-PReP-boot";
44+
#[cfg(feature = "install-to-disk")]
45+
pub(crate) const ESP_GUID: &str = "C12A7328-F81F-11D2-BA4B-00A0C93EC93B";
4046

4147
#[derive(clap::ValueEnum, Default, Debug, Copy, Clone, PartialEq, Eq, Serialize, Deserialize)]
4248
#[serde(rename_all = "kebab-case")]
@@ -258,8 +264,8 @@ pub(crate) fn install_create_rootfs(
258264
} else if cfg!(target_arch = "powerpc64") {
259265
// PowerPC-PReP-boot
260266
partno += 1;
261-
let label = crate::bootloader::PREPBOOT_LABEL;
262-
let uuid = crate::bootloader::PREPBOOT_GUID;
267+
let label = PREPBOOT_LABEL;
268+
let uuid = PREPBOOT_GUID;
263269
writeln!(
264270
&mut partitioning_buf,
265271
r#"size=4MiB, bootable, type={uuid}, name="{label}""#
@@ -271,7 +277,7 @@ pub(crate) fn install_create_rootfs(
271277
}
272278

273279
let esp_partno = if super::ARCH_USES_EFI {
274-
let esp_guid = crate::bootloader::ESP_GUID;
280+
let esp_guid = ESP_GUID;
275281
partno += 1;
276282
writeln!(
277283
&mut partitioning_buf,

0 commit comments

Comments
 (0)