Skip to content

Commit 8545d8c

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 02ecf37 commit 8545d8c

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

@@ -394,7 +395,7 @@ pub(crate) fn setup_composefs_bls_boot(
394395
Utf8PathBuf::from("/sysroot"),
395396
get_esp_partition(&sysroot_parent)?.0,
396397
[
397-
format!("root=UUID={DPS_UUID}"),
398+
format!("root=UUID={}", this_arch_root()),
398399
RW_KARG.to_string(),
399400
format!("{COMPOSEFS_CMDLINE}={id_hex}"),
400401
]

crates/lib/src/bootloader.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,11 @@ use bootc_mount as mount;
1111
#[cfg(any(feature = "composefs-backend", feature = "install-to-disk"))]
1212
use bootc_mount::tempmount::TempMount;
1313

14-
use crate::utils;
14+
use crate::{discoverable_partition_specification, utils};
1515

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

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

9391
let esp_mount = TempMount::mount_dev(&esp_part.node).context("Mounting ESP")?;

0 commit comments

Comments
 (0)