Class: Bootloader::Grub2Bls
- Inherits:
-
Grub2Base
- Object
- BootloaderBase
- Grub2Base
- Bootloader::Grub2Bls
- Includes:
- Yast::I18n, Yast::Logger
- Defined in:
- src/lib/bootloader/grub2bls.rb
Overview
Represents grub2 bls bootloader with efi target
Constant Summary collapse
- CMDLINE =
"/etc/kernel/cmdline"
Instance Attribute Summary collapse
-
#sections ⇒ Object
readonly
Returns the value of attribute sections.
Attributes inherited from Grub2Base
#console, #grub_default, #password, #pmbr_action, #secure_boot, #stage1, #trusted_boot, #update_nvram
Instance Method Summary collapse
-
#initialize ⇒ Grub2Bls
constructor
A new instance of Grub2Bls.
-
#merge(other) ⇒ Object
merges other bootloader configuration into this one.
-
#name ⇒ Object
Bootloader name.
-
#packages ⇒ Array<String>
Packages required to configure given bootloader.
-
#propose ⇒ Object
Proposes new configuration.
-
#proposed? ⇒ Boolean
True if configuration is already proposed.
-
#read ⇒ Object
reads configuration from target disk.
-
#read? ⇒ Boolean
True if configuration is already read.
-
#summary ⇒ Object
Display bootloader summary.
-
#write ⇒ Object
writes configuration to target disk.
Methods inherited from Grub2Base
#cpu_mitigations, #cpu_mitigations=, #disable_serial_console, #enable_serial_console, #explicit_cpu_mitigations, #include_os_prober_package?, #serial_console?
Methods inherited from BootloaderBase
Constructor Details
#initialize ⇒ Grub2Bls
Returns a new instance of Grub2Bls.
22 23 24 25 26 27 28 29 |
# File 'src/lib/bootloader/grub2bls.rb', line 22 def initialize super textdomain "bootloader" @sections = ::Bootloader::BlsSections.new @is_read = false @is_proposed = false end |
Instance Attribute Details
#sections ⇒ Object (readonly)
Returns the value of attribute sections.
18 19 20 |
# File 'src/lib/bootloader/grub2bls.rb', line 18 def sections @sections end |
Instance Method Details
#merge(other) ⇒ Object
merges other bootloader configuration into this one. It have to be same bootloader type. rubocop:disable Metrics/AbcSize
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'src/lib/bootloader/grub2bls.rb', line 108 def merge(other) raise "Invalid merge argument #{other.name} for #{name}" if name != other.name log.info "merging: timeout: #{grub_default.timeout}=>#{other.grub_default.timeout}" log.info " mitigations: #{cpu_mitigations.to_human_string}=>" \ "#{other.cpu_mitigations.to_human_string}" log.info " pmbr_action: #{pmbr_action}=>#{other.pmbr_action}" log.info " grub_default.kernel_params: #{grub_default.kernel_params.serialize}=>" \ "#{other.grub_default.kernel_params.serialize}" log.info " grub_default.kernel_params: #{grub_default.kernel_params.serialize}=>" \ "#{other.grub_default.kernel_params.serialize}" merge_sections(other) merge_grub_default(other) merge_pmbr_action(other) log.info "merging result: timeout: #{grub_default.timeout}" log.info " mitigations: #{cpu_mitigations.to_human_string}" log.info " kernel_params: #{grub_default.kernel_params.serialize}" log.info " pmbr_action: #{pmbr_action}" end |
#name ⇒ Object
Returns bootloader name.
43 44 45 |
# File 'src/lib/bootloader/grub2bls.rb', line 43 def name "grub2-bls" end |
#packages ⇒ Array<String>
Returns packages required to configure given bootloader.
132 133 134 135 136 137 |
# File 'src/lib/bootloader/grub2bls.rb', line 132 def packages res = super res << ("grub2-" + grub2bls_architecture + "-efi-bls") res << "sdbootutil" res end |
#propose ⇒ Object
Proposes new configuration
72 73 74 75 76 77 78 79 80 81 82 |
# File 'src/lib/bootloader/grub2bls.rb', line 72 def propose log.info("Propose settings...") if grub_default.kernel_params.empty? kernel_line = Yast::BootArch.DefaultKernelParams(Yast::BootStorage.propose_resume) grub_default.kernel_params.replace(kernel_line) end grub_default.timeout = Yast::ProductFeatures.GetIntegerFeature("globals", "boot_timeout").to_i @is_proposed = true # for UEFI always remove PMBR flag on disk (bnc#872054) self.pmbr_action = :remove end |
#proposed? ⇒ Boolean
Returns true if configuration is already proposed.
85 86 87 |
# File 'src/lib/bootloader/grub2bls.rb', line 85 def proposed? @is_proposed end |
#read ⇒ Object
reads configuration from target disk
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'src/lib/bootloader/grub2bls.rb', line 48 def read @sections.read grub_default.timeout = Bls. log.info "Boot timeout: #{grub_default.timeout}" lines = "" filename = File.join(Yast::Installation.destdir, CMDLINE) if File.exist?(filename) File.open(filename).each do |line| lines = + line end end grub_default.kernel_params.replace(lines) log.info "kernel params: #{grub_default.kernel_params}" log.info "bls sections: #{@sections.all}" log.info "bls default: #{@sections.default}" @is_read = true # flag that settings has been read end |
#read? ⇒ Boolean
Returns true if configuration is already read.
67 68 69 |
# File 'src/lib/bootloader/grub2bls.rb', line 67 def read? @is_read end |
#summary ⇒ Object
Display bootloader summary
33 34 35 36 37 38 39 40 |
# File 'src/lib/bootloader/grub2bls.rb', line 33 def summary(*) [ Yast::Builtins.sformat( _("Boot Loader Type: %1"), "GRUB2 BLS" ) ] end |
#write ⇒ Object
writes configuration to target disk
90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'src/lib/bootloader/grub2bls.rb', line 90 def write(*) Bls.install_bootloader if Yast::Stage.initial # while new installation only (currently) Bls. Bls.install_bootloader @sections.write Bls.(grub_default.timeout) # writing kernel parameter to /etc/kernel/cmdline File.open(File.join(Yast::Installation.destdir, CMDLINE), "w+") do |fw| fw.puts(grub_default.kernel_params.serialize) end Pmbr.write_efi(pmbr_action) end |