diff --git a/package/yast2-bootloader.spec b/package/yast2-bootloader.spec index df7c70bdc..699539049 100644 --- a/package/yast2-bootloader.spec +++ b/package/yast2-bootloader.spec @@ -40,7 +40,7 @@ Requires: yast2-core >= 2.18.7 Requires: yast2-packager >= 2.17.24 Requires: yast2-pkg-bindings >= 2.17.25 Requires: yast2-storage >= 2.18.18 -# GRUB_DEFAULT attribute +# GrubCfg with boot_entries that filter out unbootable entries Requires: rubygem(%rb_default_ruby_abi:cfa_grub2) >= 0.5.1 # lenses are needed as cfa_grub2 depends only on augeas bindings, but also # lenses are needed here diff --git a/src/lib/bootloader/sections.rb b/src/lib/bootloader/sections.rb index aa968ff30..cb0592052 100644 --- a/src/lib/bootloader/sections.rb +++ b/src/lib/bootloader/sections.rb @@ -23,7 +23,7 @@ def default return @default = "" if Yast::Stage.initial - default_path = read_default + default_path = read_default_path @default = default_path ? path_to_title(default_path) : all.first end @@ -48,7 +48,9 @@ def write private - def read_default + # @return [String, nil] return default boot path as string or nil if not set or something goes wrong + # @note shows error popup if calling grub2-editenv failed + def read_default_path # Execute.on_target can return nil if call failed. It shows users error popup, but bootloader # can continue with empty default section saved = Yast::Execute.on_target("/usr/bin/grub2-editenv", "list", stdout: :capture) || "" @@ -57,12 +59,16 @@ def read_default saved_line ? saved_line[/saved_entry=(.*)$/, 1] : nil end + # @return [String] convert grub boot path to title that can be displayed. If + # entry not found, then return argument def path_to_title(path) entry = @data.find { |e| e[:path] == path } entry ? entry[:title] : path end + # @return [String] convert displayable title to grub boot path. If + # entry not found, then return argument def title_to_path(title) entry = @data.find { |e| e[:title] == title }