Skip to content

Commit

Permalink
Feature: Do not timeout boot menue in systemd-boot. (bsc#1216366) (#695)
Browse files Browse the repository at this point in the history
* Feature: Do not timeout boot menue in systemd-boot. (bsc#1216366)
  • Loading branch information
schubi2 committed Feb 29, 2024
1 parent 0808245 commit 8f097b7
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 18 deletions.
6 changes: 6 additions & 0 deletions package/yast2-bootloader.changes
@@ -1,3 +1,9 @@
-------------------------------------------------------------------
Mon Feb 26 13:30:54 UTC 2024 - Stefan Schubert <schubi@suse.com>

- Feature: Do not timeout boot menue in systemd-boot. (bsc#1216366)
- 5.0.6

-------------------------------------------------------------------
Tue Feb 20 07:42:45 UTC 2024 - Stefan Schubert <schubi@suse.com>

Expand Down
2 changes: 1 addition & 1 deletion package/yast2-bootloader.spec
Expand Up @@ -17,7 +17,7 @@


Name: yast2-bootloader
Version: 5.0.5
Version: 5.0.6
Release: 0
Summary: YaST2 - Bootloader Configuration
License: GPL-2.0-or-later
Expand Down
14 changes: 12 additions & 2 deletions src/lib/bootloader/systemdboot.rb
Expand Up @@ -164,12 +164,22 @@ def create_menue_entries

def read_menue_timeout
config = CFA::SystemdBoot.load
self.menue_timeout = config.menue_timeout.to_i if config.menue_timeout
return unless config.menue_timeout

self.menue_timeout = if config.menue_timeout == "menu-force"
-1
else
config.menue_timeout.to_i
end
end

def write_menue_timeout
config = CFA::SystemdBoot.load
config.menue_timeout = menue_timeout.to_s
config.menue_timeout = if menue_timeout == -1
"menu-force"
else
menue_timeout.to_s
end
config.save
end

Expand Down
43 changes: 35 additions & 8 deletions src/lib/bootloader/systemdboot_widgets.rb
Expand Up @@ -17,35 +17,62 @@ def systemdboot
end

# Represents bootloader timeout value
class TimeoutWidget < CWM::IntField
class TimeoutWidget < CWM::CustomWidget
include SystemdBootHelper

def initialize
textdomain "bootloader"

super()

@minimum = -1
@minimum = 0
@maximum = 600
@default = 10
end

attr_reader :minimum, :maximum
attr_reader :minimum, :maximum, :default

def label
_("&Timeout in Seconds")
def contents
CheckBoxFrame(
Id(:cont_boot),
_("Automatically boot the default entry after a timeout"),
false,
HBox(
IntField(Id(:seconds), _("&Timeout in Seconds"), @minimum, @maximum,
systemdboot.menue_timeout.to_i),
HStretch()
)
)
end

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

def init
self.value = systemdboot.menue_timeout.to_i
Yast::UI.ChangeWidget(Id(:cont_boot), :Value, systemdboot.menue_timeout >= 0)
systemdboot.menue_timeout = default_value if systemdboot.menue_timeout < 0
Yast::UI.ChangeWidget(Id(:seconds), :Value, systemdboot.menue_timeout)
end

def store
systemdboot.menue_timeout = value.to_s
if Yast::UI.QueryWidget(Id(:cont_boot), :Value)
systemdboot.menue_timeout = Yast::UI.QueryWidget(Id(:seconds), :Value)
else
systemdboot.menue_timeout = -1
end
end

private

def default_value
# set default
ret = Yast::ProductFeatures.GetIntegerFeature("globals",
"boot_timeout").to_i
ret = @default if ret <= 0
ret
end
end

Expand Down
24 changes: 17 additions & 7 deletions test/systemdboot_widgets_test.rb
Expand Up @@ -35,21 +35,31 @@ def stub_widget_value(id, value)
assign_systemd_bootloader
end

it_behaves_like "labeled widget"
it_behaves_like "CWM::CustomWidget"

it "has minimal value to -1 as unlimited" do
expect(subject.minimum).to eq(-1)
it "has minimal value to 0 as unlimited" do
expect(subject.minimum).to eq(0)
end

it "has maximum value to 600" do
expect(subject.maximum).to eq 600
end

it "is initialized to timeout value if defined" do
bootloader.menue_timeout = "10"
expect(subject).to receive(:value=).with(10)
it "has own complex content" do
expect(subject.contents).to be_a Yast::Term
end

subject.init
context "storing content" do
before do
stub_widget_value(:cont_boot, false)
stub_widget_value(:seconds, 15)
end

it "sets timeout to -1 for using menu-force" do
subject.store

expect(bootloader.menue_timeout).to eq(-1)
end
end
end

Expand Down

0 comments on commit 8f097b7

Please sign in to comment.