👷 add ability to edit pacman config from UI

This commit is contained in:
Vladislav Nepogodin 2022-02-21 04:12:20 +04:00
parent d8ba5238e6
commit 3131a44da1
No known key found for this signature in database
GPG Key ID: B62C3D10C54D5DA9
4 changed files with 45 additions and 4 deletions

View File

@ -80,10 +80,9 @@ Main Menu
| ├── LUKS Encryption
| ├── Logical Volume Management (WIP)
| ├── Mount Partitions
| ├── Configure Installer Mirrorlist (TODO)
| ├── Configure Installer Mirrorlist
| | ├── Edit Pacman Configuration
| | ├── Edit Pacman Mirror Configuration
| | └── Rank Mirrors by Speed
| | └── Rank Mirrors by Speed (TODO)
| |
│ └── Refresh Pacman Keys
|

View File

@ -201,6 +201,16 @@ void edit_configs() noexcept {
detail::menu_widget(menu_entries, ok_callback, &selected, &screen, seeconf_body, {content_size, size(HEIGHT, GREATER_THAN, 1)});
}
void edit_pacman_conf() noexcept {
utils::exec("vim /etc/pacman.conf", true);
#ifdef NDEVENV
// NOTE: don't care now, Will change in future..
detail::infobox_widget("\nUpdating database ...\n");
utils::exec("pacman -Syy", true);
#endif
}
void logs_menu() noexcept {
#ifdef NDEVENV
auto* config_instance = Config::instance();

View File

@ -8,6 +8,7 @@ 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 edit_pacman_conf() noexcept;
void logs_menu() noexcept;
} // namespace tui

View File

@ -1974,6 +1974,35 @@ void mount_partitions() noexcept {
}
}
void configure_mirrorlist() noexcept {
const std::vector<std::string> menu_entries = {
"Edit Pacman Configuration",
"Rank mirrors by speed",
"Back",
};
auto screen = ScreenInteractive::Fullscreen();
std::int32_t selected{};
auto ok_callback = [&] {
switch (selected) {
case 0:
screen.Suspend();
tui::edit_pacman_conf();
screen.Resume();
break;
case 1:
SPDLOG_ERROR("Implement me!");
break;
default:
screen.ExitLoopClosure()();
break;
}
};
static constexpr auto mirrorlist_body = "\nThe pacman configuration file can be edited\nto enable multilib and other repositories.\n";
const auto& content_size = size(HEIGHT, LESS_THAN, 10) | size(WIDTH, GREATER_THAN, 40);
detail::menu_widget(menu_entries, ok_callback, &selected, &screen, mirrorlist_body, {size(HEIGHT, LESS_THAN, 3), content_size});
}
void create_partitions() noexcept {
static constexpr std::string_view optwipe = "Securely Wipe Device (optional)";
static constexpr std::string_view optauto = "Automatic Partitioning";
@ -2215,9 +2244,11 @@ void prep_menu() noexcept {
case 3:
case 4:
case 6:
case 8:
SPDLOG_ERROR("Implement me!");
break;
case 8:
tui::configure_mirrorlist();
break;
case 9:
#ifdef NDEVENV
utils::arch_chroot("pacman-key --init;pacman-key --populate archlinux cachyos;pacman-key --refresh-keys;");