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

34
TODO.md
View File

@@ -9,18 +9,30 @@ Conventions:
Core execution
- [ ] Add “apply mode” switch to orchestrator to perform destructive actions after preview validation
- Wire phase execution in [orchestrator.run(&Context)](src/orchestrator/run.rs:101): apply partitions → udev settle → mkfs → mount → maybe write fstab → build/write report
- Introduce a CLI flag (e.g. `--apply`) guarded by clear logs and safety checks (not preview)
- [ ] Partition application (destructive) in [fn apply_partitions(...)](src/partition/plan.rs:287)
- Translate [PartitionPlan](src/partition/plan.rs:80) to sgdisk commands (create GPT, partitions in order with alignment and names)
- Enforce idempotency: skip if table already matches plan (or abort with explicit validation error)
- Ensure unique partition GUIDs; capture partition device paths and GUIDs for results
- Call [util::udev_settle()](src/util/mod.rs:128) after changes; robust error mapping to Error::Tool / Error::Partition
- [-] Add “apply mode” switch to orchestrator to perform destructive actions after preview validation
- [x] Introduce CLI flag --apply guarded by clear logs and safety checks (not preview) [src/cli/args.rs](src/cli/args.rs)
- [x] Wire partition application and udev settle [orchestrator::run()](src/orchestrator/run.rs:1) → [partition::apply_partitions()](src/partition/plan.rs:1)
- [-] Wire mkfs → mount → maybe write fstab → build/write report [src/orchestrator/run.rs](src/orchestrator/run.rs)
- [x] Wire mkfs: plan_filesystems + make_filesystems [src/orchestrator/run.rs](src/orchestrator/run.rs) + [src/fs/plan.rs](src/fs/plan.rs)
- [ ] Wire mounts (plan/apply) [src/mount/ops.rs](src/mount/ops.rs)
- [ ] maybe write fstab [src/mount/ops.rs](src/mount/ops.rs)
- [ ] build/write report [src/report/state.rs](src/report/state.rs)
- [x] Partition application (destructive) in [partition::apply_partitions()](src/partition/plan.rs:1)
- [x] Boot mode detection and BIOS boot policy
- [x] Implement UEFI detection via /sys/firmware/efi: [is_efi_boot()](src/util/mod.rs:151)
- [x] Planner skips BIOS boot partition when UEFI-booted: [partition::plan_partitions()](src/partition/plan.rs:133)
- [ ] Future: revisit bootblock/bootloader specifics for BIOS vs EFI (confirm if any BIOS-targets require bios_boot) [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md)
- [x] Translate [PartitionPlan](src/partition/plan.rs:1) to sgdisk commands (create GPT, partitions in order with alignment and names)
- [x] Enforce idempotency when required via [idempotency::is_empty_disk()](src/idempotency/mod.rs:1); abort on non-empty
- [x] Capture partition GUIDs, names, device paths via sgdisk -i parsing; map to PartitionResult
- [x] Call [util::udev_settle()](src/util/mod.rs:1) after changes; consistent Error::Tool/Error::Partition mapping
- [-] Filesystem creation in [fn make_filesystems(...)](src/fs/plan.rs:182)
- [x] Base mkfs implemented for vfat/btrfs/bcachefs (UUID capture via blkid)
- [ ] Apply btrfs raid profile from config (e.g., `-m raid1 -d raid1`) for [Topology::BtrfsRaid1](src/types.rs:29) and the desired profile in [struct BtrfsOptions](src/types.rs:89)
- [ ] Optionally map compression options for btrfs and bcachefs from config (e.g., `-O compress=zstd:3` or format-equivalent)
- [x] Apply btrfs RAID profile when topology requires it (multi-device): pass -m raid1 -d raid1 in mkfs.btrfs [src/fs/plan.rs](src/fs/plan.rs)
- [x] Force mkfs.btrfs in apply path with -f to handle leftover signatures from partial runs [src/fs/plan.rs](src/fs/plan.rs)
- [ ] Compression/tuning mapping from config
- [ ] btrfs: apply compression as mount options during mounting phase [src/mount/ops.rs](src/mount/ops.rs)
- [ ] bcachefs: map compression/checksum/cache_mode to format flags (deferred) [src/fs/plan.rs](src/fs/plan.rs)
- [ ] Consider verifying UUID consistency across multi-device filesystems and improve error messages
- [ ] Mount planning and application in [mount::ops](src/mount/ops.rs:1)
- [ ] Implement [fn plan_mounts(...)](src/mount/ops.rs:68): map FsResult UUIDs into `/var/cache/{UUID}` using [cfg.mount.base_dir](src/types.rs:136), and synthesize options per FS kind
@@ -44,7 +56,7 @@ CLI, config, defaults
- [x] Built-in sensible defaults (no YAML required) [src/config/loader.rs](src/config/loader.rs:320)
- [x] Overlays from CLI: log level, file logging, fstab, removable policy, topology [src/config/loader.rs](src/config/loader.rs:247)
- [x] Preview flags (`--show`, `--report`) and topology selection (`-t/--topology`) [src/cli/args.rs](src/cli/args.rs:55)
- [ ] Add `--apply` flag to toggle execute mode and keep preview non-destructive by default [src/cli/args.rs](src/cli/args.rs:55)
- [x] Add `--apply` flag to toggle execute mode and keep preview non-destructive by default [src/cli/args.rs](src/cli/args.rs)
- [ ] Consider environment variable overlays [src/config/loader.rs](src/config/loader.rs:39)
- [ ] Consider hidden/dev flags behind features (e.g., `--dry-run-verbose`, `--trace-io`) [src/cli/args.rs](src/cli/args.rs:26)