mirror of
https://github.com/CachyOS/New-Cli-Installer.git
synced 2025-01-23 22:42:31 +08:00
🧹 use gucc for btrfs subvolumes manual UI
This commit is contained in:
parent
97be1f3fc4
commit
4d0abe4a38
38
src/disk.cpp
38
src/disk.cpp
@ -44,31 +44,31 @@ void btrfs_create_subvols([[maybe_unused]] const disk_part& disk, const std::str
|
|||||||
if (!tui::detail::inputbox_widget(subvols, subvols_body, size(ftxui::HEIGHT, ftxui::GREATER_THAN, 4))) {
|
if (!tui::detail::inputbox_widget(subvols, subvols_body, size(ftxui::HEIGHT, ftxui::GREATER_THAN, 4))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const auto& saved_path = fs::current_path();
|
|
||||||
fs::current_path(root_mountpoint);
|
|
||||||
auto subvol_list = gucc::utils::make_multiline(subvols, false, ' ');
|
auto subvol_list = gucc::utils::make_multiline(subvols, false, ' ');
|
||||||
for (const auto& subvol : subvol_list) {
|
|
||||||
gucc::utils::exec(fmt::format(FMT_COMPILE("btrfs subvolume create {} 2>>/tmp/cachyos-install.log"), subvol), true);
|
// Make the first subvolume with mountpoint /
|
||||||
}
|
std::vector<gucc::fs::BtrfsSubvolume> subvolumes{
|
||||||
fs::current_path(saved_path);
|
gucc::fs::BtrfsSubvolume{.subvolume = std::move(subvol_list[0]), .mountpoint = "/"s},
|
||||||
// Mount subvolumes
|
};
|
||||||
umount(root_mountpoint.data());
|
|
||||||
// Mount the first subvolume as /
|
|
||||||
gucc::utils::exec(fmt::format(FMT_COMPILE("mount -o {},subvol=\"{}\" \"{}\" /mnt"), disk.mount_opts, subvol_list[0], disk.root));
|
|
||||||
// Remove the first subvolume from the subvolume list
|
// Remove the first subvolume from the subvolume list
|
||||||
subvol_list.erase(subvol_list.begin());
|
subvol_list.erase(subvol_list.begin());
|
||||||
|
|
||||||
// Loop to mount all created subvolumes
|
// Get mountpoints of subvolumes
|
||||||
for (const auto& subvol : subvol_list) {
|
for (auto&& subvol : subvol_list) {
|
||||||
std::string mountp{"/home"};
|
// Ask for mountpoint
|
||||||
const auto& mountp_body = fmt::format(FMT_COMPILE("\nInput mountpoint of the subvolume {}\nas it would appear in installed system\n(without prepending /mnt).\n"), subvol);
|
const auto& content = fmt::format(FMT_COMPILE("\nInput mountpoint of\nthe subvolume {}\nas it would appear\nin installed system\n(without prepending {}).\n"), subvol, root_mountpoint);
|
||||||
if (!tui::detail::inputbox_widget(mountp, mountp_body, size(ftxui::HEIGHT, ftxui::GREATER_THAN, 4))) {
|
std::string mountpoint{"/home"};
|
||||||
|
if (!tui::detail::inputbox_widget(mountpoint, content, size(ftxui::HEIGHT, ftxui::LESS_THAN, 9) | size(ftxui::WIDTH, ftxui::LESS_THAN, 30))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto& mountp_formatted = fmt::format(FMT_COMPILE("{}{}"), root_mountpoint, mountp);
|
subvolumes.push_back(gucc::fs::BtrfsSubvolume{.subvolume = std::move(subvol), .mountpoint = std::move(mountpoint)});
|
||||||
fs::create_directories(mountp_formatted);
|
}
|
||||||
gucc::utils::exec(fmt::format(FMT_COMPILE("mount -o {},subvol=\"{}\" \"{}\" \"{}\""), disk.mount_opts, subvol, disk.root, mountp_formatted));
|
|
||||||
|
// Create subvolumes
|
||||||
|
if (!gucc::fs::btrfs_create_subvols(subvolumes, disk.root, root_mountpoint, disk.mount_opts)) {
|
||||||
|
spdlog::error("Failed to create subvolumes");
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -126,7 +126,7 @@ void mount_existing_subvols(const disk_part& disk) noexcept {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
subvolumes.push_back(gucc::fs::BtrfsSubvolume{.subvolume = subvol, .mountpoint = mountpoint});
|
subvolumes.push_back(gucc::fs::BtrfsSubvolume{.subvolume = std::move(subvol), .mountpoint = std::move(mountpoint)});
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(vnepogodin): add confirmation for selected mountpoint for particular subvolume
|
// TODO(vnepogodin): add confirmation for selected mountpoint for particular subvolume
|
||||||
|
Loading…
Reference in New Issue
Block a user