-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🧹 move systemd-boot installation into gucc
needs refactor to be testable
- Loading branch information
1 parent
5d53d8b
commit 9c8f8f2
Showing
5 changed files
with
71 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#ifndef BOOTLOADER_HPP | ||
#define BOOTLOADER_HPP | ||
|
||
#include <string_view> // for string_view | ||
|
||
namespace gucc::bootloader { | ||
|
||
// Installs & configures systemd-boot on system | ||
auto install_systemd_boot(std::string_view root_mountpoint, std::string_view efi_directory, bool is_volume_removable) noexcept -> bool; | ||
|
||
} // namespace gucc::bootloader | ||
|
||
#endif // BOOTLOADER_HPP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#include "gucc/bootloader.hpp" | ||
#include "gucc/initcpio.hpp" | ||
#include "gucc/io_utils.hpp" | ||
|
||
#include <fmt/compile.h> | ||
#include <fmt/format.h> | ||
|
||
#include <spdlog/spdlog.h> | ||
|
||
using namespace std::string_view_literals; | ||
|
||
namespace gucc::bootloader { | ||
|
||
auto install_systemd_boot(std::string_view root_mountpoint, std::string_view efi_directory, bool is_volume_removable) noexcept -> bool { | ||
// Install systemd-boot onto EFI | ||
const auto& bootctl_cmd = fmt::format(FMT_COMPILE("bootctl --path={} install"), efi_directory); | ||
if (!utils::arch_chroot_checked(bootctl_cmd, root_mountpoint)) { | ||
spdlog::error("Failed to run bootctl on path {} with: {}", root_mountpoint, bootctl_cmd); | ||
return false; | ||
} | ||
|
||
// Generate systemd-boot configuration entries with our sdboot | ||
static constexpr auto sdboot_cmd = "sdboot-manage gen"sv; | ||
if (!utils::arch_chroot_checked(bootctl_cmd, root_mountpoint)) { | ||
spdlog::error("Failed to run sdboot-manage gen on mountpoint: {}", root_mountpoint); | ||
return false; | ||
} | ||
|
||
// if the volume is removable don't use autodetect | ||
if (is_volume_removable) { | ||
const auto& initcpio_filename = fmt::format(FMT_COMPILE("{}/etc/mkinitcpio.conf"), root_mountpoint); | ||
|
||
// Remove autodetect hook | ||
auto initcpio = detail::Initcpio{initcpio_filename}; | ||
initcpio.remove_hook("autodetect"); | ||
spdlog::info("\"Autodetect\" hook was removed"); | ||
} | ||
return true; | ||
} | ||
|
||
} // namespace gucc::bootloader |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters