👷 add interactive chroot menu option

This commit is contained in:
Vladislav Nepogodin 2022-01-10 02:19:41 +04:00
parent 5efa3b4c06
commit a9b42495ea
No known key found for this signature in database
GPG Key ID: B62C3D10C54D5DA9
2 changed files with 27 additions and 1 deletions

View File

@ -561,6 +561,26 @@ void rm_pgs() noexcept {
#endif
}
void chroot_interactive() noexcept {
static constexpr auto chroot_return = "\nYou will now chroot into your installed system.\nYou can do changes almost as if you had booted into your installation.\n \nType \"exit\" to exit chroot.\n";
detail::infobox_widget(chroot_return);
std::this_thread::sleep_for(std::chrono::seconds(1));
#ifdef NDEVENV
auto* config_instance = Config::instance();
auto& config_data = config_instance->data();
const auto& mountpoint = std::get<std::string>(config_data["MOUNTPOINT"]);
utils::clear_screen();
std::cout << '\0' << std::flush;
const auto& cmd_formatted = fmt::format("arch-chroot {} bash", mountpoint);
utils::exec(cmd_formatted, true);
#else
utils::clear_screen();
utils::exec("bash", true);
#endif
}
void install_grub_uefi() noexcept {
static constexpr auto content = "\nInstall UEFI Bootloader GRUB.\n";
const auto& do_install_uefi = detail::yesno_widget(content, size(HEIGHT, LESS_THAN, 15) | size(WIDTH, LESS_THAN, 75));
@ -1961,6 +1981,12 @@ void install_core_menu() noexcept {
}
// tweaks_menu
break;
case 7:
if (!utils::check_base()) {
screen.ExitLoopClosure()();
}
tui::chroot_interactive();
break;
default:
screen.ExitLoopClosure()();
break;

View File

@ -101,7 +101,7 @@ void arch_chroot(const std::string_view& command, bool follow) noexcept {
auto& config_data = config_instance->data();
const auto& mountpoint = std::get<std::string>(config_data["MOUNTPOINT"]);
const auto& cmd_formatted = fmt::format("arch-chroot {} \"{}\"", mountpoint, command);
const auto& cmd_formatted = fmt::format("arch-chroot {} {}", mountpoint, command);
if (follow) {
tui::detail::follow_process_log_widget({"/bin/sh", "-c", cmd_formatted});
return;