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
73
74
# 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 = ["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 || Arch.aarch64 ? Empty() : "loader_location"
        )
      ),
      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



96
97
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
# File 'src/include/bootloader/grub2/dialogs.rb', line 96

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),
        VBox(
          Left("os_prober"),
          VSpacing(1),
          Left("hiddenmenu")
        ),
        HSpacing(1)
      ),
      VSpacing(1),
      MarginBox(1, 1, "default"),
      MarginBox(1, 1, "password"),
      VStretch()
   )
  }
end

- (Object) grub2efiWidgets



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

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

  deep_copy(@_grub2_efi_widgets)
end

- (Symbol) Grub2LoaderDetailsDialog

Run dialog for loader installation details for Grub2

Returns:

  • (Symbol)

    for wizard sequencer



134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# File 'src/include/bootloader/grub2/dialogs.rb', line 134

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



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
215
216
217
218
219
220
221
# File 'src/include/bootloader/grub2/dialogs.rb', line 186

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



126
127
128
129
130
# File 'src/include/bootloader/grub2/dialogs.rb', line 126

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



272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
# File 'src/include/bootloader/grub2/dialogs.rb', line 272

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



241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
# File 'src/include/bootloader/grub2/dialogs.rb', line 241

def grub_on_ppc_location
  contents = VBox(
    VSpacing(1),
    ComboBox(
      Id("boot_custom_list"),
      # TRANSLATORS: place where boot code is installed
      _("Boot &Loader Location"),
      BootStorage.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)



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

def HandleSecureBootWidget(_widget, _event)
  nil
end

- (Object) HelpSecureBootWidget



181
182
183
184
# File 'src/include/bootloader/grub2/dialogs.rb', line 181

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 "BootStorage"
  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)



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

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

  nil
end

- (Object) kernel_tab



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

def kernel_tab
  widgets = ["vgamode", "append", "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, "console"),
      VStretch()
   )
  }
end

- (Object) ppc_location_init(_widget)



223
224
225
226
227
228
229
# File 'src/include/bootloader/grub2/dialogs.rb', line 223

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

- (Object) ppc_location_store(_widget, value)



231
232
233
234
235
236
237
238
239
# File 'src/include/bootloader/grub2/dialogs.rb', line 231

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)



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

def StoreSecureBootWidget(_widget, _event)
  sb = Convert.to_boolean(UI.QueryWidget(Id("secure_boot"), :Value))
  BootCommon.setSystemSecureBootStatus(sb)

  nil
end