Module: Yast::BootloaderGrub2DialogsInclude

Defined in:
src/include/bootloader/grub2/dialogs.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) boot_code_tab



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'src/include/bootloader/grub2/dialogs.rb', line 44

def boot_code_tab
  lt = BootCommon.getLoaderType(false)

  legacy_intel = (Arch.x86_64 || Arch.i386) && lt != "grub2-efi"
  pmbr_available = lt == "grub2-efi" || (legacy_intel && gpt_boot_disk?)
  widget_names = ["distributor", "loader_type", "loader_location"]
  widget_names << "activate" << "generic_mbr" if legacy_intel
  widget_names << "inst_details" if legacy_intel || Arch.ppc
  widget_names << "pmbr" if pmbr_available

  {
    "id"           => "boot_code_tab",
    # Title in tab
    "header"       => _("Boot Code Options"),
    # if name is not included, that it is not displayed
    "widget_names" => widget_names,
    "contents"     => VBox(
      VSquash(HBox(
        Top(VBox( VSpacing(1), "loader_type")),
        Arch.s390 ? Empty() : "loader_location")),
      MarginBox(1, 0.5, "distributor"),
      MarginBox(1, 0.5, Left("activate")),
      MarginBox(1, 0.5, Left("generic_mbr")),
      MarginBox(1, 0.5, Left("pmbr")),
      MarginBox(1, 0.5, Left("inst_details")),
      VStretch()
    )
  }
end

- (Object) bootloader_tab



95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'src/include/bootloader/grub2/dialogs.rb', line 95

def bootloader_tab
    widgets = ["default", "timeout", "password", "os_prober", "hiddenmenu"]
    widgets.delete("os_prober") if Arch.s390 # there is no os prober on s390(bnc#868909)

   {
    "id" => "bootloader_tab",
    # Title in tab
    "header" => _("Bootloader Options"),
    "widget_names" => widgets,
    "contents" => VBox(
      VSpacing(2),
      HBox(
        HSpacing(1),
        "timeout",
        HSpacing(1),
        Left(VBox( "os_prober", "hiddenmenu")),
        HSpacing(1)
      ),
      MarginBox(1, 1, "default"),
      MarginBox(1, 1, "password"),
      VStretch()
    )
  }
end

- (Object) grub2efiWidgets



305
306
307
308
309
310
311
312
313
314
# File 'src/include/bootloader/grub2/dialogs.rb', line 305

def grub2efiWidgets
  if Arch.x86_64
    if @_grub2_efi_widgets == nil
      @_grub2_efi_widgets = { "loader_location" => grub2SecureBootWidget }
      @_grub2_efi_widgets.merge! Grub2Options()
    end
  end

  deep_copy(@_grub2_efi_widgets)
end

- (Symbol) Grub2InstallDetailsDialog

Run dialog to adjust installation on i386 and AMD64

Returns:

  • (Symbol)

    for wizard sequencer



218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
# File 'src/include/bootloader/grub2/dialogs.rb', line 218

def Grub2InstallDetailsDialog
  contents = HBox(
    HStretch(),
    VBox(VStretch(), Frame(_("Disk Order"), "disks_order"), VStretch()),
    HStretch()
  )

  CWM.ShowAndRun(
    {
      "widget_descr" => { "disks_order" => DisksOrderWidget() },
      "widget_names" => ["disks_order"],
      "contents"     => contents,
      "caption"      => _("Disk order settings"),
      "back_button"  => Label.BackButton,
      "abort_button" => Label.CancelButton,
      "next_button"  => Label.OKButton
    }
  )
end

- (Symbol) Grub2LoaderDetailsDialog

Run dialog for loader installation details for Grub2

Returns:

  • (Symbol)

    for wizard sequencer



128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
# File 'src/include/bootloader/grub2/dialogs.rb', line 128

def Grub2LoaderDetailsDialog
  Builtins.y2milestone("Running Grub2 loader details dialog")
  widgets = Grub2Options()

  tabs = [ bootloader_tab, kernel_tab, boot_code_tab]

  tab_widget = CWMTab.CreateWidget({
    "tab_order"    => tabs.map{ |t| t["id"] },
    "tabs"         => Hash[tabs.map{|tab| [tab["id"], tab]}],
    "initial_tab"  => tabs.first["id"],
    "widget_descr" => widgets
  })

  widgets["tab"] = tab_widget
  # Window title
  caption = _("Boot Loader Options")
  CWM.ShowAndRun(
    {
      "widget_descr" => widgets,
      "widget_names" => ["tab"],
      "contents"     => VBox("tab"),
      "caption"      => caption,
      "back_button"  => Label.BackButton,
      "abort_button" => Label.CancelButton,
      "next_button"  => Label.OKButton
    }
  )
end

- (Object) grub2SecureBootWidget



179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
# File 'src/include/bootloader/grub2/dialogs.rb', line 179

def grub2SecureBootWidget
  contents = VBox(
    VSpacing(1),
    Frame(
      _("Secure Boot"),
      VBox(
        HBox(
          HSpacing(1),
          VBox(
            Left(
              CheckBox(Id("secure_boot"), _("Enable &Secure Boot Support"))
            ),
          )
        )
      )
    )
  )

  {
    "widget"        => :custom,
    "custom_widget" => contents,
    "init"          => fun_ref(
      method(:InitSecureBootWidget),
      "void (string)"
    ),
    "handle"        => fun_ref(
      method(:HandleSecureBootWidget),
      "symbol (string, map)"
    ),
    "store"         => fun_ref(
      method(:StoreSecureBootWidget),
      "void (string, map)"
    ),
    "help"          => HelpSecureBootWidget()
  }
end

- (Object) Grub2TabDescr



120
121
122
123
124
# File 'src/include/bootloader/grub2/dialogs.rb', line 120

def Grub2TabDescr
  tabs = [ bootloader_tab, kernel_tab, boot_code_tab]

  Hash[tabs.map{|tab| [tab["id"], tab]}]
end

- (Object) grub2Widgets

Get generic widgets

Returns:

  • a map describing all generic widgets



288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
# File 'src/include/bootloader/grub2/dialogs.rb', line 288

def grub2Widgets
  if @_grub2_widgets == nil
    case Arch.architecture
    when "i386", "x86_64"
      @_grub2_widgets = { "loader_location" => grubBootLoaderLocationWidget }
    when /ppc/
      @_grub2_widgets = { "loader_location" => grub_on_ppc_location }
    when /s390/
      @_grub2_widgets = {} #no loader location for s390 as it is automatic
    else
      raise "unsuppoted architecture #{Arch.architecture}"
    end
    @_grub2_widgets.merge! Grub2Options()
  end
  deep_copy(@_grub2_widgets)
end

- (Object) grub_on_ppc_location



256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
# File 'src/include/bootloader/grub2/dialogs.rb', line 256

def grub_on_ppc_location
  contents = VBox(
    VSpacing(1),
    ComboBox(
      Id("boot_custom_list"),
      # TRANSLATORS: place where boot code is installed
      _("Boot &Loader Location"),
      prep_partitions
    )
  )

  {
     # need custom to not break ui as intel one is quite complex so some
     # spacing is needed
    "widget"        => :custom,
    "custom_widget" => contents,
    "init"          => fun_ref(
      method(:ppc_location_init),
      "void (string)"
    ),
    "store"         => fun_ref(
      method(:ppc_location_store),
      "void (string, map)"
    ),
    # help text
    "help"          => _("Choose partition where is boot sequence installed.")
  }

end

- (Object) HandleSecureBootWidget(widget, event)



163
164
165
166
# File 'src/include/bootloader/grub2/dialogs.rb', line 163

def HandleSecureBootWidget(widget, event)
  event = deep_copy(event)
  nil
end

- (Object) HelpSecureBootWidget



174
175
176
177
# File 'src/include/bootloader/grub2/dialogs.rb', line 174

def HelpSecureBootWidget
  ret = "Tick to enable UEFI Secure Boot\n"
  ret
end

- (Object) initialize_bootloader_grub2_dialogs(include_target)



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'src/include/bootloader/grub2/dialogs.rb', line 19

def initialize_bootloader_grub2_dialogs(include_target)
  Yast.import "UI"

  textdomain "bootloader"


  Yast.import "Arch"
  Yast.import "Label"
  Yast.import "Wizard"
  Yast.import "CWM"
  Yast.import "CWMTab"
  Yast.import "BootCommon"
  Yast.import "Stage"

  Yast.include include_target, "bootloader/grub2/options.rb"
  # some utils from misc are needed here
  Yast.include include_target, "bootloader/grub2/misc.rb"

  Yast.include include_target, "bootloader/grub/options.rb"

  # Cache for genericWidgets function
  @_grub2_widgets = nil
  @_grub2_efi_widgets = nil
end

- (Object) InitSecureBootWidget(widget)



157
158
159
160
161
162
# File 'src/include/bootloader/grub2/dialogs.rb', line 157

def InitSecureBootWidget(widget)
  sb = BootCommon.getSystemSecureBootStatus(false)
  UI.ChangeWidget(Id("secure_boot"), :Value, sb)

  nil
end

- (Object) kernel_tab



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'src/include/bootloader/grub2/dialogs.rb', line 74

def kernel_tab
  widgets = ["vgamode", "append", "append_failsafe", "console"]
  widgets.delete("console") if Arch.s390 # there is no console on s390 (bnc#868909)
  widgets.delete("vgamode") if Arch.s390 # there is no graphic adapter on s390 (bnc#874010)

   {
    "id"           => "kernel_tab",
    # Title in tab
    "header"       => _("Kernel Parameters"),
    "widget_names" => widgets,
    "contents"      => VBox(
      VSpacing(1),
      MarginBox(1, 0.5, "vgamode"),
      MarginBox(1, 0.5, "append"),
      MarginBox(1, 0.5, "append_failsafe"),
      MarginBox(1, 0.5, "console"),
      VStretch()
    )
  }
end

- (Object) ppc_location_init(widget)



238
239
240
241
242
243
244
# File 'src/include/bootloader/grub2/dialogs.rb', line 238

def ppc_location_init(widget)
  UI::ChangeWidget(
    Id("boot_custom_list"),
    :Value,
    BootCommon.globals["boot_custom"]
  )
end

- (Object) ppc_location_store(widget, value)



246
247
248
249
250
251
252
253
254
# File 'src/include/bootloader/grub2/dialogs.rb', line 246

def ppc_location_store(widget, value)
  value = UI::QueryWidget(
    Id("boot_custom_list"),
    :Value,
  )
  y2milestone("store boot custom #{value}")

  BootCommon.globals["boot_custom"] = value
end

- (Object) StoreSecureBootWidget(widget, event)



167
168
169
170
171
172
173
# File 'src/include/bootloader/grub2/dialogs.rb', line 167

def StoreSecureBootWidget(widget, event)
  event = deep_copy(event)
  sb = Convert.to_boolean(UI.QueryWidget(Id("secure_boot"), :Value))
  BootCommon.setSystemSecureBootStatus(sb)

  nil
end