mirror of
https://github.com/CachyOS/New-Cli-Installer.git
synced 2025-01-23 14:32:22 +08:00
👷 update backward action
add new dependency - `glibmm`
This commit is contained in:
parent
0ead58d906
commit
928dbf1590
@ -29,6 +29,12 @@ pkg_check_modules(
|
||||
IMPORTED_TARGET
|
||||
libnm>=1.10.6)
|
||||
|
||||
pkg_check_modules(
|
||||
GLIBMM
|
||||
REQUIRED
|
||||
IMPORTED_TARGET
|
||||
glibmm-2.4>=2.60.0)
|
||||
|
||||
FetchContent_Declare(ftxui
|
||||
GIT_REPOSITORY "https://github.com/arthursonzogni/ftxui.git"
|
||||
GIT_TAG "cecd54df42dd66fdf8386ed461e16b725bffc827"
|
||||
@ -98,8 +104,8 @@ enable_sanitizers(project_options)
|
||||
|
||||
include_directories(${CMAKE_SOURCE_DIR}/src)
|
||||
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE project_warnings project_options fmt::fmt ftxui::screen ftxui::dom ftxui::component nlohmann_json::nlohmann_json cpr::cpr)
|
||||
target_link_libraries(test-exec-interactive PRIVATE project_warnings project_options fmt::fmt)
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE project_warnings project_options fmt::fmt ftxui::screen ftxui::dom ftxui::component nlohmann_json::nlohmann_json cpr::cpr PkgConfig::GLIBMM)
|
||||
target_link_libraries(test-exec-interactive PRIVATE project_warnings project_options fmt::fmt PkgConfig::GLIBMM)
|
||||
|
||||
option(ENABLE_UNITY "Enable Unity builds of projects" OFF)
|
||||
if(ENABLE_UNITY)
|
||||
|
@ -37,6 +37,7 @@ ftxui = dependency('ftxui', modules : ['ftxui::screen', 'ftxui::dom', 'ftxui::co
|
||||
nlohmann_json = dependency('nlohmann_json', version : ['>=3.10.4'], fallback : ['nlohmann_json', 'nlohmann_json_dep'])
|
||||
cpr = dependency('cpr', version : ['>=1.7.0'], fallback : ['cpr', 'cpr_dep'])
|
||||
libnm = dependency('libnm', version : ['>=1.10.6'])
|
||||
glibmm = dependency('glibmm-2.4', version : ['>=2.60.0'])
|
||||
|
||||
src_files = files(
|
||||
'src/view.hpp',
|
||||
@ -99,14 +100,14 @@ add_project_arguments(cc.get_supported_arguments(possible_cc_flags), language :
|
||||
executable(
|
||||
'cachyos-installer',
|
||||
src_files,
|
||||
dependencies: [fmt, ftxui, nlohmann_json, cpr],
|
||||
dependencies: [fmt, ftxui, nlohmann_json, cpr, glibmm],
|
||||
include_directories: [include_directories('src')],
|
||||
install: true)
|
||||
|
||||
executable(
|
||||
'test-exec-interactive',
|
||||
files('src/config.cpp', 'src/utils.cpp', 'src/main_test.cpp'),
|
||||
dependencies: [fmt],
|
||||
dependencies: [fmt, glibmm],
|
||||
include_directories: [include_directories('src')],
|
||||
install: false)
|
||||
|
||||
|
@ -32,10 +32,6 @@ int main() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!tui::screen_service::initialize()) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
// auto app_router = std::make_shared<router>(tui::screen_service::instance());
|
||||
// app_router->navigate("", std::any());
|
||||
tui::init();
|
||||
|
55
src/tui.cpp
55
src/tui.cpp
@ -1,10 +1,10 @@
|
||||
#include "tui.hpp"
|
||||
#include "config.hpp"
|
||||
#include "definitions.hpp"
|
||||
#include "screen_service.hpp"
|
||||
#include "utils.hpp"
|
||||
|
||||
/* clang-format off */
|
||||
#include <csignal> // for raise
|
||||
#include <algorithm> // for transform
|
||||
#include <memory> // for __shared_ptr_access
|
||||
#include <string> // for basic_string
|
||||
@ -117,7 +117,7 @@ void auto_partition() noexcept {
|
||||
// Show created partitions
|
||||
auto disklist = utils::exec(fmt::format("lsblk {} -o NAME,TYPE,FSTYPE,SIZE", config_data["DEVICE"]));
|
||||
|
||||
auto& screen = tui::screen_service::instance()->data();
|
||||
auto screen = ScreenInteractive::Fullscreen();
|
||||
/* clang-format off */
|
||||
auto button_option = ButtonOption();
|
||||
button_option.border = false;
|
||||
@ -137,7 +137,7 @@ void auto_partition() noexcept {
|
||||
|
||||
// Simple code to show devices / partitions.
|
||||
void show_devices() noexcept {
|
||||
auto& screen = tui::screen_service::instance()->data();
|
||||
auto screen = ScreenInteractive::Fullscreen();
|
||||
auto lsblk = utils::exec("lsblk -o NAME,MODEL,TYPE,FSTYPE,SIZE,MOUNTPOINT | grep \"disk\\|part\\|lvm\\|crypt\\|NAME\\|MODEL\\|TYPE\\|FSTYPE\\|SIZE\\|MOUNTPOINT\"");
|
||||
|
||||
/* clang-format off */
|
||||
@ -159,23 +159,27 @@ void show_devices() noexcept {
|
||||
|
||||
// This function does not assume that the formatted device is the Root installation device as
|
||||
// more than one device may be formatted. Root is set in the mount_partitions function.
|
||||
void select_device() noexcept {
|
||||
bool select_device() noexcept {
|
||||
auto* config_instance = Config::instance();
|
||||
auto& config_data = config_instance->data();
|
||||
auto devices = utils::exec("lsblk -lno NAME,SIZE,TYPE | grep 'disk' | awk '{print \"/dev/\" $1 \" \" $2}' | sort -u");
|
||||
const auto& devices_list = utils::make_multiline(devices);
|
||||
|
||||
auto& screen = tui::screen_service::instance()->data();
|
||||
auto screen = ScreenInteractive::Fullscreen();
|
||||
std::int32_t selected{};
|
||||
auto menu = Menu(&devices_list, &selected);
|
||||
auto content = Renderer(menu, [&] {
|
||||
return menu->Render() | center | size(HEIGHT, GREATER_THAN, 10) | size(WIDTH, GREATER_THAN, 40);
|
||||
});
|
||||
|
||||
bool success = false;
|
||||
auto ok_callback = [&] {
|
||||
auto src = devices_list[static_cast<std::size_t>(selected)];
|
||||
const auto& lines = utils::make_multiline(src, " ");
|
||||
config_data["DEVICE"] = lines[0];
|
||||
success = true;
|
||||
screen.ExitLoopClosure();
|
||||
std::raise(SIGINT);
|
||||
};
|
||||
|
||||
ButtonOption button_option{.border = false};
|
||||
@ -196,6 +200,8 @@ void select_device() noexcept {
|
||||
});
|
||||
|
||||
screen.Loop(renderer);
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
void create_partitions() noexcept {
|
||||
@ -215,7 +221,7 @@ void create_partitions() noexcept {
|
||||
"parted",
|
||||
};
|
||||
|
||||
auto& screen = tui::screen_service::instance()->data();
|
||||
auto screen = ScreenInteractive::Fullscreen();
|
||||
std::int32_t selected{};
|
||||
auto menu = Menu(&menu_entries, &selected);
|
||||
auto content = Renderer(menu, [&] {
|
||||
@ -282,7 +288,7 @@ void prep_menu() noexcept {
|
||||
"Back",
|
||||
};
|
||||
|
||||
auto& screen = tui::screen_service::instance()->data();
|
||||
auto screen = ScreenInteractive::Fullscreen();
|
||||
std::int32_t selected{};
|
||||
auto menu = Menu(&menu_entries, &selected);
|
||||
auto content = Renderer(menu, [&] {
|
||||
@ -290,21 +296,22 @@ void prep_menu() noexcept {
|
||||
});
|
||||
|
||||
auto ok_callback = [&] {
|
||||
const auto& temp = selected + 1;
|
||||
switch (temp) {
|
||||
case 1:
|
||||
switch (selected) {
|
||||
case 0:
|
||||
error("Implement me!\n");
|
||||
break;
|
||||
case 2:
|
||||
case 1:
|
||||
tui::show_devices();
|
||||
break;
|
||||
|
||||
case 3: {
|
||||
case 2: {
|
||||
utils::umount_partitions();
|
||||
tui::select_device();
|
||||
if (tui::select_device()) {
|
||||
tui::create_partitions();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
case 4:
|
||||
case 5:
|
||||
case 6:
|
||||
@ -313,12 +320,11 @@ void prep_menu() noexcept {
|
||||
case 9:
|
||||
case 10:
|
||||
case 11:
|
||||
case 12:
|
||||
error("Implement me!\n");
|
||||
break;
|
||||
default:
|
||||
screen.Clear();
|
||||
screen.ExitLoopClosure();
|
||||
std::raise(SIGINT);
|
||||
break;
|
||||
}
|
||||
};
|
||||
@ -353,7 +359,7 @@ void init() noexcept {
|
||||
"Done",
|
||||
};
|
||||
|
||||
auto& screen = tui::screen_service::instance()->data();
|
||||
auto screen = ScreenInteractive::Fullscreen();
|
||||
std::int32_t selected{};
|
||||
auto menu = Menu(&menu_entries, &selected);
|
||||
auto content = Renderer(menu, [&] {
|
||||
@ -361,36 +367,37 @@ void init() noexcept {
|
||||
});
|
||||
|
||||
auto ok_callback = [&] {
|
||||
const auto& temp = selected + 1;
|
||||
switch (temp) {
|
||||
case 1:
|
||||
switch (selected) {
|
||||
case 0:
|
||||
tui::prep_menu();
|
||||
break;
|
||||
case 2: {
|
||||
case 1: {
|
||||
if (!utils::check_mount()) {
|
||||
screen.ExitLoopClosure();
|
||||
std::raise(SIGINT);
|
||||
}
|
||||
tui::install_desktop_system_menu();
|
||||
break;
|
||||
}
|
||||
case 3: {
|
||||
case 2: {
|
||||
if (!utils::check_mount()) {
|
||||
screen.ExitLoopClosure();
|
||||
std::raise(SIGINT);
|
||||
}
|
||||
tui::install_core_menu();
|
||||
break;
|
||||
}
|
||||
case 4: {
|
||||
case 3: {
|
||||
utils::check_mount();
|
||||
tui::install_custom_menu();
|
||||
break;
|
||||
}
|
||||
case 5:
|
||||
case 4:
|
||||
tui::system_rescue_menu();
|
||||
break;
|
||||
default:
|
||||
screen.Clear();
|
||||
screen.ExitLoopClosure();
|
||||
std::raise(SIGINT);
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user