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

yast / yast-bootloader / 12048550996

27 Nov 2024 10:37AM UTC coverage: 87.484% (+0.1%) from 87.378%
12048550996

Pull #708

github

schubi2
cleanup
Pull Request #708: Supporting Grub2-BLS

210 of 240 new or added lines in 13 files covered. (87.5%)

88 existing lines in 7 files now uncovered.

3362 of 3843 relevant lines covered (87.48%)

13.0 hits per line

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

87.18
/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

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

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

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

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

26
        super()
11✔
27

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

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

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

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

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

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

65
    private
1✔
66

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

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

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

83
        super
4✔
84
      end
85

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

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

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

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

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

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

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

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

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

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

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

149
    private
1✔
150

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

158
        w.map do |widget|
1✔
UNCOV
159
          MarginBox(horizontal_margin, 0, Left(widget))
×
160
        end
161
      end
162

163
      def horizontal_margin
1✔
UNCOV
164
        @horizontal_margin ||= Yast::UI.TextMode ? 1 : 1.5
×
165
      end
166

167
      def secure_boot_widget?
1✔
168
        Systeminfo.secure_boot_available?(systemdboot.name)
×
169
      end
170
    end
171

172
    # Represents bootloader specific options like its timeout,
173
    # default section or password protection
174
    class BootloaderTab < CWM::Tab
1✔
175
      def label
1✔
176
        textdomain "bootloader"
1✔
177

178
        _("Boot&loader Options")
1✔
179
      end
180

181
      def contents
1✔
182
        VBox(
1✔
183
          VSpacing(2),
184
          HBox(
185
            HSpacing(1),
186
            TimeoutWidget.new,
187
            HSpacing(1)
188
          ),
189
          VStretch()
190
        )
191
      end
192
    end
193
  end
194
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

© 2025 Coveralls, Inc