Class: Bootloader::BootloaderFactory

Inherits:
Object
  • Object
show all
Defined in:
src/lib/bootloader/bootloader_factory.rb

Overview

Factory to get instance of bootloader

Constant Summary

SUPPORTED_BOOTLOADERS =
[
  "none", # allows user to manage bootloader itself
  "grub2",
  "grub2-efi"
].freeze

Class Attribute Summary (collapse)

Class Method Summary (collapse)

Class Attribute Details

+ (Object) current



31
32
33
# File 'src/lib/bootloader/bootloader_factory.rb', line 31

def current
  @current ||= (system || proposed)
end

Class Method Details

+ (Object) bootloader_by_name(name)



62
63
64
65
66
67
68
69
70
71
72
73
# File 'src/lib/bootloader/bootloader_factory.rb', line 62

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 "none"
    @cached_bootloaders["none"] ||= NoneBootloader.new
  end
end

+ (Object) clear_cache



39
40
41
# File 'src/lib/bootloader/bootloader_factory.rb', line 39

def clear_cache
  @cached_bootloaders = nil
end

+ (Object) current_name=(name)



35
36
37
# File 'src/lib/bootloader/bootloader_factory.rb', line 35

def current_name=(name)
  @current = bootloader_by_name(name)
end

+ (Object) proposed



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

def proposed
  bootloader_by_name(proposed_name)
end

+ (Object) supported_names



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'src/lib/bootloader/bootloader_factory.rb', line 43

def supported_names
  if Yast::Mode.config
    # default means bootloader use what it think is the best
    return BootloaderFactory::SUPPORTED_BOOTLOADERS + ["default"]
  end

  system_bl = begin
                system.name
              rescue
                nil
              end # rescue exception if system one is not support
  ret = system_bl ? [system.name] : [] # use current as first
  ret << "grub2" unless Yast::Arch.aarch64 # grub2 everywhere except aarch64
  ret << "grub2-efi" if Yast::Arch.x86_64 || Yast::Arch.aarch64
  ret << "none"
  # avoid double entry for selected one
  ret.uniq
end

+ (Object) system



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

def system
  bootloader_by_name(Sysconfig.from_system.bootloader)
end