Skip to content

Commit b8575ae

Browse files
committed
crates: Add discoverable partition module
This fleshes out what we had with a more rigorous binding to the spec. Assisted-by: Claude Code Signed-off-by: Colin Walters <[email protected]>
1 parent 84c7a19 commit b8575ae

File tree

10 files changed

+1317
-29
lines changed

10 files changed

+1317
-29
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ anyhow = "1.0.82"
3636
camino = "1.1.6"
3737
canon-json = "0.2.1"
3838
cap-std-ext = "4.0.3"
39+
cfg-if = "1.0"
3940
chrono = { version = "0.4.38", default-features = false }
4041
clap = "4.5.4"
4142
clap_mangen = { version = "0.2.20" }

crates/lib/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ anyhow = { workspace = true }
3030
camino = { workspace = true, features = ["serde1"] }
3131
canon-json = { workspace = true }
3232
cap-std-ext = { workspace = true, features = ["fs_utf8"] }
33+
cfg-if = { workspace = true }
3334
chrono = { workspace = true, features = ["serde"] }
3435
clap = { workspace = true, features = ["derive","cargo"] }
3536
clap_mangen = { workspace = true, optional = true }

crates/lib/src/bootc_composefs/boot.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ use crate::{
4444
BOOT_LOADER_ENTRIES, COMPOSEFS_CMDLINE, ORIGIN_KEY_BOOT, ORIGIN_KEY_BOOT_DIGEST,
4545
STAGED_BOOT_LOADER_ENTRIES, STATE_DIR_ABS, USER_CFG, USER_CFG_STAGED,
4646
},
47-
install::{dps_uuid::DPS_UUID, RW_KARG},
47+
discoverable_partition_specification::this_arch_root,
48+
install::RW_KARG,
4849
spec::{Bootloader, Host},
4950
};
5051

@@ -400,7 +401,7 @@ pub(crate) fn setup_composefs_bls_boot(
400401
Utf8PathBuf::from("/sysroot"),
401402
get_esp_partition(&sysroot_parent)?.0,
402403
[
403-
format!("root=UUID={DPS_UUID}"),
404+
format!("root=UUID={}", this_arch_root()),
404405
RW_KARG.to_string(),
405406
format!("{COMPOSEFS_CMDLINE}={id_hex}"),
406407
]

crates/lib/src/bootloader.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,11 @@ use bootc_mount as mount;
1010

1111
#[cfg(any(feature = "composefs-backend", feature = "install-to-disk"))]
1212
use crate::bootc_composefs::boot::mount_esp;
13-
use crate::utils;
13+
use crate::{discoverable_partition_specification, utils};
1414

1515
/// The name of the mountpoint for efi (as a subdirectory of /boot, or at the toplevel)
1616
pub(crate) const EFI_DIR: &str = "efi";
1717
/// The EFI system partition GUID
18-
#[allow(dead_code)]
19-
pub(crate) const ESP_GUID: &str = "C12A7328-F81F-11D2-BA4B-00A0C93EC93B";
2018
/// Path to the bootupd update payload
2119
#[allow(dead_code)]
2220
const BOOTUPD_UPDATES: &str = "usr/lib/bootupd/updates";
@@ -26,7 +24,7 @@ pub(crate) fn esp_in(device: &PartitionTable) -> Result<&Partition> {
2624
device
2725
.partitions
2826
.iter()
29-
.find(|p| p.parttype.as_str() == ESP_GUID)
27+
.find(|p| p.parttype.as_str() == discoverable_partition_specification::ESP)
3028
.ok_or(anyhow::anyhow!("ESP not found in partition table"))
3129
}
3230

@@ -86,7 +84,7 @@ pub(crate) fn install_systemd_boot(
8684
let esp_part = device
8785
.partitions
8886
.iter()
89-
.find(|p| p.parttype.as_str() == ESP_GUID)
87+
.find(|p| p.parttype.as_str() == discoverable_partition_specification::ESP)
9088
.ok_or_else(|| anyhow::anyhow!("ESP partition not found"))?;
9189

9290
let esp_mount = mount_esp(&esp_part.node).context("Mounting ESP")?;

0 commit comments

Comments
 (0)