-
Notifications
You must be signed in to change notification settings - Fork 23
/
config_dialog.rb
112 lines (94 loc) · 3.37 KB
/
config_dialog.rb
1
2
3
4
5
6
7
8
9
10
11
12
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
39
40
41
42
43
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# frozen_string_literal: true
require "yast"
require "bootloader/bootloader_factory"
require "bootloader/none_bootloader"
require "bootloader/grub2_widgets"
require "bootloader/systemdboot_widgets"
Yast.import "BootStorage"
Yast.import "CWMTab"
Yast.import "CWM"
Yast.import "Mode"
Yast.import "Popup"
module Bootloader
# Dialog for whole bootloader configuration
class ConfigDialog
include Yast::Logger
include Yast::I18n
include Yast::UIShortcuts
# param initial_tab [:boot_code|:kernel|:bootloader] initial tab when dialog open
def initialize(initial_tab: :boot_code)
@initial_tab = initial_tab
end
def run
guarded_run
rescue ::Bootloader::NoRoot
Yast::Report.Error(
_("YaST cannot configure the bootloader because it failed to find the root file system.")
)
:abort
rescue ::Bootloader::BrokenConfiguration, ::Bootloader::UnsupportedOption => e
msg = if e.is_a?(::Bootloader::BrokenConfiguration)
# TRANSLATORS: %s stands for readon why yast cannot process it
_("YaST cannot process current bootloader configuration (%s). " \
"Propose new configuration from scratch?") % e.reason
else
e.message
end
ret = Yast::Report.AnyQuestion(_("Unsupported Configuration"),
msg,
_("Propose"),
_("Quit"),
:yes) # focus proposing new one
return :abort unless ret
::Bootloader::BootloaderFactory.current = ::Bootloader::BootloaderFactory.proposed
::Bootloader::BootloaderFactory.current.propose
retry
end
private
def guarded_run
textdomain "bootloader"
log.info "Running Main Dialog"
# F#300779 - Install diskless client (NFS-root)
# additional warning that root partition is nfs type -> bootloader will not be installed
nfs = Yast::BootStorage.boot_filesystem.is?(:nfs)
if nfs && Yast::Mode.installation
Yast::Popup.Message(
_(
"The boot partition is of type NFS. Bootloader cannot be installed."
)
)
log.info "Boot partition is nfs type, bootloader will not be installed."
return :next
end
# F#300779: end
Yast::CWM.show(
contents,
caption: _("Boot Loader Settings"),
back_button: "",
abort_button: Yast::Label.CancelButton,
next_button: Yast::Label.OKButton,
skip_store_for: [:redraw]
)
end
def contents
return VBox(LoaderTypeWidget.new) if BootloaderFactory.current.is_a?(NoneBootloader)
if BootloaderFactory.current.is_a?(SystemdBoot)
boot_code_tab = ::Bootloader::SystemdBootWidget::BootCodeTab.new
kernel_tab = ::Bootloader::SystemdBootWidget::KernelTab.new
bootloader_tab = ::Bootloader::SystemdBootWidget::BootloaderTab.new
else
boot_code_tab = ::Bootloader::Grub2Widget::BootCodeTab.new
kernel_tab = ::Bootloader::Grub2Widget::KernelTab.new
bootloader_tab = ::Bootloader::Grub2Widget::BootloaderTab.new
end
case @initial_tab
when :boot_code then boot_code_tab.initial = true
when :kernel then kernel_tab.initial = true
when :bootloader then bootloader_tab.initial = true
else
raise "unknown initial tab #{@initial_tab.inspect}"
end
VBox(CWM::Tabs.new(boot_code_tab, kernel_tab, bootloader_tab))
end
end
end