mirror of
https://github.com/CachyOS/New-Cli-Installer.git
synced 2025-01-23 05:52:23 +08:00
👷 disk: refactor zfs pool creation using gucc
Some checks are pending
Build / Build with CMake (push) Waiting to run
Build / Build with CMake (DEVENV OFF) (push) Waiting to run
Build / Build with Meson (push) Waiting to run
Build / Build with Meson (DEVENV OFF) (push) Waiting to run
Checks / cpp-linter (push) Waiting to run
Checks / Check C++ style (push) Waiting to run
Some checks are pending
Build / Build with CMake (push) Waiting to run
Build / Build with CMake (DEVENV OFF) (push) Waiting to run
Build / Build with Meson (push) Waiting to run
Build / Build with Meson (DEVENV OFF) (push) Waiting to run
Checks / cpp-linter (push) Waiting to run
Checks / Check C++ style (push) Waiting to run
This commit is contained in:
parent
6ba80505da
commit
09f9d297f7
11
src/disk.cpp
11
src/disk.cpp
@ -239,22 +239,17 @@ bool zfs_create_zpool(const std::string_view& partition, const std::string_view&
|
||||
static constexpr auto zpool_options{"-f -o ashift=12 -o autotrim=on -O acltype=posixacl -O compression=zstd -O atime=off -O relatime=off -O normalization=formD -O xattr=sa -O mountpoint=none"sv};
|
||||
|
||||
#ifdef NDEVENV
|
||||
std::int32_t ret_code{};
|
||||
std::string device_path{partition};
|
||||
|
||||
// Find the UUID of the partition
|
||||
const auto& partuuid = gucc::utils::exec(fmt::format(FMT_COMPILE("lsblk -lno PATH,PARTUUID | grep \"^{}\" | {}"), partition, "awk '{print $2}'"sv), false);
|
||||
|
||||
// See if the partition has a partuuid, if not use the device name
|
||||
const auto& zfs_zpool_cmd = fmt::format(FMT_COMPILE("zpool create {} {}"), zpool_options, pool_name);
|
||||
if (!partuuid.empty()) {
|
||||
ret_code = utils::to_int(gucc::utils::exec(fmt::format(FMT_COMPILE("{} {} 2>>/tmp/cachyos-install.log"), zfs_zpool_cmd, partuuid), true));
|
||||
spdlog::info("Creating zpool {} on device {} using partuuid {}", pool_name, partition, partuuid);
|
||||
} else {
|
||||
ret_code = utils::to_int(gucc::utils::exec(fmt::format(FMT_COMPILE("{} {} 2>>/tmp/cachyos-install.log"), zfs_zpool_cmd, partition), true));
|
||||
spdlog::info("Creating zpool {} on device {}", pool_name, partition);
|
||||
device_path = partuuid;
|
||||
}
|
||||
|
||||
if (ret_code != 0) {
|
||||
if (!gucc::fs::zfs_create_zpool(device_path, pool_name, zpool_options)) {
|
||||
spdlog::error("Failed to create zpool!");
|
||||
return false;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user