mirror of
https://github.com/CachyOS/New-Cli-Installer.git
synced 2025-02-02 22:07:13 +08:00
👷 gucc: add exec_checked to io_utils
This commit is contained in:
parent
ccc4f6c459
commit
1492d40efe
@ -10,6 +10,7 @@ namespace gucc::utils {
|
|||||||
auto safe_getenv(const char* env_name) noexcept -> std::string_view;
|
auto safe_getenv(const char* env_name) noexcept -> std::string_view;
|
||||||
void exec(const std::vector<std::string>& vec) noexcept;
|
void exec(const std::vector<std::string>& vec) noexcept;
|
||||||
auto exec(std::string_view command, bool interactive = false) noexcept -> std::string;
|
auto exec(std::string_view command, bool interactive = false) noexcept -> std::string;
|
||||||
|
auto exec_checked(std::string_view command) noexcept -> bool;
|
||||||
void arch_chroot(std::string_view command, std::string_view mountpoint, bool interactive = false) noexcept;
|
void arch_chroot(std::string_view command, std::string_view mountpoint, bool interactive = false) noexcept;
|
||||||
auto arch_chroot_checked(std::string_view command, std::string_view mountpoint) noexcept -> bool;
|
auto arch_chroot_checked(std::string_view command, std::string_view mountpoint) noexcept -> bool;
|
||||||
|
|
||||||
|
@ -89,6 +89,10 @@ auto exec(std::string_view command, bool interactive) noexcept -> std::string {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto exec_checked(std::string_view command) noexcept -> bool {
|
||||||
|
return utils::exec(command, true) == "0"sv;
|
||||||
|
}
|
||||||
|
|
||||||
void arch_chroot(std::string_view command, std::string_view mountpoint, bool interactive) noexcept {
|
void arch_chroot(std::string_view command, std::string_view mountpoint, bool interactive) noexcept {
|
||||||
// TODO(vnepogodin): refactor to move output into variable and print into log
|
// TODO(vnepogodin): refactor to move output into variable and print into log
|
||||||
const auto& cmd_formatted = fmt::format(FMT_COMPILE("arch-chroot {} {} 2>>/tmp/cachyos-install.log 2>&1"), mountpoint, command);
|
const auto& cmd_formatted = fmt::format(FMT_COMPILE("arch-chroot {} {} 2>>/tmp/cachyos-install.log 2>&1"), mountpoint, command);
|
||||||
@ -105,7 +109,7 @@ auto arch_chroot_checked(std::string_view command, std::string_view mountpoint)
|
|||||||
const auto& cmd_formatted = fmt::format(FMT_COMPILE("arch-chroot {} {} 2>>/tmp/cachyos-install.log 1>/dev/null"), mountpoint, command);
|
const auto& cmd_formatted = fmt::format(FMT_COMPILE("arch-chroot {} {} 2>>/tmp/cachyos-install.log 1>/dev/null"), mountpoint, command);
|
||||||
|
|
||||||
#ifdef NDEVENV
|
#ifdef NDEVENV
|
||||||
return utils::exec(cmd_formatted, true) == "0";
|
return utils::exec(cmd_formatted, true) == "0"sv;
|
||||||
#else
|
#else
|
||||||
spdlog::info("Running with checked arch-chroot: '{}'", cmd_formatted);
|
spdlog::info("Running with checked arch-chroot: '{}'", cmd_formatted);
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
Reference in New Issue
Block a user