diff --git a/lib/src/bootloader.rs b/lib/src/bootloader.rs index 39c0d1511..aeb31d75c 100644 --- a/lib/src/bootloader.rs +++ b/lib/src/bootloader.rs @@ -6,7 +6,6 @@ use camino::Utf8Path; use cap_std::fs::Dir; use cap_std::fs::Permissions; use cap_std_ext::cap_std; -use cap_std_ext::cap_std::fs::DirBuilder; use cap_std_ext::prelude::*; use fn_error_context::context; @@ -15,43 +14,9 @@ use crate::task::Task; /// This variable is referenced by our GRUB fragment pub(crate) const IGNITION_VARIABLE: &str = "$ignition_firstboot"; const GRUB_BOOT_UUID_FILE: &str = "bootuuid.cfg"; -const STATIC_GRUB_CFG: &str = include_str!("grub.cfg"); -const STATIC_GRUB_CFG_EFI: &str = include_str!("grub-efi.cfg"); /// The name of the mountpoint for efi (as a subdirectory of /boot, or at the toplevel) pub(crate) const EFI_DIR: &str = "efi"; -#[context("Installing grub2 EFI")] -fn install_grub2_efi(efidir: &Dir, uuid: &str) -> Result<()> { - let mut vendordir = None; - let efidir = efidir.open_dir("EFI").context("Opening EFI/")?; - for child in efidir.entries()? { - let child = child?; - let name = child.file_name(); - let name = if let Some(name) = name.to_str() { - name - } else { - continue; - }; - if name == "BOOT" { - continue; - } - if !child.file_type()?.is_dir() { - continue; - } - vendordir = Some(child.open_dir()?); - break; - } - let vendordir = vendordir.ok_or_else(|| anyhow::anyhow!("Failed to find EFI vendor dir"))?; - vendordir - .atomic_write("grub.cfg", STATIC_GRUB_CFG_EFI) - .context("Writing static EFI grub.cfg")?; - vendordir - .atomic_write(GRUB_BOOT_UUID_FILE, uuid) - .with_context(|| format!("Writing {GRUB_BOOT_UUID_FILE}"))?; - - Ok(()) -} - /// Return `true` if the system is booted via EFI pub(crate) fn is_efi_booted() -> Result { if !super::install::ARCH_USES_EFI { @@ -74,7 +39,7 @@ pub(crate) fn install_via_bootupd( // to only doing that. This is only on x86_64 because that's the only arch that has multiple // components right now. // TODO: Add --component=auto which moves this logic into bootupd - let (install_efi, component_args) = if cfg!(target_arch = "x86_64") && is_alongside { + let component_args = if cfg!(target_arch = "x86_64") && is_alongside { assert!(super::install::ARCH_USES_EFI); let install_efi = is_efi_booted()?; let component_arg = if install_efi { @@ -82,11 +47,11 @@ pub(crate) fn install_via_bootupd( } else { "--component=BIOS" }; - (install_efi, Some(component_arg)) + Some(component_arg) } else { - (super::install::ARCH_USES_EFI, None) + None }; - let args = ["backend", "install"] + let args = ["backend", "install", "--with-static-configs"] .into_iter() .chain(verbose) .chain(component_args) @@ -104,26 +69,7 @@ pub(crate) fn install_via_bootupd( let bootfs = &rootfs.join("boot"); let bootfs = Dir::open_ambient_dir(bootfs, cap_std::ambient_authority()).context("Opening boot")?; - - if super::install::ARCH_USES_EFI && install_efi { - let efidir = bootfs.open_dir("efi").context("Opening efi")?; - install_grub2_efi(&efidir, &grub2_uuid_contents)?; - } - - bootfs - .ensure_dir_with("grub2", &DirBuilder::new()) - .context("Creating boot/grub2")?; - let grub2 = bootfs.open_dir("grub2")?; - - // Mode 0700 to support passwords etc. - grub2.set_permissions(".", Permissions::from_mode(0o700))?; - grub2 - .atomic_write_with_perms( - "grub.cfg", - STATIC_GRUB_CFG, - cap_std::fs::Permissions::from_mode(0o600), - ) - .context("Writing grub.cfg")?; + let grub2 = bootfs.open_dir("grub2").context("Opening boot/grub2")?; grub2 .atomic_write_with_perms( diff --git a/lib/src/grub-efi.cfg b/lib/src/grub-efi.cfg deleted file mode 100644 index 08ddae107..000000000 --- a/lib/src/grub-efi.cfg +++ /dev/null @@ -1,18 +0,0 @@ -if [ -e (md/md-boot) ]; then - # The search command might pick a RAID component rather than the RAID, - # since the /boot RAID currently uses superblock 1.0. See the comment in - # the main grub.cfg. - set prefix=md/md-boot -else - if [ -f ${config_directory}/bootuuid.cfg ]; then - source ${config_directory}/bootuuid.cfg - fi - if [ -n "${BOOT_UUID}" ]; then - search --fs-uuid "${BOOT_UUID}" --set prefix --no-floppy - else - search --label boot --set prefix --no-floppy - fi -fi -set prefix=($prefix)/grub2 -configfile $prefix/grub.cfg -boot diff --git a/lib/src/grub.cfg b/lib/src/grub.cfg deleted file mode 100644 index f2188f481..000000000 --- a/lib/src/grub.cfg +++ /dev/null @@ -1,95 +0,0 @@ -# This file is copied from https://github.com/coreos/coreos-assembler/blob/main/src/grub.cfg -set pager=1 -# petitboot doesn't support -e and doesn't support an empty path part -if [ -d (md/md-boot)/grub2 ]; then - # fcct currently creates /boot RAID with superblock 1.0, which allows - # component partitions to be read directly as filesystems. This is - # necessary because transposefs doesn't yet rerun grub2-install on BIOS, - # so GRUB still expects /boot to be a partition on the first disk. - # - # There are two consequences: - # 1. On BIOS and UEFI, the search command might pick an individual RAID - # component, but we want it to use the full RAID in case there are bad - # sectors etc. The undocumented --hint option is supposed to support - # this sort of override, but it doesn't seem to work, so we set $boot - # directly. - # 2. On BIOS, the "normal" module has already been loaded from an - # individual RAID component, and $prefix still points there. We want - # future module loads to come from the RAID, so we reset $prefix. - # (On UEFI, the stub grub.cfg has already set $prefix properly.) - set boot=md/md-boot - set prefix=($boot)/grub2 -else - if [ -f ${config_directory}/bootuuid.cfg ]; then - source ${config_directory}/bootuuid.cfg - fi - if [ -n "${BOOT_UUID}" ]; then - search --fs-uuid "${BOOT_UUID}" --set boot --no-floppy - else - search --label boot --set boot --no-floppy - fi -fi -set root=$boot - -if [ -f ${config_directory}/grubenv ]; then - load_env -f ${config_directory}/grubenv -elif [ -s $prefix/grubenv ]; then - load_env -fi - -if [ x"${feature_menuentry_id}" = xy ]; then - menuentry_id_option="--id" -else - menuentry_id_option="" -fi - -function load_video { - if [ x$feature_all_video_module = xy ]; then - insmod all_video - else - insmod efi_gop - insmod efi_uga - insmod ieee1275_fb - insmod vbe - insmod vga - insmod video_bochs - insmod video_cirrus - fi -} - -# Any non-default console settings will be inserted here. -# CONSOLE-SETTINGS-START -# CONSOLE-SETTINGS-END - -if [ x$feature_timeout_style = xy ] ; then - set timeout_style=menu - set timeout=1 -# Fallback normal timeout code in case the timeout_style feature is -# unavailable. -else - set timeout=1 -fi - -# Determine if this is a first boot and set the ${ignition_firstboot} variable -# which is used in the kernel command line. -set ignition_firstboot="" -if [ -f "/ignition.firstboot" ]; then - # Default networking parameters to be used with ignition. - set ignition_network_kcmdline='' - - # Source in the `ignition.firstboot` file which could override the - # above $ignition_network_kcmdline with static networking config. - # This override feature is also by coreos-installer to persist static - # networking config provided during install to the first boot of the machine. - source "/ignition.firstboot" - - set ignition_firstboot="ignition.firstboot ${ignition_network_kcmdline}" -fi - -# Import user defined configuration -# tracker: https://github.com/coreos/fedora-coreos-tracker/issues/805 -if [ -f $prefix/user.cfg ]; then - source $prefix/user.cfg -fi - -blscfg