Skip to content

Commit

Permalink
add SLE15 SP2 only workaround for arm to make also some strange firmw…
Browse files Browse the repository at this point in the history
…are work (bsc#1167015)
  • Loading branch information
jreidinger committed Apr 23, 2020
1 parent 53adfe9 commit 487e164
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
10 changes: 9 additions & 1 deletion src/lib/bootloader/grub_install.rb
Expand Up @@ -39,6 +39,13 @@ def execute(devices: [], secure_boot: false, trusted_boot: false)

if no_device_install?
Yast::Execute.on_target(cmd)
# workaround for arm on SLE15 SP2 (bsc#1167015)
# run grub2-install also non-removable if efi is there
if Yast::Arch.aarch64 && File.directory?("/sys/firmware/efi")
cmd.delete("--no-nvram")
cmd.delete("--removable")
Yast::Execute.on_target(cmd)
end
[]
else
return [] if devices.empty?
Expand Down Expand Up @@ -118,7 +125,8 @@ def removable_efi?
# working NVRAM, we either see no efivars at all (booted via non-EFI entry
# point) or there is no efi variable exposed. Install grub in the
# removable location there.
efi && Dir.glob("/sys/firmware/efi/efivars/*").empty?
# Workaround for SLE15 SP2 - run always as removable on arm (bsc#1167015)
Yast::Arch.aarch64 || (efi && Dir.glob("/sys/firmware/efi/efivars/*").empty?)
end

def no_device_install?
Expand Down
22 changes: 18 additions & 4 deletions test/grub_install_test.rb
Expand Up @@ -37,6 +37,10 @@ def expect_grub2_install(target, device: nil, removable: false)
end
end

before do
allow(::File).to receive(:directory?).and_return(false)
end

context "initialized with efi: true" do
subject { Bootloader::GrubInstall.new(efi: true) }

Expand All @@ -49,12 +53,12 @@ def expect_grub2_install(target, device: nil, removable: false)
subject.execute(secure_boot: true)
end

it "runs grub2-install with --suse-force-signed on aarch64" do
it "runs grub2-install with --suse-force-signed on aarch64 with secure boot" do
stub_arch("aarch64")
stub_efivars

expect(Yast::Execute).to receive(:on_target)
.with([/grub2-install/, anything, "--suse-force-signed", anything, anything])
.with([/grub2-install/, anything, "--suse-force-signed", anything, anything, anything, anything])

subject.execute(secure_boot: true)
end
Expand Down Expand Up @@ -92,7 +96,17 @@ def expect_grub2_install(target, device: nil, removable: false)
it "runs with target arm64-efi on aarch64" do
stub_arch("aarch64")
stub_efivars
expect_grub2_install("arm64-efi")
expect_grub2_install("arm64-efi", removable: true)

subject.execute(devices: [])
end

it "runs twice as removable and non removable on aarch64 with efi vars (bsc#1167015)" do
stub_arch("aarch64")
stub_efivars
allow(::File).to receive(:directory?).and_return(true)
expect_grub2_install("arm64-efi", removable: false)
expect_grub2_install("arm64-efi", removable: true)

subject.execute(devices: [])
end
Expand Down Expand Up @@ -133,7 +147,7 @@ def expect_grub2_install(target, device: nil, removable: false)

it "do not raise exception if secure_boot: true passed" do
stub_arch("x86_64")
expect { subject.execute(secure_boot: true) }.to_not raise_error(RuntimeError)
expect { subject.execute(secure_boot: true) }.to_not raise_error
end

it "runs for each device passed in devices" do
Expand Down

0 comments on commit 487e164

Please sign in to comment.