• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

yast / yast-bootloader / 14702893520

28 Apr 2025 07:46AM UTC coverage: 87.417%. Remained the same
14702893520

push

github

schubi2
adapting menu-force

0 of 2 new or added lines in 2 files covered. (0.0%)

3418 of 3910 relevant lines covered (87.42%)

12.99 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

88.1
/src/lib/bootloader/systemdboot_widgets.rb
1
# frozen_string_literal: true
2

3
require "yast"
1✔
4
require "bootloader/generic_widgets"
1✔
5
require "bootloader/systeminfo"
1✔
6
require "bootloader/pmbr"
1✔
7

8
Yast.import "UI"
1✔
9
Yast.import "Arch"
1✔
10

11
module Bootloader
1✔
12
  module SystemdBootWidget
1✔
13
    # Adds to generic widget systemd-boot specific helpers
14
    module SystemdBootHelper
1✔
15
      def systemdboot
1✔
16
        BootloaderFactory.current
5✔
17
      end
18
    end
19

20
    # Represents bootloader timeout value
21
    class TimeoutWidget < CWM::CustomWidget
1✔
22
      include SystemdBootHelper
1✔
23

24
      def initialize
1✔
25
        textdomain "bootloader"
11✔
26

27
        super()
11✔
28

29
        @minimum = 0
11✔
30
        @maximum = 600
11✔
31
        @default = 10
11✔
32
      end
33

34
      attr_reader :minimum, :maximum, :default
1✔
35

36
      def contents
1✔
37
        CheckBoxFrame(
2✔
38
          Id(:cont_boot),
39
          _("Automatically boot the default entry after a timeout"),
40
          false,
41
          HBox(
42
            IntField(Id(:seconds), _("&Timeout in Seconds"), @minimum, @maximum,
43
              systemdboot.menu_timeout.to_i),
44
            HStretch()
45
          )
46
        )
47
      end
48

49
      def help
1✔
50
        _("<p>Continue boot process after defined seconds.</p>" \
1✔
51
          "<p><b>Timeout in Seconds</b>\n" \
52
          "specifies the time the boot loader will wait until the default kernel is loaded.</p>\n")
53
      end
54

55
      def init
1✔
56
        Yast::UI.ChangeWidget(Id(:cont_boot), :Value, systemdboot.menu_timeout >= 0)
×
NEW
57
        systemdboot.menu_timeout = default_value if systemdboot.menu_timeout < -1
×
58
        Yast::UI.ChangeWidget(Id(:seconds), :Value, systemdboot.menu_timeout)
×
59
      end
60

61
      def store
1✔
62
        cont_boot = Yast::UI.QueryWidget(Id(:cont_boot), :Value)
1✔
63
        systemdboot.menu_timeout = cont_boot ? Yast::UI.QueryWidget(Id(:seconds), :Value) : -1
1✔
64
      end
65

66
    private
1✔
67

68
      def default_value
1✔
69
        # set default
70
        ret = Yast::ProductFeatures.GetIntegerFeature("globals",
×
71
          "boot_timeout").to_i
72
        ret = @default if ret <= 0
×
73
        ret
×
74
      end
75
    end
76

77
    # Represents switcher for secure boot on EFI
78
    class SecureBootWidget < CWM::CheckBox
1✔
79
      include SystemdBootHelper
1✔
80

81
      def initialize
1✔
82
        textdomain "bootloader"
4✔
83

84
        super
4✔
85
      end
86

87
      def label
1✔
88
        _("&Secure Boot Support")
1✔
89
      end
90

91
      def help
1✔
92
        _(
1✔
93
          "<p><b>Secure Boot Support</b> if checked enables Secure Boot support.<br>" \
94
          "This does not turn on secure booting. " \
95
          "It only sets up the boot loader in a way that supports secure booting. " \
96
          "You still have to enable Secure Boot in the UEFI Firmware.</p> "
97
        )
98
      end
99

100
      def init
1✔
101
        self.value = systemdboot.secure_boot
1✔
102
      end
103

104
      def store
1✔
105
        systemdboot.secure_boot = value
1✔
106
      end
107
    end
108

109
    # represents Tab with kernel related configuration
110
    class KernelTab < CWM::Tab
1✔
111
      def label
1✔
112
        textdomain "bootloader"
1✔
113

114
        _("&Kernel Parameters")
1✔
115
      end
116

117
      def contents
1✔
118
        VBox(
1✔
119
          VSpacing(1),
120
          MarginBox(1, 0.5, KernelAppendWidget.new),
121
          MarginBox(1, 0.5, Left(CpuMitigationsWidget.new)),
122
          VStretch()
123
        )
124
      end
125
    end
126

127
    # Represent tab with options related to stage1 location and bootloader type
128
    class BootCodeTab < CWM::Tab
1✔
129
      include SystemdBootHelper
1✔
130

131
      def label
1✔
132
        textdomain "bootloader"
1✔
133

134
        _("Boot Co&de Options")
1✔
135
      end
136

137
      def contents
1✔
138
        VBox(
1✔
139
          VSpacing(1),
140
          HBox(
141
            HSpacing(1),
142
            Left(LoaderTypeWidget.new)
143
          ),
144
          VSpacing(1),
145
          *widgets,
146
          VSpacing(1),
147
          pmbr_widget,
148
          VStretch()
149
        )
150
      end
151

152
    private
1✔
153

154
      def widgets
1✔
155
        w = []
1✔
156
        if Yast::Stage.initial && # while new installation only (currently)
1✔
157
            secure_boot_widget?
158
          w << SecureBootWidget.new
×
159
        end
160

161
        w.map do |widget|
1✔
162
          MarginBox(horizontal_margin, 0, Left(widget))
×
163
        end
164
      end
165

166
      def pmbr_widget
1✔
167
        return Empty() unless pmbr_widget?
1✔
168

169
        MarginBox(1, 0, Left(PMBRWidget.new))
1✔
170
      end
171

172
      def horizontal_margin
1✔
173
        @horizontal_margin ||= Yast::UI.TextMode ? 1 : 1.5
×
174
      end
175

176
      def secure_boot_widget?
1✔
177
        Systeminfo.secure_boot_available?(systemdboot.name)
×
178
      end
179

180
      def pmbr_widget?
1✔
181
        Pmbr.available?
1✔
182
      end
183
    end
184

185
    # Represents bootloader specific options like its timeout,
186
    # default section or password protection
187
    class BootloaderTab < CWM::Tab
1✔
188
      def label
1✔
189
        textdomain "bootloader"
1✔
190

191
        _("Boot&loader Options")
1✔
192
      end
193

194
      def contents
1✔
195
        VBox(
1✔
196
          VSpacing(2),
197
          HBox(
198
            HSpacing(1),
199
            TimeoutWidget.new,
200
            HSpacing(1)
201
          ),
202
          VStretch()
203
        )
204
      end
205
    end
206
  end
207
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc