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

Using BLS bootloader as default. #1396

Open
wants to merge 34 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
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
13 changes: 13 additions & 0 deletions src/lib/y2storage/boot_requirements_checker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ def strategy_class
BootRequirementsStrategies::NfsRoot
elsif raspberry_pi?
BootRequirementsStrategies::Raspi
elsif bls?
BootRequirementsStrategies::BLS
schubi2 marked this conversation as resolved.
Show resolved Hide resolved
else
arch_strategy_class
end
Expand All @@ -148,6 +150,17 @@ def arch_strategy_class
end
end

# Whether BLS boot will be used for booting
#
# @return [Boolean]
def bls?
Yast.import "Linuxrc"
schubi2 marked this conversation as resolved.
Show resolved Hide resolved

arch.efiboot? &&
(Yast::Linuxrc.InstallInf("NO_BLS_BOOT").nil? ||
Yast::Linuxrc.InstallInf("NO_BLS_BOOT") != 1)
end

# Whether the root filesystem is NFS
#
# @return [Boolean]
Expand Down
1 change: 1 addition & 0 deletions src/lib/y2storage/boot_requirements_strategies.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@
require "y2storage/boot_requirements_strategies/zipl"
require "y2storage/boot_requirements_strategies/nfs_root"
require "y2storage/boot_requirements_strategies/raspi"
require "y2storage/boot_requirements_strategies/bls"
47 changes: 47 additions & 0 deletions src/lib/y2storage/boot_requirements_strategies/bls.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Copyright (c) [2024] SUSE LLC
#
# All Rights Reserved.
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of version 2 of the GNU General Public License as published
# by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, contact SUSE LLC.
#
# To contact SUSE LLC about this file by physical or electronic mail, you may
# find current contact information at www.suse.com.

require "y2storage/boot_requirements_strategies/uefi"

module Y2Storage
module BootRequirementsStrategies
# Strategy to calculate boot requirements in BLS/UEFI systems
class BLS < UEFI
def initialize(*args)
textdomain "storage"
super
end

private

# @return [VolumeSpecification]
def efi_volume
if @efi_volume.nil?
@efi_volume = volume_specification_for("/boot/efi")
# BLS needs 1GiB for boot at least
# https://uapi-group.org/specifications/specs/boot_loader_specification/
@efi_volume.min_size = DiskSize.GiB(1)
schubi2 marked this conversation as resolved.
Show resolved Hide resolved
@efi_volume.desired_size = DiskSize.GiB(1)
@efi_volume.max_size = DiskSize.GiB(1)
end
@efi_volume
end
end
end
end
20 changes: 11 additions & 9 deletions src/lib/y2storage/boot_requirements_strategies/uefi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,17 @@ def warnings
res + res_new
end

private

# @return [VolumeSpecification]
schubi2 marked this conversation as resolved.
Show resolved Hide resolved
def efi_volume
if @efi_volume.nil?
@efi_volume = volume_specification_for("/boot/efi")
limit_volume_size_to_min(@efi_volume) if Yast::Arch.aarch64 # bsc#1119318
end
@efi_volume
end

protected

def esp_encrypted_error
Expand Down Expand Up @@ -111,15 +122,6 @@ def valid_esp_configured?
!missing_partition_for?(efi_volume, exclude: :size)
end

# @return [VolumeSpecification]
def efi_volume
if @efi_volume.nil?
@efi_volume = volume_specification_for("/boot/efi")
limit_volume_size_to_min(@efi_volume) if Yast::Arch.aarch64 # bsc#1119318
end
@efi_volume
end

# Adjusts the given volume specification to enforce a minimal device that
# never grows beyond its minimum size
#
Expand Down
20 changes: 20 additions & 0 deletions test/support/proposed_partitions_examples.rb
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,26 @@
end
end

RSpec.shared_examples "EFI partition for BLS bootloaders" do
using Y2Storage::Refinements::SizeCasts

context "when aiming for the recommended size" do
let(:target) { :desired }

it "requires /boot/efi to use FAT32" do
expect(efi_part.mkfs_options).to include "-F32"
end

it "requires it to be at least 1 GiB" do
schubi2 marked this conversation as resolved.
Show resolved Hide resolved
expect(efi_part.min).to eq 1.GiB
end

it "requires it to be at most 1 GiB (enough space for all BLS entries)" do
expect(efi_part.max).to eq 1.GiB
end
end
end

RSpec.shared_examples "minimalistic EFI partition" do
using Y2Storage::Refinements::SizeCasts

Expand Down
19 changes: 18 additions & 1 deletion test/y2storage/boot_requirements_checker_x86_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -290,14 +290,31 @@
end

context "when proposing a new EFI partition" do

schubi2 marked this conversation as resolved.
Show resolved Hide resolved
let(:efi_part) { find_vol("/boot/efi", checker.needed_partitions(target)) }
let(:desired_efi_part) { find_vol("/boot/efi", checker.needed_partitions(:desired)) }
# Default values to ensure proposal of EFI partition
let(:efiboot) { true }
let(:efi_partitions) { [] }

include_examples "proposed EFI partition basics"
include_examples "flexible size EFI partition"

context "and BLS bootloader as default" do
schubi2 marked this conversation as resolved.
Show resolved Hide resolved
before do
allow(Yast::Linuxrc).to receive(:InstallInf).with("NO_BLS_BOOT").and_return(0)
end

include_examples "EFI partition for BLS bootloaders"
end

context "and no BLS bootloader as default" do
schubi2 marked this conversation as resolved.
Show resolved Hide resolved
before do
allow(Yast::Linuxrc).to receive(:InstallInf).with("NO_BLS_BOOT").and_return(1)
end

include_examples "flexible size EFI partition"
end

end
end
end
Expand Down
Loading