🧹 tui: grub efi gets handled by utility
Some checks are pending
Build / Build with CMake (push) Waiting to run
Build / Build with CMake (DEVENV OFF) (push) Waiting to run
Build / Build with Meson (push) Waiting to run
Build / Build with Meson (DEVENV OFF) (push) Waiting to run
Checks / cpp-linter (push) Waiting to run
Checks / Check C++ style (push) Waiting to run

prevent code duplication
This commit is contained in:
Vladislav Nepogodin 2025-01-13 04:07:09 +04:00
parent 800ae404e8
commit 4c613309d8
No known key found for this signature in database
GPG Key ID: B62C3D10C54D5DA9

View File

@ -454,22 +454,17 @@ void install_grub_uefi() noexcept {
const auto& uefi_mount = std::get<std::string>(config_data["UEFI_MOUNT"]); const auto& uefi_mount = std::get<std::string>(config_data["UEFI_MOUNT"]);
utils::clear_screen(); utils::clear_screen();
utils::install_grub_uefi(bootid, false);
// Ask if user wishes to set Grub as the default bootloader and act accordingly // Ask if user wishes to set Grub as the default bootloader and act accordingly
static constexpr auto set_boot_default_body = "Some UEFI firmware may not detect the bootloader unless it is set\nas default by copying its efi stub to"sv; static constexpr auto set_boot_default_body = "Some UEFI firmware may not detect the bootloader unless it is set\nas default by copying its efi stub to"sv;
static constexpr auto set_boot_default_body2 = "and renaming it to bootx64.efi.\n\nIt is recommended to do so unless already using a default bootloader,\nor where intending to use multiple bootloaders.\n\nSet bootloader as default?"sv; static constexpr auto set_boot_default_body2 = "and renaming it to bootx64.efi.\n\nIt is recommended to do so unless already using a default bootloader,\nor where intending to use multiple bootloaders.\n\nSet bootloader as default?"sv;
const auto& do_set_default_bootloader = detail::yesno_widget(fmt::format(FMT_COMPILE("\n{} {}/EFI/boot {}\n"), set_boot_default_body, uefi_mount, set_boot_default_body2), size(HEIGHT, LESS_THAN, 15) | size(WIDTH, LESS_THAN, 75)); const auto& do_set_default_bootloader = detail::yesno_widget(fmt::format(FMT_COMPILE("\n{} {}/EFI/boot {}\n"), set_boot_default_body, uefi_mount, set_boot_default_body2), size(HEIGHT, LESS_THAN, 15) | size(WIDTH, LESS_THAN, 75));
utils::install_grub_uefi(bootid, do_set_default_bootloader);
/* clang-format off */ /* clang-format off */
if (!do_set_default_bootloader) { return; } if (!do_set_default_bootloader) { return; }
/* clang-format on */ /* clang-format on */
#ifdef NDEVENV
utils::arch_chroot(fmt::format(FMT_COMPILE("mkdir -p {}/EFI/boot"), uefi_mount), false);
spdlog::info("Grub efi binary status:(EFI/cachyos/grubx64.efi): {}", fs::exists(fmt::format(FMT_COMPILE("{0}/EFI/cachyos/grubx64.efi"), uefi_mount)));
utils::arch_chroot(fmt::format(FMT_COMPILE("cp -r {0}/EFI/cachyos/grubx64.efi {0}/EFI/boot/bootx64.efi"), uefi_mount), false);
#endif
detail::infobox_widget("\nGrub has been set as the default bootloader.\n"sv); detail::infobox_widget("\nGrub has been set as the default bootloader.\n"sv);
std::this_thread::sleep_for(std::chrono::seconds(2)); std::this_thread::sleep_for(std::chrono::seconds(2));
} }
@ -713,6 +708,7 @@ void bios_bootloader() {
if (selected_bootloader.empty()) { return; } if (selected_bootloader.empty()) { return; }
/* clang-format on */ /* clang-format on */
// that will install 2 packages in case os-prober entry is selected
utils::remove_all(selected_bootloader, "+ "sv); utils::remove_all(selected_bootloader, "+ "sv);
/* clang-format off */ /* clang-format off */