Skip to content

Commit

Permalink
grub2bls
Browse files Browse the repository at this point in the history
rubocop

rubocop

rubocop

rubocop

rubocop

docu

added yast-bootloader

added yast-bootloader
  • Loading branch information
schubi2 committed Nov 13, 2024
1 parent d9d0d4d commit 8cfcb3a
Show file tree
Hide file tree
Showing 6 changed files with 472 additions and 1,057 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ that holds and also can propose the bootloader implementation. So now let's expl

- [GRUB2](https://www.rubydoc.info/github/yast/yast-bootloader/master/Bootloader/Grub2) for legacy booting or emulated grub2 boot like s390x.
- [GRUB2-EFI](https://www.rubydoc.info/github/yast/yast-bootloader/master/Bootloader/Grub2EFI) for EFI variant of GRUB2 bootloader
- [GRUB2-BLS](https://www.rubydoc.info/github/yast/yast-bootloader/master/Bootloader/Grub2Bls) bootloader based on Boot Loader Specification(BLS) (for EFI only)
- [systemd-boot](https://www.rubydoc.info/github/yast/yast-bootloader/master/Bootloader/SystemdBoot) systemd bootloader (for EFI only)
- [None](https://www.rubydoc.info/github/yast/yast-bootloader/master/Bootloader/NoneBootloader) when YaST does not manage booting
- [GRUB2 base](https://www.rubydoc.info/github/yast/yast-bootloader/master/Bootloader/Grub2Base) is the shared functionality for both GRUB2 implementations
Expand Down
1,490 changes: 446 additions & 1,044 deletions doc/bootloader_backend.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions src/lib/bootloader/bootloader_base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@
module Bootloader
# Represents base for all kinds of bootloaders
class BootloaderBase
include Yast::I18n

def initialize
textdomain "bootloader"

@read = false
@proposed = false
@initial_sysconfig = Sysconfig.from_system
Expand Down
26 changes: 13 additions & 13 deletions test/bls_sections_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,42 +10,42 @@

before do
allow(Yast::Misc).to receive(:CustomSysconfigRead)
.with("ID_LIKE", "openSUSE", "/etc/os-release")
.and_return("openSUSE")
.with("ID_LIKE", "openSUSE", "/etc/os-release")
.and_return("openSUSE")
end

describe "#read" do
before do
allow(Yast::Execute).to receive(:on_target)
allow(Yast::Execute).to receive(:on_target)
.with("/usr/bin/bootctl", "--json=short", "list", stdout: :capture)
.and_return("[{\"title\" : \"openSUSE Tumbleweed\", \"isDefault\" : true }," \
"{\"title\" : \"Snapper: *openSUSE Tumbleweed 20241107\", \"isDefault\" : false}]")
allow(Yast::Misc).to receive(:CustomSysconfigRead)
allow(Yast::Misc).to receive(:CustomSysconfigRead)
.with("default", "", "/boot/efi/EFI/openSUSE/grubenv")
.and_return("openSUSE Tumbleweed")
subject.read
subject.read
end

it "returns list of all available sections" do
expect(subject.all).to eq(["openSUSE Tumbleweed", "Snapper: *openSUSE Tumbleweed 20241107"])
end

it "reads default menu entry" do
expect(subject.default).to eq("openSUSE Tumbleweed")
expect(subject.default).to eq("openSUSE Tumbleweed")
end
end

describe "#default=" do
before do
allow(Yast::Execute).to receive(:on_target)
allow(Yast::Execute).to receive(:on_target)
.with("/usr/bin/bootctl", "--json=short", "list", stdout: :capture)
.and_return("[{\"title\" : \"openSUSE Tumbleweed\", \"isDefault\" : true }," \
"{\"title\" : \"Snapper: *openSUSE Tumbleweed 20241107\", \"isDefault\" : false}]")
allow(Yast::Misc).to receive(:CustomSysconfigRead)
allow(Yast::Misc).to receive(:CustomSysconfigRead)
.with("default", "", "/boot/efi/EFI/openSUSE/grubenv")
.and_return("openSUSE Tumbleweed")
subject.read
end
subject.read
end
it "sets new value for default" do
subject.default = "Snapper: *openSUSE Tumbleweed 20241107"
expect(subject.default).to eq "Snapper: *openSUSE Tumbleweed 20241107"
Expand All @@ -61,16 +61,16 @@
it "writes default value if set" do
subject.default = "Snapper: *openSUSE Tumbleweed 20241107"
expect(Yast::Execute).to receive(:on_target)
.with("/usr/bin/sdbootutil", "set-default", subject.default, {:allowed_exitstatus=>[0, 1]})
.with("/usr/bin/sdbootutil", "set-default", subject.default, { :allowed_exitstatus=>[0, 1] })
subject.write
end

it "does not write default value if not set" do
subject.default = ""
expect(Yast::Execute).to_not receive(:on_target)
.with("/usr/bin/sdbootutil", "set-default", subject.default, {:allowed_exitstatus=>[0, 1]})
.with("/usr/bin/sdbootutil", "set-default", subject.default, { :allowed_exitstatus=>[0, 1] })
subject.write
end
end

end
end
7 changes: 7 additions & 0 deletions test/boot_support_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@
expect(subject.SystemSupported).to eq false
end

it "returns false if grub2-bls is used and UEFI is not supported" do
Bootloader::BootloaderFactory.current_name = "grub2-bls"
allow(subject).to receive(:efi?).and_return(false)

expect(subject.SystemSupported).to eq false
end

it "returns false if systemd-boot is used and UEFI is not supported" do
Bootloader::BootloaderFactory.current_name = "systemd-boot"
allow(subject).to receive(:efi?).and_return(false)
Expand Down
1 change: 1 addition & 0 deletions test/grub2_bls_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
describe "#packages" do
it "adds grub2* and sdbootutil packages" do
allow(Yast::Arch).to receive(:architecture).and_return("x86_64")
allow(Yast::Package).to receive(:Available).with("os-prober").and_return(true)
expect(subject.packages).to include("grub2-" + Yast::Arch.architecture + "-efi-bls")
expect(subject.packages).to include("sdbootutil")
expect(subject.packages).to include("grub2")
Expand Down

0 comments on commit 8cfcb3a

Please sign in to comment.