Class: Bootloader::BootloaderBase
- Inherits:
-
Object
- Object
- Bootloader::BootloaderBase
- Defined in:
- src/lib/bootloader/bootloader_base.rb
Overview
Represents base for all kinds of bootloaders
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize ⇒ BootloaderBase
constructor
A new instance of BootloaderBase.
-
#merge(other) ⇒ Object
merges other bootloader configuration into this one.
-
#packages ⇒ Array<String>
Packages required to configure given bootloader.
-
#prepare ⇒ Boolean
Prepares the system to (before write the configuration).
-
#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 ⇒ Array<String>
Description for proposal summary page for given bootloader.
-
#write(etc_only: false) ⇒ Object
writes configuration to target disk.
-
#write_sysconfig(prewrite: false) ⇒ Object
done in common write but also in installation pre write as kernel update need it.
Constructor Details
#initialize ⇒ BootloaderBase
Returns a new instance of BootloaderBase.
14 15 16 17 18 |
# File 'src/lib/bootloader/bootloader_base.rb', line 14 def initialize @read = false @proposed = false @initial_sysconfig = Sysconfig.from_system end |
Instance Method Details
#merge(other) ⇒ Object
merges other bootloader configuration into this one. It have to be same bootloader type.
93 94 95 96 97 98 |
# File 'src/lib/bootloader/bootloader_base.rb', line 93 def merge(other) raise "Invalid merge argument #{other.name} for #{name}" if name != other.name @read ||= other.read? @proposed ||= other.proposed? # rubocop:disable Naming/MemoizedInstanceVariableName end |
#packages ⇒ Array<String>
Returns packages required to configure given bootloader.
75 76 77 78 79 80 81 82 |
# File 'src/lib/bootloader/bootloader_base.rb', line 75 def packages res = [] # added kexec-tools fate#303395 res << "kexec-tools" if include_kexec_tools_package? res end |
#prepare ⇒ Boolean
Prepares the system to (before write the configuration)
Writes the new sysconfig and, when the Mode.normal is set, tries to install the required packages. If user decides to cancel the installation, it restores the previous sysconfig.
27 28 29 30 31 32 33 34 35 36 |
# File 'src/lib/bootloader/bootloader_base.rb', line 27 def prepare write_sysconfig return true unless Yast::Mode.normal return true if Yast::Package.InstallAll(packages) restore_initial_sysconfig false end |
#propose ⇒ Object
Proposes new configuration
55 56 57 |
# File 'src/lib/bootloader/bootloader_base.rb', line 55 def propose @proposed = true end |
#proposed? ⇒ Boolean
Returns true if configuration is already proposed.
70 71 72 |
# File 'src/lib/bootloader/bootloader_base.rb', line 70 def proposed? @proposed end |
#read ⇒ Object
reads configuration from target disk
50 51 52 |
# File 'src/lib/bootloader/bootloader_base.rb', line 50 def read @read = true end |
#read? ⇒ Boolean
Returns true if configuration is already read.
65 66 67 |
# File 'src/lib/bootloader/bootloader_base.rb', line 65 def read? @read end |
#summary ⇒ Array<String>
Returns description for proposal summary page for given bootloader.
60 61 62 |
# File 'src/lib/bootloader/bootloader_base.rb', line 60 def summary [] end |
#write(etc_only: false) ⇒ Object
writes configuration to target disk
41 42 43 44 45 46 47 |
# File 'src/lib/bootloader/bootloader_base.rb', line 41 def write(etc_only: false) return if etc_only # reset eventl. already installed systemd bootloader systemd_boot = BootloaderFactory.bootloader_by_name("systemd-boot") systemd_boot&.delete end |
#write_sysconfig(prewrite: false) ⇒ Object
done in common write but also in installation pre write as kernel update need it
86 87 88 89 |
# File 'src/lib/bootloader/bootloader_base.rb', line 86 def write_sysconfig(prewrite: false) sysconfig = Bootloader::Sysconfig.new(bootloader: name) prewrite ? sysconfig.pre_write : sysconfig.write end |