Class: Bootloader::SystemdBoot

Inherits:
BootloaderBase show all
Includes:
Yast::I18n, Yast::Logger
Defined in:
src/lib/bootloader/systemdboot.rb

Overview

Represents systemd bootloader with efi target

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from BootloaderBase

#prepare, #proposed?, #read?

Constructor Details

#initializeSystemdBoot

Returns a new instance of SystemdBoot.



29
30
31
32
33
# File 'src/lib/bootloader/systemdboot.rb', line 29

def initialize
  super

  textdomain "bootloader"
end

Instance Attribute Details

Returns menue timeout.

Returns:

  • (Integer)

    menue timeout



23
24
25
# File 'src/lib/bootloader/systemdboot.rb', line 23

def menue_timeout
  @menue_timeout
end

#secure_bootBoolean

Returns current secure boot setting.

Returns:

  • (Boolean)

    current secure boot setting



27
28
29
# File 'src/lib/bootloader/systemdboot.rb', line 27

def secure_boot
  @secure_boot
end

Instance Method Details

#deleteObject



123
124
125
# File 'src/lib/bootloader/systemdboot.rb', line 123

def delete
  log.warn("is currently not supported")
end

#merge(other) ⇒ Object



35
36
37
38
39
40
41
# File 'src/lib/bootloader/systemdboot.rb', line 35

def merge(other)
  log.info "merging with system: timeout=#{other.menue_timeout} " \
           "secure_boot=#{other.secure_boot}"
  super
  self.menue_timeout = other.menue_timeout unless other.menue_timeout.nil?
  self.secure_boot = other.secure_boot unless other.secure_boot.nil?
end

#nameObject



105
106
107
# File 'src/lib/bootloader/systemdboot.rb', line 105

def name
  "systemd-boot"
end

#packagesObject



109
110
111
112
113
114
115
116
117
118
119
120
121
# File 'src/lib/bootloader/systemdboot.rb', line 109

def packages
  res = super
  res << "sdbootutil" << "systemd-boot"

  case Yast::Arch.architecture
  when "x86_64"
    res << "shim" if secure_boot
  else
    log.warn "Unknown architecture #{Yast::Arch.architecture} for systemdboot"
  end

  res
end

#proposeObject



63
64
65
66
67
68
# File 'src/lib/bootloader/systemdboot.rb', line 63

def propose
  super
  log.info("Propose settings...")
  self.menue_timeout = Yast::ProductFeatures.GetIntegerFeature("globals", "boot_timeout").to_i
  self.secure_boot = Systeminfo.secure_boot_supported?
end

#readObject



43
44
45
46
47
48
# File 'src/lib/bootloader/systemdboot.rb', line 43

def read
  super

  read_menue_timeout
  self.secure_boot = Systeminfo.secure_boot_active?
end

#secure_boot_summaryString

Secure boot setting shown in summary screen. sdbootutil intialize secure boot if shim has been installed.

Returns:

  • (String)


82
83
84
85
86
87
88
89
90
# File 'src/lib/bootloader/systemdboot.rb', line 82

def secure_boot_summary
  link = if secure_boot
    "<a href=\"disable_secure_boot\">(#{_("disable")})</a>"
  else
    "<a href=\"enable_secure_boot\">(#{_("enable")})</a>"
  end

  "#{_("Secure Boot:")} #{status_string(secure_boot)} #{link}"
end

#status_string(status) ⇒ Object



70
71
72
73
74
75
76
# File 'src/lib/bootloader/systemdboot.rb', line 70

def status_string(status)
  if status
    _("enabled")
  else
    _("disabled")
  end
end

#summaryObject

Display bootloader summary

Returns:

  • a list of summary lines



94
95
96
97
98
99
100
101
102
103
# File 'src/lib/bootloader/systemdboot.rb', line 94

def summary(*)
  result = [
    Yast::Builtins.sformat(
      _("Boot Loader Type: %1"),
      "Systemd Boot"
    )
  ]
  result << secure_boot_summary if Systeminfo.secure_boot_available?(name)
  result
end

#write(etc_only: false) ⇒ Object

Write bootloader settings to disk



51
52
53
54
55
56
57
58
59
60
61
# File 'src/lib/bootloader/systemdboot.rb', line 51

def write(etc_only: false)
  super
  log.info("Writing settings...")
  if Yast::Stage.initial # while new installation only (currently)
    install_bootloader
    create_menue_entries
  end
  write_menue_timeout

  true
end

#write_sysconfig(prewrite: false) ⇒ Object

overwrite BootloaderBase version to save secure boot



128
129
130
131
132
133
# File 'src/lib/bootloader/systemdboot.rb', line 128

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