Class: Bootloader::BootloaderFactory
- Inherits:
-
Object
- Object
- Bootloader::BootloaderFactory
- Extended by:
- Yast::Logger
- Defined in:
- src/lib/bootloader/bootloader_factory.rb
Overview
Factory to get instance of bootloader
Constant Summary collapse
- SUPPORTED_BOOTLOADERS =
[ "none", # allows user to manage bootloader itself "grub2", "grub2-efi" ].freeze
- DEFAULT_KEYWORD =
Keyword used in autoyast for default bootloader used for given system.
"default"- SYSTEMDBOOT =
"systemd-boot"- GRUB2BLS =
"grub2-bls"
Class Attribute Summary collapse
Class Method Summary collapse
-
.bootloader_by_name(name) ⇒ Object
rubocop:disable Metrics/CyclomaticComplexity.
- .clear_cache ⇒ Object
- .current_name=(name) ⇒ Object
- .proposed ⇒ Object
- .supported_names ⇒ Object
- .system ⇒ Object
Class Attribute Details
.current ⇒ Object
46 47 48 |
# File 'src/lib/bootloader/bootloader_factory.rb', line 46 def current @current ||= (system || proposed) end |
Class Method Details
.bootloader_by_name(name) ⇒ Object
rubocop:disable Metrics/CyclomaticComplexity
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'src/lib/bootloader/bootloader_factory.rb', line 86 def bootloader_by_name(name) # needed to be able to store settings when moving between bootloaders @cached_bootloaders ||= {} case name when "grub2" @cached_bootloaders["grub2"] ||= Grub2.new when "grub2-efi" @cached_bootloaders["grub2-efi"] ||= Grub2EFI.new when "systemd-boot" @cached_bootloaders["systemd-boot"] ||= SystemdBoot.new when "grub2-bls" @cached_bootloaders["grub2-bls"] ||= Grub2Bls.new when "none" @cached_bootloaders["none"] ||= NoneBootloader.new when String raise UnsupportedBootloader, name else log.error "Factory receive nil name" nil # in other cases it means that read failed end end |
.clear_cache ⇒ Object
54 55 56 |
# File 'src/lib/bootloader/bootloader_factory.rb', line 54 def clear_cache @cached_bootloaders = nil end |
.current_name=(name) ⇒ Object
50 51 52 |
# File 'src/lib/bootloader/bootloader_factory.rb', line 50 def current_name=(name) @current = bootloader_by_name(name) end |
.proposed ⇒ Object
35 36 37 |
# File 'src/lib/bootloader/bootloader_factory.rb', line 35 def proposed bootloader_by_name(proposed_name) end |
.supported_names ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'src/lib/bootloader/bootloader_factory.rb', line 58 def supported_names if Yast::Mode.config # default means bootloader use what it think is the best result = BootloaderFactory::SUPPORTED_BOOTLOADERS.clone result << GRUB2BLS if use_grub2_bls? result << SYSTEMDBOOT if use_systemd_boot? result << DEFAULT_KEYWORD return result end begin system_bl = system.name # rescue exception if system one is not support rescue StandardError system_bl = nil end ret = system_bl ? [system.name] : [] # use current as first # grub2 everywhere except aarch64 or riscv64 ret << "grub2" unless Systeminfo.efi_mandatory? ret << "grub2-efi" if Systeminfo.efi_supported? ret << GRUB2BLS if use_grub2_bls? ret << SYSTEMDBOOT if use_systemd_boot? ret << "none" # avoid double entry for selected one ret.uniq end |
.system ⇒ Object
39 40 41 42 43 44 |
# File 'src/lib/bootloader/bootloader_factory.rb', line 39 def system sysconfig_name = Sysconfig.from_system.bootloader return nil unless sysconfig_name bootloader_by_name(sysconfig_name) end |