apply mode: wire partition apply + mkfs; btrfs RAID1 flags and -f; UEFI detection and skip bios_boot when UEFI; sgdisk-based partition apply; update TODO and REGION markers

This commit is contained in:
2025-09-29 15:10:57 +02:00
parent b0e41b59b1
commit 04216b7f8f
7 changed files with 295 additions and 43 deletions

View File

@@ -4,11 +4,13 @@
// api: util::run_cmd(args: &[&str]) -> crate::Result<()>
// api: util::run_cmd_capture(args: &[&str]) -> crate::Result<CmdOutput>
// api: util::udev_settle(timeout_ms: u64) -> crate::Result<()>
// api: util::is_efi_boot() -> bool
// REGION: API-END
//
// REGION: RESPONSIBILITIES
// - Centralize external tool discovery and invocation (sgdisk, blkid, mkfs.*, udevadm).
// - Provide capture and error mapping to crate::Error consistently.
// - Provide environment helpers (udev settle, boot mode detection).
// Non-goals: business logic (planning/validation), direct parsing of complex outputs beyond what callers need.
// REGION: RESPONSIBILITIES-END
//
@@ -39,6 +41,7 @@
use crate::{Error, Result};
use std::process::Command;
use std::path::Path;
use tracing::{debug, warn};
/// Captured output from an external tool invocation.
@@ -147,6 +150,14 @@ pub fn udev_settle(timeout_ms: u64) -> Result<()> {
}
}
/// Detect whether the current system booted via UEFI (initramfs-friendly).
///
/// Returns true when /sys/firmware/efi exists (standard on UEFI boots).
/// Returns false on legacy BIOS boots where that path is absent.
pub fn is_efi_boot() -> bool {
Path::new("/sys/firmware/efi").exists()
}
#[cfg(test)]
mod tests {
use super::*;