Class: Bootloader::Grub2EFI

Inherits:
Grub2Base show all
Includes:
Yast::Logger
Defined in:
src/lib/bootloader/grub2efi.rb

Overview

Represents grub2 bootloader with efi target

Instance Attribute Summary

Attributes inherited from Grub2Base

#console, #grub_default, #password, #pmbr_action, #sections, #secure_boot, #stage1, #trusted_boot, #update_nvram

Instance Method Summary collapse

Methods inherited from Grub2Base

#cpu_mitigations, #cpu_mitigations=, #disable_serial_console, #enable_serial_console, #explicit_cpu_mitigations, #include_os_prober_package?, #merge, #pmbr_setup, #read, #serial_console?

Methods inherited from BootloaderBase

#merge, #prepare, #proposed?, #read, #read?

Constructor Details

#initializeGrub2EFI

Returns a new instance of Grub2EFI.



17
18
19
20
21
22
23
# File 'src/lib/bootloader/grub2efi.rb', line 17

def initialize
  super

  textdomain "bootloader"

  @grub_install = GrubInstall.new(efi: true)
end

Instance Method Details

#nameObject



68
69
70
# File 'src/lib/bootloader/grub2efi.rb', line 68

def name
  "grub2-efi"
end

#packagesObject



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'src/lib/bootloader/grub2efi.rb', line 72

def packages
  res = super

  case Systeminfo.efi_arch
  when "i386"
    res << "grub2-i386-efi"
  when "x86_64"
    res << "grub2-x86_64-efi"
    res << "shim" << "mokutil" if secure_boot
  when "arm"
    res << "grub2-arm-efi"
  when "aarch64"
    res << "grub2-arm64-efi"
    res << "shim" << "mokutil" if secure_boot
  when "riscv64"
    res << "grub2-riscv64-efi"
  else
    log.warn "Unknown architecture #{Yast::Arch.architecture} for EFI"
  end

  res
end

#proposeObject



40
41
42
43
44
45
46
47
48
49
# File 'src/lib/bootloader/grub2efi.rb', line 40

def propose
  super

  # for UEFI always remove PMBR flag on disk (bnc#872054)
  self.pmbr_action = :remove

  # linuxefi/initrdefi are available on x86 only
  grub_default.generic_set("GRUB_USE_LINUXEFI",
    (Yast::Arch.x86_64 || Yast::Arch.i386) ? "true" : "false")
end

#summaryObject

Display bootloader summary

Returns:

  • a list of summary lines



53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'src/lib/bootloader/grub2efi.rb', line 53

def summary(*)
  result = [
    Yast::Builtins.sformat(
      _("Boot Loader Type: %1"),
      "GRUB2 EFI"
    )
  ]

  result << secure_boot_summary if Systeminfo.secure_boot_available?(name)
  result << trusted_boot_summary if Systeminfo.trusted_boot_available?(name)
  result << update_nvram_summary if Systeminfo.nvram_available?(name)

  result
end

#write(etc_only: false) ⇒ Object

Write bootloader settings to disk



26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'src/lib/bootloader/grub2efi.rb', line 26

def write(etc_only: false)
  # super have to called as first as grub install require some config written in ancestor
  super

  pmbr_write if pmbr_action

  unless etc_only
    @grub_install.execute(secure_boot: secure_boot, trusted_boot: trusted_boot,
      update_nvram: update_nvram)
  end

  true
end

#write_sysconfig(prewrite: false) ⇒ Object

overwrite BootloaderBase version to save secure boot



96
97
98
99
100
101
# File 'src/lib/bootloader/grub2efi.rb', line 96

def write_sysconfig(prewrite: false)
  sysconfig = Bootloader::Sysconfig.new(bootloader: name,
    secure_boot: secure_boot, trusted_boot: trusted_boot,
    update_nvram: update_nvram)
  prewrite ? sysconfig.pre_write : sysconfig.write
end