Class: Bootloader::BootloaderBase

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

Overview

Represents base for all kinds of bootloaders

Direct Known Subclasses

Grub2Base, NoneBootloader

Instance Method Summary (collapse)

Constructor Details

- (BootloaderBase) initialize

Returns a new instance of BootloaderBase



12
13
14
15
# File 'src/lib/bootloader/bootloader_base.rb', line 12

def initialize
  @read = false
  @proposed = false
end

Instance Method Details

- (Object) merge(other)

merges other bootloader configuration into this one. It have to be same bootloader type.



73
74
75
76
77
78
# File 'src/lib/bootloader/bootloader_base.rb', line 73

def merge(other)
  raise "Invalid merge argument #{other.name} for #{name}" if name != other.name

  @read ||= other.read?
  @proposed ||= other.proposed?
end

- (Array<String>) packages

Returns packages required to configure given bootloader

Returns:

  • (Array<String>)

    packages required to configure given bootloader



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

def packages
  res = []

  # added kexec-tools fate# 303395
  if !Yast::Mode.live_installation &&
      Yast::Linuxrc.InstallInf("kexec_reboot") != "0"
    res << "kexec-tools"
  end

  res
end

- (Object) propose

Proposes new configuration



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

def propose
  Yast::BootStorage.detect_disks
  @proposed = true
end

- (Boolean) proposed?

Returns true if configuration is already proposed

Returns:

  • (Boolean)

    true if configuration is already proposed



47
48
49
# File 'src/lib/bootloader/bootloader_base.rb', line 47

def proposed?
  @proposed
end

- (Object) read

reads configuration from target disk



25
26
27
28
# File 'src/lib/bootloader/bootloader_base.rb', line 25

def read
  Yast::BootStorage.detect_disks
  @read = true
end

- (Boolean) read?

Returns true if configuration is already read

Returns:

  • (Boolean)

    true if configuration is already read



42
43
44
# File 'src/lib/bootloader/bootloader_base.rb', line 42

def read?
  @read
end

- (Array<String>) summary

Returns description for proposal summary page for given bootloader

Returns:

  • (Array<String>)

    description for proposal summary page for given bootloader



37
38
39
# File 'src/lib/bootloader/bootloader_base.rb', line 37

def summary
  []
end

- (Object) write

writes configuration to target disk



18
19
20
21
22
# File 'src/lib/bootloader/bootloader_base.rb', line 18

def write
  write_sysconfig
  # in running system install package, for other modes, it need specific handling
  Yast::PackageSystem.InstallAll(packages) if Yast::Mode.normal
end

- (Object) write_sysconfig(prewrite: false)

done in common write but also in installation pre write as kernel update need it

Parameters:

  • prewrite (Boolean)

    true only in installation when scr is not yet switched



66
67
68
69
# File 'src/lib/bootloader/bootloader_base.rb', line 66

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