👷 update backward action

add new dependency - `glibmm`
This commit is contained in:
Vladislav Nepogodin 2021-12-06 02:32:14 +04:00
parent 0ead58d906
commit 928dbf1590
No known key found for this signature in database
GPG Key ID: B62C3D10C54D5DA9
4 changed files with 44 additions and 34 deletions

View File

@ -29,6 +29,12 @@ pkg_check_modules(
IMPORTED_TARGET IMPORTED_TARGET
libnm>=1.10.6) libnm>=1.10.6)
pkg_check_modules(
GLIBMM
REQUIRED
IMPORTED_TARGET
glibmm-2.4>=2.60.0)
FetchContent_Declare(ftxui FetchContent_Declare(ftxui
GIT_REPOSITORY "https://github.com/arthursonzogni/ftxui.git" GIT_REPOSITORY "https://github.com/arthursonzogni/ftxui.git"
GIT_TAG "cecd54df42dd66fdf8386ed461e16b725bffc827" GIT_TAG "cecd54df42dd66fdf8386ed461e16b725bffc827"
@ -98,8 +104,8 @@ enable_sanitizers(project_options)
include_directories(${CMAKE_SOURCE_DIR}/src) 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(${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) target_link_libraries(test-exec-interactive PRIVATE project_warnings project_options fmt::fmt PkgConfig::GLIBMM)
option(ENABLE_UNITY "Enable Unity builds of projects" OFF) option(ENABLE_UNITY "Enable Unity builds of projects" OFF)
if(ENABLE_UNITY) if(ENABLE_UNITY)

View File

@ -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']) 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']) cpr = dependency('cpr', version : ['>=1.7.0'], fallback : ['cpr', 'cpr_dep'])
libnm = dependency('libnm', version : ['>=1.10.6']) libnm = dependency('libnm', version : ['>=1.10.6'])
glibmm = dependency('glibmm-2.4', version : ['>=2.60.0'])
src_files = files( src_files = files(
'src/view.hpp', 'src/view.hpp',
@ -99,14 +100,14 @@ add_project_arguments(cc.get_supported_arguments(possible_cc_flags), language :
executable( executable(
'cachyos-installer', 'cachyos-installer',
src_files, src_files,
dependencies: [fmt, ftxui, nlohmann_json, cpr], dependencies: [fmt, ftxui, nlohmann_json, cpr, glibmm],
include_directories: [include_directories('src')], include_directories: [include_directories('src')],
install: true) install: true)
executable( executable(
'test-exec-interactive', 'test-exec-interactive',
files('src/config.cpp', 'src/utils.cpp', 'src/main_test.cpp'), files('src/config.cpp', 'src/utils.cpp', 'src/main_test.cpp'),
dependencies: [fmt], dependencies: [fmt, glibmm],
include_directories: [include_directories('src')], include_directories: [include_directories('src')],
install: false) install: false)

View File

@ -32,10 +32,6 @@ int main() {
return 0; return 0;
} }
if (!tui::screen_service::initialize()) {
return 1;
}
// auto app_router = std::make_shared<router>(tui::screen_service::instance()); // auto app_router = std::make_shared<router>(tui::screen_service::instance());
// app_router->navigate("", std::any()); // app_router->navigate("", std::any());
tui::init(); tui::init();

View File

@ -1,10 +1,10 @@
#include "tui.hpp" #include "tui.hpp"
#include "config.hpp" #include "config.hpp"
#include "definitions.hpp" #include "definitions.hpp"
#include "screen_service.hpp"
#include "utils.hpp" #include "utils.hpp"
/* clang-format off */ /* clang-format off */
#include <csignal> // for raise
#include <algorithm> // for transform #include <algorithm> // for transform
#include <memory> // for __shared_ptr_access #include <memory> // for __shared_ptr_access
#include <string> // for basic_string #include <string> // for basic_string
@ -117,7 +117,7 @@ void auto_partition() noexcept {
// Show created partitions // Show created partitions
auto disklist = utils::exec(fmt::format("lsblk {} -o NAME,TYPE,FSTYPE,SIZE", config_data["DEVICE"])); 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 */ /* clang-format off */
auto button_option = ButtonOption(); auto button_option = ButtonOption();
button_option.border = false; button_option.border = false;
@ -137,8 +137,8 @@ void auto_partition() noexcept {
// Simple code to show devices / partitions. // Simple code to show devices / partitions.
void show_devices() noexcept { 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\""); 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 */ /* clang-format off */
auto button_option = ButtonOption(); auto button_option = ButtonOption();
@ -159,23 +159,27 @@ void show_devices() noexcept {
// This function does not assume that the formatted device is the Root installation device as // 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. // 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_instance = Config::instance();
auto& config_data = config_instance->data(); auto& config_data = config_instance->data();
auto devices = utils::exec("lsblk -lno NAME,SIZE,TYPE | grep 'disk' | awk '{print \"/dev/\" $1 \" \" $2}' | sort -u"); 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); const auto& devices_list = utils::make_multiline(devices);
auto& screen = tui::screen_service::instance()->data(); auto screen = ScreenInteractive::Fullscreen();
std::int32_t selected{}; std::int32_t selected{};
auto menu = Menu(&devices_list, &selected); auto menu = Menu(&devices_list, &selected);
auto content = Renderer(menu, [&] { auto content = Renderer(menu, [&] {
return menu->Render() | center | size(HEIGHT, GREATER_THAN, 10) | size(WIDTH, GREATER_THAN, 40); return menu->Render() | center | size(HEIGHT, GREATER_THAN, 10) | size(WIDTH, GREATER_THAN, 40);
}); });
bool success = false;
auto ok_callback = [&] { auto ok_callback = [&] {
auto src = devices_list[static_cast<std::size_t>(selected)]; auto src = devices_list[static_cast<std::size_t>(selected)];
const auto& lines = utils::make_multiline(src, " "); const auto& lines = utils::make_multiline(src, " ");
config_data["DEVICE"] = lines[0]; config_data["DEVICE"] = lines[0];
success = true;
screen.ExitLoopClosure();
std::raise(SIGINT);
}; };
ButtonOption button_option{.border = false}; ButtonOption button_option{.border = false};
@ -196,6 +200,8 @@ void select_device() noexcept {
}); });
screen.Loop(renderer); screen.Loop(renderer);
return success;
} }
void create_partitions() noexcept { void create_partitions() noexcept {
@ -215,7 +221,7 @@ void create_partitions() noexcept {
"parted", "parted",
}; };
auto& screen = tui::screen_service::instance()->data(); auto screen = ScreenInteractive::Fullscreen();
std::int32_t selected{}; std::int32_t selected{};
auto menu = Menu(&menu_entries, &selected); auto menu = Menu(&menu_entries, &selected);
auto content = Renderer(menu, [&] { auto content = Renderer(menu, [&] {
@ -282,7 +288,7 @@ void prep_menu() noexcept {
"Back", "Back",
}; };
auto& screen = tui::screen_service::instance()->data(); auto screen = ScreenInteractive::Fullscreen();
std::int32_t selected{}; std::int32_t selected{};
auto menu = Menu(&menu_entries, &selected); auto menu = Menu(&menu_entries, &selected);
auto content = Renderer(menu, [&] { auto content = Renderer(menu, [&] {
@ -290,21 +296,22 @@ void prep_menu() noexcept {
}); });
auto ok_callback = [&] { auto ok_callback = [&] {
const auto& temp = selected + 1; switch (selected) {
switch (temp) { case 0:
case 1:
error("Implement me!\n"); error("Implement me!\n");
break; break;
case 2: case 1:
tui::show_devices(); tui::show_devices();
break; break;
case 3: { case 2: {
utils::umount_partitions(); utils::umount_partitions();
tui::select_device(); if (tui::select_device()) {
tui::create_partitions(); tui::create_partitions();
}
break; break;
} }
case 3:
case 4: case 4:
case 5: case 5:
case 6: case 6:
@ -313,12 +320,11 @@ void prep_menu() noexcept {
case 9: case 9:
case 10: case 10:
case 11: case 11:
case 12:
error("Implement me!\n"); error("Implement me!\n");
break; break;
default: default:
screen.Clear();
screen.ExitLoopClosure(); screen.ExitLoopClosure();
std::raise(SIGINT);
break; break;
} }
}; };
@ -353,7 +359,7 @@ void init() noexcept {
"Done", "Done",
}; };
auto& screen = tui::screen_service::instance()->data(); auto screen = ScreenInteractive::Fullscreen();
std::int32_t selected{}; std::int32_t selected{};
auto menu = Menu(&menu_entries, &selected); auto menu = Menu(&menu_entries, &selected);
auto content = Renderer(menu, [&] { auto content = Renderer(menu, [&] {
@ -361,36 +367,37 @@ void init() noexcept {
}); });
auto ok_callback = [&] { auto ok_callback = [&] {
const auto& temp = selected + 1; switch (selected) {
switch (temp) { case 0:
case 1:
tui::prep_menu(); tui::prep_menu();
break; break;
case 2: { case 1: {
if (!utils::check_mount()) { if (!utils::check_mount()) {
screen.ExitLoopClosure(); screen.ExitLoopClosure();
std::raise(SIGINT);
} }
tui::install_desktop_system_menu(); tui::install_desktop_system_menu();
break; break;
} }
case 3: { case 2: {
if (!utils::check_mount()) { if (!utils::check_mount()) {
screen.ExitLoopClosure(); screen.ExitLoopClosure();
std::raise(SIGINT);
} }
tui::install_core_menu(); tui::install_core_menu();
break; break;
} }
case 4: { case 3: {
utils::check_mount(); utils::check_mount();
tui::install_custom_menu(); tui::install_custom_menu();
break; break;
} }
case 5: case 4:
tui::system_rescue_menu(); tui::system_rescue_menu();
break; break;
default: default:
screen.Clear();
screen.ExitLoopClosure(); screen.ExitLoopClosure();
std::raise(SIGINT);
break; break;
} }
}; };