Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

patch to not show popup when editenv list failed #537

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/lib/bootloader/sections.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,11 @@ def write
# or something goes wrong
# @note shows error popup if calling grub2-editenv failed
def read_default
# 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) || ""
saved = Yast::SCR.Execute(
Yast::Path.new(".target.bash_output"),
"/usr/bin/grub2-editenv list"
)
saved = saved["exit"] == 0 ? saved["stdout"] : ""
saved_line = saved.lines.grep(/saved_entry=/).first || ""

default_path = saved_line[/saved_entry=(.*)$/, 1]
Expand Down
12 changes: 6 additions & 6 deletions test/sections_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@

describe "#default" do
it "gets name of default section stored in grub2" do
expect(Yast::Execute).to receive(:on_target)
.with("/usr/bin/grub2-editenv", "list", stdout: :capture)
.and_return("saved_entry=alien>windows\nbla_bla=no\n")
expect(Yast::SCR).to receive(:Execute)
.with(anything, "/usr/bin/grub2-editenv list")
.and_return("exit" => 0, "stdout" => "saved_entry=alien>windows\nbla_bla=no\n")

expect(subject.default).to eq "windows"
end

it "gets first section if nothing stored in grub2" do
expect(Yast::Execute).to receive(:on_target)
.with("/usr/bin/grub2-editenv", "list", stdout: :capture)
.and_return("\n")
expect(Yast::SCR).to receive(:Execute)
.with(anything, "/usr/bin/grub2-editenv list")
.and_return("exit" => 0, "stdout" => "\n")

expect(subject.default).to eq "linux"
end
Expand Down