Skip to content

Commit

Permalink
👷 fstab: don't provide options for fstab gen
Browse files Browse the repository at this point in the history
  • Loading branch information
vnepogodin committed Jul 6, 2024
1 parent ec7b6f4 commit 2b708b3
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 33 deletions.
2 changes: 1 addition & 1 deletion src/simple_tui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ void menu_simple() noexcept {
}*/

// at this point we should have everything already mounted
utils::generate_fstab("genfstab -U");
utils::generate_fstab();

if (hostname.empty()) {
tui::set_hostname();
Expand Down
33 changes: 4 additions & 29 deletions src/tui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,38 +128,13 @@ void btrfs_subvolumes() noexcept {

// Function will not allow incorrect UUID type for installed system.
void generate_fstab() noexcept {
const std::vector<std::string> menu_entries = {
"genfstab -U -p",
"genfstab -p",
"genfstab -L -p",
"genfstab -t PARTUUID -p",
};

auto* config_instance = Config::instance();
auto& config_data = config_instance->data();
const auto& system_info = std::get<std::string>(config_data["SYSTEM"]);

auto screen = ScreenInteractive::Fullscreen();
std::string fstab_cmd{};
std::int32_t selected{};
auto ok_callback = [&] {
if (system_info == "BIOS"sv && selected == 3) {
static constexpr auto FstabErr = "\nThe Part UUID option is only for UEFI/GPT installations.\n"sv;
detail::msgbox_widget(FstabErr);
return;
}
fstab_cmd = menu_entries[static_cast<std::size_t>(selected)];
screen.ExitLoopClosure()();
};

static constexpr auto fstab_body = "\nThe FSTAB file (File System TABle) sets what storage devices\nand partitions are to be mounted, and how they are to be used.\n\nUUID (Universally Unique IDentifier) is recommended.\n\nIf no labels were set for the partitions earlier,\ndevice names will be used for the label option.\n"sv;
detail::menu_widget(menu_entries, ok_callback, &selected, &screen, fstab_body);

static constexpr auto fstab_body = "\nThe FSTAB file (File System TABle) sets what storage devices\nand partitions are to be mounted, and how they are to be used.\n\nUUID (Universally Unique IDentifier) used.\n"sv;
const auto& do_set_fstab = detail::yesno_widget(fstab_body, size(HEIGHT, LESS_THAN, 15) | size(WIDTH, LESS_THAN, 75));
/* clang-format off */
if (fstab_cmd.empty()) { return; }
if (!do_set_fstab) { return; }
/* clang-format on */

utils::generate_fstab(fstab_cmd);
utils::generate_fstab();
}

// Set system hostname
Expand Down
5 changes: 3 additions & 2 deletions src/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,8 @@ void secure_wipe() noexcept {
#endif
}

void generate_fstab(const std::string_view& fstab_cmd) noexcept {
void generate_fstab() noexcept {
static constexpr auto fstab_cmd = "genfstab -U -p"sv;
spdlog::info("Generating with fstab '{}'", fstab_cmd);

#ifdef NDEVENV
Expand Down Expand Up @@ -916,7 +917,7 @@ void install_base(const std::string_view& packages) noexcept {
spdlog::info("re-run mkinitcpio");
}

utils::generate_fstab("genfstab -U -p");
utils::generate_fstab();

/* clang-format off */
if (zfs == 0) { return; }
Expand Down
2 changes: 1 addition & 1 deletion src/utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ void clear_screen() noexcept;
void inst_needed(const std::string_view& pkg) noexcept;
void secure_wipe() noexcept;
void auto_partition() noexcept;
void generate_fstab(const std::string_view& fstab_cmd) noexcept;
void generate_fstab() noexcept;
void set_hostname(const std::string_view& hostname) noexcept;
void set_locale(const std::string_view& locale) noexcept;
void set_xkbmap(const std::string_view& xkbmap) noexcept;
Expand Down

0 comments on commit 2b708b3

Please sign in to comment.