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

yast / yast-bootloader / 8848983076

26 Apr 2024 01:21PM UTC coverage: 87.52% (+0.1%) from 87.387%
8848983076

Pull #700

github

web-flow
Merge a3e40b0cc into 3a16f9bd6
Pull Request #700: Kernel parameters for systemd-boot

108 of 119 new or added lines in 6 files covered. (90.76%)

68 existing lines in 4 files now uncovered.

3247 of 3710 relevant lines covered (87.52%)

13.03 hits per line

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

88.17
/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/cpu_mitigations"
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
8✔
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.menue_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.menue_timeout >= 0)
×
57
        systemdboot.menue_timeout = default_value if systemdboot.menue_timeout < 0
×
UNCOV
58
        Yast::UI.ChangeWidget(Id(:seconds), :Value, systemdboot.menue_timeout)
×
59
      end
60

61
      def store
1✔
62
        cont_boot = Yast::UI.QueryWidget(Id(:cont_boot), :Value)
1✔
63
        systemdboot.menue_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
UNCOV
70
        ret = Yast::ProductFeatures.GetIntegerFeature("globals",
×
71
          "boot_timeout").to_i
72
        ret = @default if ret <= 0
×
UNCOV
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 decision if smt is enabled
110
    class SdCpuMitigationsWidget < CpuMitigationsWidget
1✔
111
      include SystemdBootHelper
1✔
112

113
      def init
1✔
114
        if systemdboot.respond_to?(:cpu_mitigations)
1✔
NEW
UNCOV
115
          self.value = systemdboot.cpu_mitigations.value.to_s
×
116
        else
117
          # do not crash when use no bootloader. This widget is also used in security dialog.
118
          # (bsc#1184968)
119
          disable
1✔
120
        end
121
      end
122

123
      def store
1✔
124
        systemdboot.cpu_mitigations = ::Bootloader::CpuMitigations.new(value.to_sym) if enabled?
1✔
125
      end
126
    end
127

128
    # represents kernel command line
129
    class SdKernelAppendWidget < KernelAppendWidget
1✔
130
      include SystemdBootHelper
1✔
131

132
      def init
1✔
133
        self.value = systemdboot.kernel_params.serialize.gsub(/mitigations=\S+/, "")
1✔
134
      end
135

136
      def store
1✔
137
        systemdboot.kernel_params.replace(value)
1✔
138
      end
139
    end
140

141
    # represents Tab with kernel related configuration
142
    class KernelTab < CWM::Tab
1✔
143
      def label
1✔
144
        textdomain "bootloader"
1✔
145

146
        _("&Kernel Parameters")
1✔
147
      end
148

149
      def contents
1✔
150
        VBox(
1✔
151
          VSpacing(1),
152
          MarginBox(1, 0.5, SdKernelAppendWidget.new),
153
          MarginBox(1, 0.5, Left(SdCpuMitigationsWidget.new)),
154
          VStretch()
155
        )
156
      end
157
    end
158

159
    # Represent tab with options related to stage1 location and bootloader type
160
    class BootCodeTab < CWM::Tab
1✔
161
      include SystemdBootHelper
1✔
162

163
      def label
1✔
164
        textdomain "bootloader"
1✔
165

166
        _("Boot Co&de Options")
1✔
167
      end
168

169
      def contents
1✔
170
        VBox(
1✔
171
          VSpacing(1),
172
          HBox(
173
            HSpacing(1),
174
            Left(LoaderTypeWidget.new)
175
          ),
176
          VSpacing(1),
177
          *widgets,
178
          VStretch()
179
        )
180
      end
181

182
    private
1✔
183

184
      def widgets
1✔
185
        w = []
1✔
186
        if Yast::Stage.initial && # while new installation only (currently)
1✔
187
            secure_boot_widget?
UNCOV
188
          w << SecureBootWidget.new
×
189
        end
190

191
        w.map do |widget|
1✔
UNCOV
192
          MarginBox(horizontal_margin, 0, Left(widget))
×
193
        end
194
      end
195

196
      def horizontal_margin
1✔
UNCOV
197
        @horizontal_margin ||= Yast::UI.TextMode ? 1 : 1.5
×
198
      end
199

200
      def secure_boot_widget?
1✔
UNCOV
201
        Systeminfo.secure_boot_available?(systemdboot.name)
×
202
      end
203
    end
204

205
    # Represents bootloader specific options like its timeout,
206
    # default section or password protection
207
    class BootloaderTab < CWM::Tab
1✔
208
      def label
1✔
209
        textdomain "bootloader"
1✔
210

211
        _("Boot&loader Options")
1✔
212
      end
213

214
      def contents
1✔
215
        VBox(
1✔
216
          VSpacing(2),
217
          HBox(
218
            HSpacing(1),
219
            TimeoutWidget.new,
220
            HSpacing(1)
221
          ),
222
          VStretch()
223
        )
224
      end
225
    end
226
  end
227
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