Class: Yast::GRUB2Base

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

Overview

Common base for GRUB2 specialized classes

Direct Known Subclasses

BootGRUB2Class, BootGRUB2EFIClass

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Instance Attribute Details

- (Object) password

Returns the value of attribute password



11
12
13
# File 'src/lib/bootloader/grub2base.rb', line 11

def password
  @password
end

Instance Method Details

- (Object) Dialogs



88
89
90
91
92
93
94
95
96
# File 'src/lib/bootloader/grub2base.rb', line 88

def Dialogs
  Builtins.y2milestone("Called GRUB2 Dialogs")
  {
    "loader"       => fun_ref(
      method(:Grub2LoaderDetailsDialog),
      "symbol ()"
    )
  }
end

- (Object) Initializer

Initializer of GRUB bootloader



149
150
151
152
153
154
155
156
157
158
159
160
# File 'src/lib/bootloader/grub2base.rb', line 149

def Initializer
  Builtins.y2milestone("Called GRUB2 initializer")
  BootCommon.current_bootloader_attribs = {
    "propose"            => false,
    "read"               => false,
    "scratch"            => false,
    "restore_mbr"        => false,
    "bootloader_on_disk" => false
  }

  nil
end

- (Object) main



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'src/lib/bootloader/grub2base.rb', line 13

def main
  Yast.import "UI"

  textdomain "bootloader"

  Yast.import "Arch"
  Yast.import "BootArch"
  Yast.import "BootCommon"
  Yast.import "BootStorage"
  Yast.import "HTML"
  Yast.import "Initrd"
  Yast.import "Kernel"
  Yast.import "Mode"
  Yast.import "Pkg"
  Yast.import "Product"
  Yast.import "ProductFeatures"
  Yast.import "Stage"
  Yast.import "Storage"
  Yast.import "StorageDevices"

  # includes
  # for simplified widgets than other
  Yast.include self, "bootloader/grub2/dialogs.rb"

  @password = ::Bootloader::GRUB2Pwd.new
end

- (Object) pmbr_setup(action, *devices)

set pmbr flags on boot disks



43
44
45
46
47
48
49
50
51
52
53
54
# File 'src/lib/bootloader/grub2base.rb', line 43

def pmbr_setup(action, *devices)
  action_parted = case action
    when :add    then "on"
    when :remove then "off"
    else raise "invalid action #{action}"
    end
  devices.each do |dev|
    res = WFM.Execute(path(".local.bash_output"),
      "parted -s '#{dev}' disk_set pmbr_boot #{action_parted}")
    Builtins.y2milestone("parted disk_set pmbr: #{res}")
  end
end

- (Object) Propose



98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# File 'src/lib/bootloader/grub2base.rb', line 98

def Propose
  if BootCommon.was_proposed
    # workaround autoyast config is Imported thus was_proposed always set
    if Mode.autoinst || Mode.autoupgrade
      Builtins.y2milestone(
        "autoinst mode we ignore meaningless was_proposed as it always set"
      )
    else
      Builtins.y2milestone(
        "calling Propose with was_proposed set is really bogus, clear it to force a re-propose"
      )
      return
    end
  end

  BootCommon.globals = StandardGlobals().merge(BootCommon.globals || {})

  swap_parts = BootStorage.available_swap_partitions
  largest_swap_part = (swap_parts.max_by { |_part, size| size } || [""]).first

  resume = BootArch.ResumeAvailable ? largest_swap_part : ""
  # try to use label or udev id for device name... FATE #302219
  if resume != "" && !resume.nil?
    resume = ::Bootloader::UdevMapping.to_mountby_device(resume)
  end

  BootCommon.globals["append"]          ||= BootArch.DefaultKernelParams(resume)
  BootCommon.globals["failsafe_disabled"] = "true" if BootCommon.globals["failsafe_disabled"].nil?
  BootCommon.globals["distributor"]     ||= ""

  # Propose bootloader serial settings from kernel cmdline during install (bnc#862388)
  serial = BootCommon.GetSerialFromAppend

  if !serial.empty?
    BootCommon.globals["terminal"] ||= "serial"
    BootCommon.globals["serial"] ||= serial
  end

  Builtins.y2milestone("Proposed globals: %1", BootCommon.globals)

  nil
end

- (Object) Reset

Reset bootloader settings



83
84
85
86
# File 'src/lib/bootloader/grub2base.rb', line 83

def Reset
  return if Mode.autoinst
  BootCommon.Reset
end

- (Object) Save(clean, init, flush)

overwrite Save to allow generation of modification scripts



142
143
144
145
146
# File 'src/lib/bootloader/grub2base.rb', line 142

def Save(clean, init, flush)
  @password.write

  BootCommon.Save(clean, init, flush)
end

- (Object) StandardGlobals

Propose global options of bootloader



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'src/lib/bootloader/grub2base.rb', line 57

def StandardGlobals
  # s390 do not have os_prober, see bnc#868909#c2
  # ppc have slow os_prober, see boo#931653
  disable_os_prober = (Arch.s390 || Arch.ppc) ||
    ProductFeatures.GetBooleanFeature("globals", "disable_os_prober")
  {
    "timeout"   => "8",
    "default"   => "0",
    "vgamode"   => "",
    "gfxmode"   => "auto",
    "terminal"  => Arch.s390 ? "console" : "gfxterm",
    "os_prober" => disable_os_prober ? "false" : "true",
    "activate"  => Arch.ppc ? "true" : "false"
  }
end

- (Object) Update

Update read settings to new version of configuration files



74
75
76
77
78
79
80
# File 'src/lib/bootloader/grub2base.rb', line 74

def Update
  Read(true, true)

  BootCommon.UpdateGlobals

  nil
end