From 2b708b3888334cd41eccfa45e1f6093f86545994 Mon Sep 17 00:00:00 2001 From: Vladislav Nepogodin Date: Sat, 6 Jul 2024 17:55:16 +0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=B7=20fstab:=20don't=20provide=20optio?= =?UTF-8?q?ns=20for=20fstab=20gen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/simple_tui.cpp | 2 +- src/tui.cpp | 33 ++++----------------------------- src/utils.cpp | 5 +++-- src/utils.hpp | 2 +- 4 files changed, 9 insertions(+), 33 deletions(-) diff --git a/src/simple_tui.cpp b/src/simple_tui.cpp index 781400f..b79764c 100644 --- a/src/simple_tui.cpp +++ b/src/simple_tui.cpp @@ -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(); diff --git a/src/tui.cpp b/src/tui.cpp index 19ffeef..182f3f9 100644 --- a/src/tui.cpp +++ b/src/tui.cpp @@ -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 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(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(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 diff --git a/src/utils.cpp b/src/utils.cpp index 2c9b587..ed705df 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -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 @@ -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; } diff --git a/src/utils.hpp b/src/utils.hpp index f268b58..f7f4154 100644 --- a/src/utils.hpp +++ b/src/utils.hpp @@ -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;