mirror of
https://github.com/CachyOS/New-Cli-Installer.git
synced 2025-01-23 14:32:22 +08:00
👷 add new pages
Add ability to watch at the system logs User can now review configs installed on OS Selecting drivers needed for the target, through TUI, or just pick drivers automatically
This commit is contained in:
parent
a348f980ce
commit
7c078af4fc
@ -91,9 +91,11 @@ add_executable(${PROJECT_NAME}
|
||||
src/config.cpp src/config.hpp
|
||||
src/utils.cpp src/utils.hpp
|
||||
src/disk.cpp src/disk.hpp
|
||||
src/drivers.cpp src/drivers.hpp
|
||||
src/widgets.cpp src/widgets.hpp
|
||||
src/follow_process_log.hpp src/follow_process_log.cpp
|
||||
src/crypto.cpp src/crypto.hpp
|
||||
src/misc.cpp src/misc.hpp
|
||||
src/tui.cpp src/tui.hpp
|
||||
src/main.cpp
|
||||
)
|
||||
|
14
README.md
14
README.md
@ -63,7 +63,7 @@ pass `-DENABLE_DEVENV=OFF` to cmake or `-Ddevenv=false` to meson when configurin
|
||||
|
||||
**Simple menu overview:**
|
||||
|
||||
TODO: should be simple as calamares
|
||||
TODO: should be simple as Calamares Installer
|
||||
|
||||
---
|
||||
|
||||
@ -112,13 +112,13 @@ Main Menu
|
||||
| | ├── Disable Coredump Logging
|
||||
| | └── Restrict Access to Kernel Logs
|
||||
| │
|
||||
│ ├── Review Configuration Files (TODO)
|
||||
│ ├── Review Configuration Files
|
||||
│ └── Chroot into Installation
|
||||
|
|
||||
└── System Rescue
|
||||
├── Install Hardware Drivers (TODO)
|
||||
│ ├── Install Display Drivers
|
||||
│ └── Install Network Drivers
|
||||
├── Install Hardware Drivers
|
||||
│ ├── Install Display Drivers (WIP)
|
||||
│ └── Install Network Drivers (TODO)
|
||||
|
|
||||
├── Install Bootloader
|
||||
├── Configure Base
|
||||
@ -126,12 +126,12 @@ Main Menu
|
||||
│
|
||||
├── Install Custom Packages
|
||||
├── Remove Packages
|
||||
├── Review Configuration Files (TODO)
|
||||
├── Review Configuration Files
|
||||
├── Chroot into Installation
|
||||
├── Data Recovery (TODO)
|
||||
│ └── Btrfs snapshots..
|
||||
│
|
||||
└── View System Logs (TODO)
|
||||
└── View System Logs
|
||||
├── Dmesg
|
||||
├── Pacman log
|
||||
├── Xorg log
|
||||
|
@ -47,9 +47,11 @@ src_files = files(
|
||||
'src/config.cpp', 'src/config.hpp',
|
||||
'src/utils.cpp', 'src/utils.hpp',
|
||||
'src/disk.cpp', 'src/disk.hpp',
|
||||
'src/drivers.cpp', 'src/drivers.hpp',
|
||||
'src/widgets.cpp', 'src/widgets.hpp',
|
||||
'src/follow_process_log.cpp', 'src/follow_process_log.hpp',
|
||||
'src/crypto.cpp', 'src/crypto.hpp',
|
||||
'src/misc.cpp', 'src/misc.hpp',
|
||||
'src/tui.cpp', 'src/tui.hpp',
|
||||
'src/main.cpp',
|
||||
)
|
||||
|
@ -35,6 +35,9 @@ bool Config::initialize() noexcept {
|
||||
|
||||
// Mounting
|
||||
s_config->m_data["MOUNTPOINT"] = "/mnt";
|
||||
|
||||
// Installation
|
||||
s_config->m_data["GRAPHIC_CARD"] = "";
|
||||
}
|
||||
|
||||
return s_config.get();
|
||||
|
135
src/drivers.cpp
Normal file
135
src/drivers.cpp
Normal file
@ -0,0 +1,135 @@
|
||||
#include "drivers.hpp"
|
||||
#include "config.hpp"
|
||||
#include "utils.hpp"
|
||||
#include "widgets.hpp"
|
||||
|
||||
/* clang-format off */
|
||||
#include <fstream> // for ofstream
|
||||
#include <ftxui/component/component.hpp> // for Renderer, Button
|
||||
#include <ftxui/component/component_options.hpp> // for ButtonOption
|
||||
#include <ftxui/component/screen_interactive.hpp> // for Component, ScreenI...
|
||||
#include <ftxui/dom/elements.hpp> // for operator|, size
|
||||
/* clang-format on */
|
||||
|
||||
#include <fmt/compile.h>
|
||||
#include <fmt/core.h>
|
||||
|
||||
using namespace ftxui;
|
||||
|
||||
namespace tui {
|
||||
|
||||
static void install_intel() noexcept { }
|
||||
static void install_ati() noexcept {
|
||||
auto* config_instance = Config::instance();
|
||||
auto& config_data = config_instance->data();
|
||||
const auto& mountpoint = std::get<std::string>(config_data["MOUNTPOINT"]);
|
||||
|
||||
utils::exec(fmt::format(FMT_COMPILE("sed -i 's/MODULES=\"\"/MODULES=\"radeon\"/' {}/etc/mkinitcpio.conf"), mountpoint));
|
||||
}
|
||||
|
||||
static void setup_graphics_card() noexcept {
|
||||
std::string_view driver{};
|
||||
{
|
||||
static constexpr auto UseSpaceBar = "\nUse [Spacebar] to de/select options listed.\n";
|
||||
const auto& cmd = utils::exec("mhwd -l | awk '/ video-/{print $1}' | awk '$0=$0' | sort | uniq");
|
||||
const auto& radiobox_list = utils::make_multiline(cmd);
|
||||
|
||||
auto screen = ScreenInteractive::Fullscreen();
|
||||
std::int32_t selected{};
|
||||
auto ok_callback = [&] {
|
||||
driver = radiobox_list[static_cast<size_t>(selected)];
|
||||
screen.ExitLoopClosure()();
|
||||
};
|
||||
detail::radiolist_widget(radiobox_list, ok_callback, &selected, &screen, UseSpaceBar, detail::WidgetBoxSize{.text_size = nothing});
|
||||
}
|
||||
/* clang-format off */
|
||||
if (driver.empty()) { return; }
|
||||
/* clang-format on */
|
||||
|
||||
auto* config_instance = Config::instance();
|
||||
auto& config_data = config_instance->data();
|
||||
const auto& mountpoint = std::get<std::string>(config_data["MOUNTPOINT"]);
|
||||
const auto& cachepath = std::get<std::string>(config_data["cachepath"]);
|
||||
auto& graphics_card = std::get<std::string>(config_data["GRAPHIC_CARD"]);
|
||||
|
||||
utils::exec(fmt::format(FMT_COMPILE("mhwd --pmcachedir \"{}\" --pmroot {} -f -i pci {}"), cachepath, mountpoint, driver), true);
|
||||
std::ofstream{fmt::format(FMT_COMPILE("{}/.video_installed"), mountpoint)};
|
||||
|
||||
graphics_card = utils::exec("lspci | grep -i \"vga\" | sed 's/.*://' | sed 's/(.*//' | sed 's/^[ \\t]*//'");
|
||||
|
||||
// All non-NVIDIA cards / virtualization
|
||||
if (!(utils::exec(fmt::format(FMT_COMPILE("echo \"{}\" | grep -i 'intel\\|lenovo'"), graphics_card)).empty())) {
|
||||
install_intel();
|
||||
} else if (!(utils::exec(fmt::format(FMT_COMPILE("echo \"{}\" | grep -i 'ati'"), graphics_card)).empty())) {
|
||||
install_ati();
|
||||
} else if (driver == "video-nouveau") {
|
||||
utils::exec(fmt::format(FMT_COMPILE("sed -i 's/MODULES=\"\"/MODULES=\"nouveau\"/' {}/etc/mkinitcpio.conf"), mountpoint));
|
||||
}
|
||||
}
|
||||
|
||||
static void install_graphics_menu() noexcept {
|
||||
auto* config_instance = Config::instance();
|
||||
auto& config_data = config_instance->data();
|
||||
const auto& mountpoint = std::get<std::string>(config_data["MOUNTPOINT"]);
|
||||
|
||||
const std::vector<std::string> menu_entries = {
|
||||
"Auto-install free drivers",
|
||||
"Auto-install proprietary drivers",
|
||||
"Select Display Driver",
|
||||
// "Install all free drivers",
|
||||
"Back",
|
||||
};
|
||||
|
||||
auto screen = ScreenInteractive::Fullscreen();
|
||||
std::int32_t selected{};
|
||||
auto ok_callback = [&] {
|
||||
switch (selected) {
|
||||
case 0:
|
||||
utils::arch_chroot("mhwd -a pci free 0300");
|
||||
std::ofstream{fmt::format(FMT_COMPILE("{}/.video_installed"), mountpoint)};
|
||||
break;
|
||||
case 1:
|
||||
utils::arch_chroot("mhwd -a pci nonfree 0300");
|
||||
std::ofstream{fmt::format(FMT_COMPILE("{}/.video_installed"), mountpoint)};
|
||||
break;
|
||||
case 2:
|
||||
setup_graphics_card();
|
||||
break;
|
||||
/*case 3:
|
||||
install_all_drivers();
|
||||
std::ofstream{fmt::format(FMT_COMPILE("{}/.video_installed"), mountpoint)};
|
||||
break;*/
|
||||
default:
|
||||
screen.ExitLoopClosure()();
|
||||
break;
|
||||
}
|
||||
};
|
||||
detail::menu_widget(menu_entries, ok_callback, &selected, &screen);
|
||||
}
|
||||
|
||||
void install_drivers_menu() noexcept {
|
||||
const std::vector<std::string> menu_entries = {
|
||||
"Install Display Driver",
|
||||
//"Install Network Drivers",
|
||||
"Back",
|
||||
};
|
||||
|
||||
auto screen = ScreenInteractive::Fullscreen();
|
||||
std::int32_t selected{};
|
||||
auto ok_callback = [&] {
|
||||
switch (selected) {
|
||||
case 0:
|
||||
install_graphics_menu();
|
||||
break;
|
||||
/*case 1:
|
||||
setup_network_drivers();
|
||||
break;*/
|
||||
default:
|
||||
screen.ExitLoopClosure()();
|
||||
break;
|
||||
}
|
||||
};
|
||||
detail::menu_widget(menu_entries, ok_callback, &selected, &screen);
|
||||
}
|
||||
|
||||
} // namespace tui
|
8
src/drivers.hpp
Normal file
8
src/drivers.hpp
Normal file
@ -0,0 +1,8 @@
|
||||
#ifndef DRIVERS_HPP
|
||||
#define DRIVERS_HPP
|
||||
|
||||
namespace tui {
|
||||
void install_drivers_menu() noexcept;
|
||||
}
|
||||
|
||||
#endif // DRIVERS_HPP
|
248
src/misc.cpp
Normal file
248
src/misc.cpp
Normal file
@ -0,0 +1,248 @@
|
||||
#include "misc.hpp"
|
||||
#include "config.hpp"
|
||||
#include "utils.hpp"
|
||||
#include "widgets.hpp"
|
||||
|
||||
/* clang-format off */
|
||||
#include <filesystem> // for exists, is_directory
|
||||
#include <ftxui/component/component.hpp> // for Renderer, Button
|
||||
#include <ftxui/component/component_options.hpp> // for ButtonOption
|
||||
#include <ftxui/component/screen_interactive.hpp> // for Component, ScreenI...
|
||||
#include <ftxui/dom/elements.hpp> // for operator|, size
|
||||
/* clang-format on */
|
||||
|
||||
#include <fmt/compile.h>
|
||||
#include <fmt/core.h>
|
||||
|
||||
using namespace ftxui;
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
namespace tui {
|
||||
|
||||
// Revised to deal with partion sizes now being displayed to the user
|
||||
bool confirm_mount([[maybe_unused]] const std::string_view& part_user) {
|
||||
#ifdef NDEVENV
|
||||
const auto& ret_status = utils::exec(fmt::format(FMT_COMPILE("mount | grep {}"), part_user), true);
|
||||
if (ret_status != "0") {
|
||||
detail::infobox_widget("\nMount Failed!\n");
|
||||
std::this_thread::sleep_for(std::chrono::seconds(2));
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
auto* config_instance = Config::instance();
|
||||
auto& config_data = config_instance->data();
|
||||
const auto& partition = std::get<std::string>(config_data["PARTITION"]);
|
||||
auto& partitions = std::get<std::vector<std::string>>(config_data["PARTITIONS"]);
|
||||
auto& number_partitions = std::get<std::int32_t>(config_data["NUMBER_PARTITIONS"]);
|
||||
|
||||
detail::infobox_widget("\nMount Successful!\n");
|
||||
std::this_thread::sleep_for(std::chrono::seconds(2));
|
||||
|
||||
// TODO: reimplement natively
|
||||
const auto& str = utils::make_multiline(partitions);
|
||||
const auto& cmd = fmt::format(FMT_COMPILE("echo \"{0}\" | sed \"s~{1} [0-9]*[G-M]~~\" | sed \"s~{1} [0-9]*\\.[0-9]*[G-M]~~\" | sed \"s~{1}$\' -\'~~\""), str, partition);
|
||||
const auto& res_text = utils::exec(cmd);
|
||||
partitions = utils::make_multiline(res_text);
|
||||
number_partitions -= 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Fsck hook
|
||||
void set_fsck_hook() noexcept {
|
||||
auto* config_instance = Config::instance();
|
||||
auto& config_data = config_instance->data();
|
||||
const auto& do_sethook = detail::yesno_widget("\nDo you want to use fsck hook?\n", size(HEIGHT, LESS_THAN, 15) | size(WIDTH, LESS_THAN, 75));
|
||||
config_data["FSCK_HOOK"] = do_sethook;
|
||||
}
|
||||
|
||||
// Choose pacman cache
|
||||
void set_cache() noexcept {
|
||||
auto* config_instance = Config::instance();
|
||||
auto& config_data = config_instance->data();
|
||||
|
||||
static constexpr auto content = "\nDo you want to use the pacman cache of the running system instead\nof the installation target?\nThis can reduce the size of the required downloads in the installation.\n";
|
||||
if (!detail::yesno_widget(content, size(HEIGHT, GREATER_THAN, 3))) {
|
||||
config_data["hostcache"] = 0;
|
||||
config_data["cachepath"] = "/mnt/var/cache/pacman/pkg/";
|
||||
return;
|
||||
}
|
||||
|
||||
config_data["hostcache"] = 1;
|
||||
config_data["cachepath"] = "/var/cache/pacman/pkg/";
|
||||
}
|
||||
|
||||
static void edit_mkinitcpio(ScreenInteractive& screen) noexcept {
|
||||
#ifdef NDEVENV
|
||||
auto* config_instance = Config::instance();
|
||||
auto& config_data = config_instance->data();
|
||||
const auto& mountpoint = std::get<std::string>(config_data["MOUNTPOINT"]);
|
||||
#else
|
||||
const std::string& mountpoint = "/";
|
||||
#endif
|
||||
|
||||
utils::exec(fmt::format(FMT_COMPILE("vim \"{}/etc/mkinitcpio.conf\""), mountpoint), true);
|
||||
screen.Resume();
|
||||
|
||||
static constexpr auto content = "\nRun mkinitcpio?\n";
|
||||
const auto& do_run = detail::yesno_widget(content, size(HEIGHT, LESS_THAN, 2) | size(WIDTH, LESS_THAN, 40));
|
||||
if (do_run) {
|
||||
utils::arch_chroot("mkinitcpio -P");
|
||||
}
|
||||
screen.Suspend();
|
||||
}
|
||||
|
||||
static void edit_grub(ScreenInteractive& screen) noexcept {
|
||||
#ifdef NDEVENV
|
||||
auto* config_instance = Config::instance();
|
||||
auto& config_data = config_instance->data();
|
||||
const auto& mountpoint = std::get<std::string>(config_data["MOUNTPOINT"]);
|
||||
#else
|
||||
const std::string& mountpoint = "/";
|
||||
#endif
|
||||
|
||||
utils::exec(fmt::format(FMT_COMPILE("vim \"{}/etc/default/grub\""), mountpoint), true);
|
||||
screen.Resume();
|
||||
|
||||
static constexpr auto content = "\nUpdate GRUB?\n";
|
||||
const auto& do_update = detail::yesno_widget(content, size(HEIGHT, LESS_THAN, 2) | size(WIDTH, LESS_THAN, 40));
|
||||
if (do_update) {
|
||||
utils::grub_mkconfig();
|
||||
}
|
||||
screen.Suspend();
|
||||
}
|
||||
|
||||
void edit_configs() noexcept {
|
||||
auto* config_instance = Config::instance();
|
||||
auto& config_data = config_instance->data();
|
||||
const auto& uefi_mount = std::get<std::string>(config_data["UEFI_MOUNT"]);
|
||||
#ifdef NDEVENV
|
||||
const auto& mountpoint = std::get<std::string>(config_data["MOUNTPOINT"]);
|
||||
#else
|
||||
const std::string& mountpoint = "/";
|
||||
#endif
|
||||
|
||||
// Clear the file variables
|
||||
std::vector<std::string> menu_entries{};
|
||||
std::vector<std::function<void()>> functions{};
|
||||
menu_entries.reserve(24);
|
||||
functions.reserve(24);
|
||||
const auto& check_and_add = [&](
|
||||
const std::string& file_path, const std::string& dir = "",
|
||||
bool is_custom = false, std::function<void()>&& cust_func = []() {}) {
|
||||
const auto& append_function = [&functions](const std::string& filename) {
|
||||
/* clang-format off */
|
||||
functions.push_back([filename]{ utils::exec(fmt::format(FMT_COMPILE("vim {}"), filename), true); });
|
||||
/* clang-format on */
|
||||
};
|
||||
/* clang-format off */
|
||||
if (!fs::exists(file_path)) { return; }
|
||||
if (dir.empty()) { menu_entries.push_back(fmt::format(FMT_COMPILE("{}"), fs::path{file_path}.filename().c_str())); }
|
||||
else menu_entries.push_back(fmt::format(FMT_COMPILE("{} {}"), fs::path{file_path}.filename().c_str(), dir.data()));
|
||||
|
||||
if (!is_custom) { append_function(file_path); }
|
||||
else functions.push_back([cust_func]{ cust_func(); });
|
||||
/* clang-format on */
|
||||
};
|
||||
|
||||
{
|
||||
const auto& home_entry = fmt::format(FMT_COMPILE("{}/home"), mountpoint);
|
||||
if (fs::exists(home_entry))
|
||||
for (const auto& dir_entry : fs::directory_iterator{home_entry}) {
|
||||
const auto& extend_xinit_conf = fmt::format(FMT_COMPILE("{}/.extend.xinitrc"), dir_entry.path().c_str());
|
||||
const auto& extend_xres_conf = fmt::format(FMT_COMPILE("{}/.extend.Xresources"), dir_entry.path().c_str());
|
||||
const auto& xinit_conf = fmt::format(FMT_COMPILE("{}/.xinitrc"), dir_entry.path().c_str());
|
||||
const auto& xres_conf = fmt::format(FMT_COMPILE("{}/.Xresources"), dir_entry.path().c_str());
|
||||
check_and_add(extend_xinit_conf, dir_entry.path().filename());
|
||||
check_and_add(xinit_conf, dir_entry.path().filename());
|
||||
check_and_add(extend_xres_conf, dir_entry.path().filename());
|
||||
check_and_add(xres_conf, dir_entry.path().filename());
|
||||
}
|
||||
}
|
||||
|
||||
const std::array local_paths{
|
||||
fmt::format(FMT_COMPILE("{}/etc/crypttab"), mountpoint),
|
||||
fmt::format(FMT_COMPILE("{}/etc/fstab"), mountpoint),
|
||||
fmt::format(FMT_COMPILE("{}/boot/refind_linux.conf"), mountpoint),
|
||||
fmt::format(FMT_COMPILE("{}{}/EFI/refind/refind_linux.conf"), mountpoint, uefi_mount),
|
||||
fmt::format(FMT_COMPILE("{}{}/loader/loader.conf"), mountpoint, uefi_mount),
|
||||
fmt::format(FMT_COMPILE("{}/etc/hostname"), mountpoint),
|
||||
fmt::format(FMT_COMPILE("{}/etc/hosts"), mountpoint),
|
||||
fmt::format(FMT_COMPILE("{}/etc/systemd/journald.conf"), mountpoint),
|
||||
fmt::format(FMT_COMPILE("{}/etc/conf.d/keymaps"), mountpoint),
|
||||
fmt::format(FMT_COMPILE("{}/etc/locale.conf"), mountpoint),
|
||||
fmt::format(FMT_COMPILE("{}/etc/lightdm/lightdm.conf"), mountpoint),
|
||||
fmt::format(FMT_COMPILE("{}/etc/lxdm/lxdm.conf"), mountpoint),
|
||||
fmt::format(FMT_COMPILE("{}/etc/rc.conf"), mountpoint),
|
||||
fmt::format(FMT_COMPILE("{}/etc/pacman.conf"), mountpoint),
|
||||
fmt::format(FMT_COMPILE("{}/etc/makepkg.conf"), mountpoint),
|
||||
fmt::format(FMT_COMPILE("{}/etc/sddm.conf"), mountpoint),
|
||||
fmt::format(FMT_COMPILE("{}/etc/sudoers.conf"), mountpoint),
|
||||
fmt::format(FMT_COMPILE("{}/boot/syslinux/syslinux.cfg"), mountpoint),
|
||||
fmt::format(FMT_COMPILE("{}/etc/vconsole.conf"), mountpoint),
|
||||
fmt::format(FMT_COMPILE("{}/etc/default/grub"), mountpoint),
|
||||
fmt::format(FMT_COMPILE("{}/etc/mkinitcpio.conf"), mountpoint)};
|
||||
|
||||
for (size_t i = 0; i < local_paths.size() - 2; ++i) {
|
||||
check_and_add(local_paths[i]);
|
||||
}
|
||||
|
||||
auto screen = ScreenInteractive::Fullscreen();
|
||||
check_and_add(local_paths[19], "", true, [&screen] { edit_grub(screen); });
|
||||
check_and_add(local_paths[20], "", true, [&screen] { edit_mkinitcpio(screen); });
|
||||
|
||||
std::int32_t selected{};
|
||||
auto ok_callback = [&] {
|
||||
screen.Suspend();
|
||||
functions[static_cast<std::size_t>(selected)]();
|
||||
screen.Resume();
|
||||
};
|
||||
static constexpr auto seeconf_body = "\nSelect any file listed below to be reviewed or amended.\n";
|
||||
const auto& content_size = size(HEIGHT, GREATER_THAN, 10) | size(WIDTH, GREATER_THAN, 40) | vscroll_indicator | yframe | flex;
|
||||
detail::menu_widget(menu_entries, ok_callback, &selected, &screen, seeconf_body, {content_size, size(HEIGHT, GREATER_THAN, 1)});
|
||||
}
|
||||
|
||||
void logs_menu() noexcept {
|
||||
#ifdef NDEVENV
|
||||
auto* config_instance = Config::instance();
|
||||
auto& config_data = config_instance->data();
|
||||
const auto& mountpoint = std::get<std::string>(config_data["MOUNTPOINT"]);
|
||||
#else
|
||||
const std::string& mountpoint = "/";
|
||||
#endif
|
||||
|
||||
const std::vector<std::string> menu_entries = {
|
||||
"Dmesg",
|
||||
"Pacman log",
|
||||
"Xorg log",
|
||||
"Journalctl",
|
||||
"Back",
|
||||
};
|
||||
|
||||
auto screen = ScreenInteractive::Fullscreen();
|
||||
std::int32_t selected{};
|
||||
auto ok_callback = [&] {
|
||||
screen.Suspend();
|
||||
switch (selected) {
|
||||
case 0:
|
||||
utils::exec(fmt::format(FMT_COMPILE("arch-chroot {} dmesg | fzf --reverse --header=\"Exit by pressing esc\" --prompt=\"Type to filter log entries > \""), mountpoint), true);
|
||||
break;
|
||||
case 1:
|
||||
utils::exec(fmt::format(FMT_COMPILE("fzf --reverse --header=\"Exit by pressing esc\" --prompt=\"Type to filter log entries > \" < {}/var/log/pacman.log"), mountpoint), true);
|
||||
break;
|
||||
case 2:
|
||||
utils::exec(fmt::format(FMT_COMPILE("fzf --reverse --header=\"Exit by pressing esc\" --prompt=\"Type to filter log entries > \" < {}/var/log/Xorg.0.log"), mountpoint), true);
|
||||
break;
|
||||
case 3:
|
||||
utils::exec(fmt::format(FMT_COMPILE("arch-chroot {} journalctl | fzf --reverse --header=\"Exit by pressing esc\" --prompt=\"Type to filter log entries > \""), mountpoint), true);
|
||||
break;
|
||||
default:
|
||||
screen.Resume();
|
||||
screen.ExitLoopClosure()();
|
||||
return;
|
||||
}
|
||||
screen.Resume();
|
||||
};
|
||||
detail::menu_widget(menu_entries, ok_callback, &selected, &screen);
|
||||
}
|
||||
|
||||
} // namespace tui
|
14
src/misc.hpp
Normal file
14
src/misc.hpp
Normal file
@ -0,0 +1,14 @@
|
||||
#ifndef MISC_HPP
|
||||
#define MISC_HPP
|
||||
|
||||
#include <string_view>
|
||||
|
||||
namespace tui {
|
||||
bool confirm_mount([[maybe_unused]] const std::string_view& part_user);
|
||||
void set_fsck_hook() noexcept;
|
||||
void set_cache() noexcept;
|
||||
void edit_configs() noexcept;
|
||||
void logs_menu() noexcept;
|
||||
} // namespace tui
|
||||
|
||||
#endif // MISC_HPP
|
92
src/tui.cpp
92
src/tui.cpp
@ -3,6 +3,8 @@
|
||||
#include "crypto.hpp"
|
||||
#include "definitions.hpp"
|
||||
#include "disk.hpp"
|
||||
#include "drivers.hpp"
|
||||
#include "misc.hpp"
|
||||
#include "utils.hpp"
|
||||
#include "widgets.hpp"
|
||||
|
||||
@ -13,7 +15,6 @@
|
||||
#include <regex> // for regex_search, match_results<>::_Base_type
|
||||
#include <string> // for basic_string
|
||||
#include <ftxui/component/component.hpp> // for Renderer, Button
|
||||
#include <ftxui/component/component_options.hpp> // for ButtonOption
|
||||
#include <ftxui/component/screen_interactive.hpp> // for Component, ScreenI...
|
||||
#include <ftxui/dom/elements.hpp> // for operator|, size
|
||||
/* clang-format on */
|
||||
@ -39,58 +40,6 @@ namespace ranges = std::ranges;
|
||||
|
||||
namespace tui {
|
||||
|
||||
// Revised to deal with partion sizes now being displayed to the user
|
||||
bool confirm_mount([[maybe_unused]] const std::string_view& part_user) {
|
||||
#ifdef NDEVENV
|
||||
const auto& ret_status = utils::exec(fmt::format(FMT_COMPILE("mount | grep {}"), part_user), true);
|
||||
if (ret_status != "0") {
|
||||
detail::infobox_widget("\nMount Failed!\n");
|
||||
std::this_thread::sleep_for(std::chrono::seconds(2));
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
auto* config_instance = Config::instance();
|
||||
auto& config_data = config_instance->data();
|
||||
const auto& partition = std::get<std::string>(config_data["PARTITION"]);
|
||||
auto& partitions = std::get<std::vector<std::string>>(config_data["PARTITIONS"]);
|
||||
auto& number_partitions = std::get<std::int32_t>(config_data["NUMBER_PARTITIONS"]);
|
||||
|
||||
detail::infobox_widget("\nMount Successful!\n");
|
||||
std::this_thread::sleep_for(std::chrono::seconds(2));
|
||||
|
||||
// TODO: reimplement natively
|
||||
const auto& str = utils::make_multiline(partitions);
|
||||
const auto& cmd = fmt::format(FMT_COMPILE("echo \"{0}\" | sed \"s~{1} [0-9]*[G-M]~~\" | sed \"s~{1} [0-9]*\\.[0-9]*[G-M]~~\" | sed \"s~{1}$\' -\'~~\""), str, partition);
|
||||
const auto& res_text = utils::exec(cmd);
|
||||
partitions = utils::make_multiline(res_text);
|
||||
number_partitions -= 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Fsck hook
|
||||
void set_fsck_hook() noexcept {
|
||||
auto* config_instance = Config::instance();
|
||||
auto& config_data = config_instance->data();
|
||||
const auto& do_sethook = detail::yesno_widget("\nDo you want to use fsck hook?\n", size(HEIGHT, LESS_THAN, 15) | size(WIDTH, LESS_THAN, 75));
|
||||
config_data["FSCK_HOOK"] = do_sethook;
|
||||
}
|
||||
|
||||
// Choose pacman cache
|
||||
void set_cache() noexcept {
|
||||
auto* config_instance = Config::instance();
|
||||
auto& config_data = config_instance->data();
|
||||
|
||||
static constexpr auto content = "\nDo you want to use the pacman cache of the running system instead\nof the installation target?\nThis can reduce the size of the required downloads in the installation.\n";
|
||||
if (!detail::yesno_widget(content, size(HEIGHT, GREATER_THAN, 3))) {
|
||||
config_data["hostcache"] = 0;
|
||||
config_data["cachepath"] = "/mnt/var/cache/pacman/pkg/";
|
||||
return;
|
||||
}
|
||||
|
||||
config_data["hostcache"] = 1;
|
||||
config_data["cachepath"] = "/var/cache/pacman/pkg/";
|
||||
}
|
||||
|
||||
bool exit_done() noexcept {
|
||||
#ifdef NDEVENV
|
||||
auto* config_instance = Config::instance();
|
||||
@ -243,8 +192,6 @@ void set_locale() noexcept {
|
||||
screen.ExitLoopClosure()();
|
||||
};
|
||||
|
||||
// static constexpr auto timezone_body = "The time zone is used to correctly set your system clock.";
|
||||
// const auto& content_size = size(HEIGHT, GREATER_THAN, 10) | size(WIDTH, GREATER_THAN, 40);
|
||||
static constexpr auto langBody = "\nChoose the system language.\n\nThe format is language_COUNTRY (e.g. en_US is english, United States;\nen_GB is english, Great Britain).\n";
|
||||
const auto& content_size = size(HEIGHT, GREATER_THAN, 10) | size(WIDTH, GREATER_THAN, 40) | vscroll_indicator | yframe | flex;
|
||||
detail::menu_widget(locales, ok_callback, &selected, &screen, langBody, {content_size, size(HEIGHT, GREATER_THAN, 1)});
|
||||
@ -2100,10 +2047,7 @@ void install_core_menu() noexcept {
|
||||
if (!utils::check_base()) {
|
||||
screen.ExitLoopClosure()();
|
||||
}
|
||||
// screen.Suspend();
|
||||
// tui::edit_configs();
|
||||
// screen.Resume();
|
||||
|
||||
tui::edit_configs();
|
||||
break;
|
||||
case 7:
|
||||
if (!utils::check_base()) {
|
||||
@ -2139,6 +2083,13 @@ void system_rescue_menu() noexcept {
|
||||
std::int32_t selected{};
|
||||
auto ok_callback = [&] {
|
||||
switch (selected) {
|
||||
case 0:
|
||||
if (!utils::check_mount() && !utils::check_base()) {
|
||||
screen.ExitLoopClosure()();
|
||||
break;
|
||||
}
|
||||
tui::install_drivers_menu();
|
||||
break;
|
||||
case 1:
|
||||
if (!utils::check_mount() && !utils::check_base()) {
|
||||
screen.ExitLoopClosure()();
|
||||
@ -2154,12 +2105,33 @@ void system_rescue_menu() noexcept {
|
||||
tui::install_cust_pkgs();
|
||||
break;
|
||||
case 3:
|
||||
if (!utils::check_mount() && !utils::check_base()) {
|
||||
if (!utils::check_base()) {
|
||||
screen.ExitLoopClosure()();
|
||||
break;
|
||||
}
|
||||
tui::rm_pgs();
|
||||
break;
|
||||
case 4:
|
||||
if (!utils::check_base()) {
|
||||
screen.ExitLoopClosure()();
|
||||
}
|
||||
tui::edit_configs();
|
||||
break;
|
||||
case 5:
|
||||
if (!utils::check_base()) {
|
||||
screen.ExitLoopClosure()();
|
||||
}
|
||||
screen.Suspend();
|
||||
tui::chroot_interactive();
|
||||
screen.Resume();
|
||||
|
||||
break;
|
||||
case 7:
|
||||
if (!utils::check_base()) {
|
||||
screen.ExitLoopClosure()();
|
||||
}
|
||||
tui::logs_menu();
|
||||
break;
|
||||
default:
|
||||
screen.ExitLoopClosure()();
|
||||
break;
|
||||
|
@ -699,7 +699,7 @@ void parse_config() noexcept {
|
||||
for (auto entry : doc["steps"]) {
|
||||
std::string_view step;
|
||||
entry.get(step);
|
||||
spdlog::debug(step);
|
||||
// spdlog::debug(step);
|
||||
}
|
||||
}
|
||||
|
||||
@ -734,6 +734,11 @@ void setup_luks_keyfile() noexcept {
|
||||
}
|
||||
}
|
||||
|
||||
void grub_mkconfig() noexcept {
|
||||
utils::arch_chroot("grub-mkconfig -o /boot/grub/grub.cfg");
|
||||
// check_for_error "grub-mkconfig" $?
|
||||
}
|
||||
|
||||
void final_check() noexcept {
|
||||
auto* config_instance = Config::instance();
|
||||
auto& config_data = config_instance->data();
|
||||
|
@ -44,6 +44,7 @@ void set_keymap() noexcept;
|
||||
void enable_autologin(const std::string_view& dm, const std::string_view& user) noexcept;
|
||||
void parse_config() noexcept;
|
||||
void setup_luks_keyfile() noexcept;
|
||||
void grub_mkconfig() noexcept;
|
||||
void final_check() noexcept;
|
||||
|
||||
template <typename T = std::int32_t,
|
||||
|
Loading…
Reference in New Issue
Block a user