Skip to content

Commit 6436e10

Browse files
committed
🚧 simple_tui: expose auto partitions to ready_parts
1 parent 6f5532c commit 6436e10

1 file changed

Lines changed: 21 additions & 4 deletions

File tree

‎src/simple_tui.cpp‎

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -896,7 +896,8 @@ void prepare_disk_state(const UserSelections& selections) noexcept {
896896
config_data["BOOTLOADER"] = selections.bootloader;
897897
config_data["FILESYSTEM_NAME"] = selections.filesystem;
898898

899-
utils::auto_partition();
899+
// Generate and apply partition schema
900+
auto auto_partitions = utils::auto_partition();
900901
utils::lvm_detect();
901902

902903
config_data["INCLUDE_PART"] = "part\\|lvm\\|crypt";
@@ -915,12 +916,28 @@ void prepare_disk_state(const UserSelections& selections) noexcept {
915916
}
916917

917918
auto& ready_parts = std::get<std::vector<std::string>>(config_data["READY_PARTITIONS"]);
918-
if (ready_parts.empty()) {
919-
utils::select_filesystem(selections.filesystem);
919+
if (ready_parts.empty() && !auto_partitions.empty()) {
920+
config_data["PARTITION_SCHEMA"] = auto_partitions;
921+
spdlog::info("Auto-partition schema stored with {} entries", auto_partitions.size());
922+
923+
// Convert auto-partition output into ready_parts format:
924+
// "{device}\t{mountpoint}\t{size}\t{fstype}\t{type}"
925+
// where type is "boot" for /boot or /boot/efi, "root" for /, else "additional".
926+
std::vector<std::string> built_ready_parts{};
927+
built_ready_parts.reserve(auto_partitions.size());
928+
for (const auto& part : auto_partitions) {
929+
const auto part_type = (part.mountpoint == "/boot"sv || part.mountpoint == "/boot/efi"sv)
930+
? "boot"sv
931+
: (part.mountpoint == "/"sv ? "root"sv : "additional"sv);
932+
built_ready_parts.emplace_back(fmt::format(FMT_COMPILE("{}\t{}\t{}\t{}\t{}"),
933+
part.device, part.mountpoint, part.size, part.fstype, part_type));
934+
}
935+
ready_parts = std::move(built_ready_parts);
936+
spdlog::info("Auto-partition produced {} ready_parts entries", ready_parts.size());
920937
}
921938

922939
if (ready_parts.empty()) {
923-
spdlog::info("TODO: auto make layout(ready parts)!");
940+
utils::select_filesystem(selections.filesystem);
924941
}
925942
}
926943

0 commit comments

Comments
 (0)