From 957b21619448e9355a5774ff4bf594209a8fb118 Mon Sep 17 00:00:00 2001 From: Vladislav Nepogodin Date: Mon, 29 Jul 2024 00:20:34 +0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=B9=20utils:=20refactor=20grub=20efi?= =?UTF-8?q?=20using=20native=20calls?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/utils.cpp b/src/utils.cpp index 4215b94..9a6b5e4 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -1046,9 +1046,16 @@ pacman -S --noconfirm --needed grub efibootmgr dosfstools grub-btrfs grub-hook if (!as_default) { return; } /* clang-format on */ - utils::arch_chroot(fmt::format(FMT_COMPILE("mkdir -p {}/EFI/boot"), uefi_mount), false); - spdlog::info("Grub efi binary status:(EFI/cachyos/grubx64.efi): {}", fs::exists(fmt::format(FMT_COMPILE("{0}/EFI/cachyos/grubx64.efi"), uefi_mount))); - utils::arch_chroot(fmt::format(FMT_COMPILE("cp -r {0}/EFI/cachyos/grubx64.efi {0}/EFI/boot/bootx64.efi"), uefi_mount), false); + // create efi directories + const auto& boot_mountpoint = fmt::format(FMT_COMPILE("{}{}"), mountpoint, uefi_mount); + fs::create_directories(fmt::format(FMT_COMPILE("{}/EFI/boot"), boot_mountpoint), err); + + const auto& efi_cachyos_grub_file = fmt::format(FMT_COMPILE("{}/EFI/cachyos/grubx64.efi"), boot_mountpoint); + spdlog::info("Grub efi binary status:(EFI/cachyos/grubx64.efi): {}", fs::exists(efi_cachyos_grub_file)); + + // copy cachyos efi as default efi + const auto& default_efi_grub_file = fmt::format(FMT_COMPILE("{}/EFI/boot/bootx64.efi"), boot_mountpoint); + fs::copy_file(efi_cachyos_grub_file, default_efi_grub_file, fs::copy_options::overwrite_existing); #endif }