Skip to content

Commit

Permalink
testcase
Browse files Browse the repository at this point in the history
  • Loading branch information
schubi2 committed May 24, 2023
1 parent 84f89e0 commit 83c7ee5
Show file tree
Hide file tree
Showing 23 changed files with 1,344 additions and 120 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,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
- [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
- [GRUB password](https://www.rubydoc.info/github/yast/yast-bootloader/master/Bootloader/GRUB2Pwd) is a specific class that manages password protection of grub2
Expand Down
5 changes: 5 additions & 0 deletions SUPPORTED_SCENARIOS.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ The goal of this document is to have a single source of information which scena
* grub2-efi
* only for UEFI boot
* only with GPT (see [bug](https://bugzilla.novell.com/show_bug.cgi?id=889733#c8))
* systemd-boot
* only for UEFI boot
* none

# Partition table
Expand Down Expand Up @@ -77,5 +79,8 @@ This option requires packages based on the architecture of the system:
* arm architecture requires: <b>grub2-arm-efi</b>.
* aarch64 architecture requires: <b>grub2-arm64-efi</b>.

## systemd-boot
If you're running a multiboot EFI system, systemd-boot can provide easier boot management and may even reduce your boot times.

## none
This option has no additional package requirement.
1,045 changes: 1,044 additions & 1 deletion 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.
9 changes: 6 additions & 3 deletions src/lib/bootloader/autoyast_converter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def import(data)
bootloader = bootloader_from_data(data)
return bootloader if bootloader.name == "none"

if ["grub2","grub2-efi"].include?(bootloader.name)
if ["grub2", "grub2-efi"].include?(bootloader.name)
import_grub2(data, bootloader)
import_grub2efi(data, bootloader)
import_stage1(data, bootloader)
Expand All @@ -44,7 +44,9 @@ def import(data)
# so use nil to always use proposed value (bsc#1081967)
bootloader.pmbr_action = nil
cpu_mitigations = data.global.cpu_mitigations
bootloader.cpu_mitigations = CpuMitigations.from_string(cpu_mitigations) if cpu_mitigations
if cpu_mitigations
bootloader.cpu_mitigations = CpuMitigations.from_string(cpu_mitigations)
end
end
if bootloader.name == "systemd-boot"
bootloader.menue_timeout = data.global.timeout
Expand All @@ -64,9 +66,10 @@ def export(config)
res = { "loader_type" => bootloader_type }

return res if bootloader_type == "none"

res["global"] = {}

if ["grub2","grub2-efi"].include?(config.name)
if ["grub2", "grub2-efi"].include?(config.name)
global = res["global"]
export_grub2(global, config) if config.name == "grub2"
export_grub2efi(global, config) if config.name == "grub2-efi"
Expand Down
10 changes: 7 additions & 3 deletions src/lib/bootloader/bootloader_factory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ def supported_names
# default means bootloader use what it think is the best
if Yast::ProductFeatures.GetBooleanFeature("globals", "enable_systemd_boot")
return BootloaderFactory::SUPPORTED_BOOTLOADERS + [SYSTEMDBOOT, DEFAULT_KEYWORD]
else
return BootloaderFactory::SUPPORTED_BOOTLOADERS + [DEFAULT_KEYWORD]
end

return BootloaderFactory::SUPPORTED_BOOTLOADERS + [DEFAULT_KEYWORD]
end

begin
Expand All @@ -70,12 +70,15 @@ def supported_names
# grub2 everywhere except aarch64 or riscv64
ret << "grub2" unless Systeminfo.efi_mandatory?
ret << "grub2-efi" if Systeminfo.efi_supported?
ret << SYSTEMDBOOT if Systeminfo.efi_supported? && Yast::ProductFeatures.GetBooleanFeature("globals", "enable_systemd_boot")
ret << SYSTEMDBOOT if Systeminfo.efi_supported? && Yast::ProductFeatures.GetBooleanFeature(
"globals", "enable_systemd_boot"
)
ret << "none"
# avoid double entry for selected one
ret.uniq
end

# rubocop:disable Metrics/CyclomaticComplexity
def bootloader_by_name(name)
# needed to be able to store settings when moving between bootloaders
@cached_bootloaders ||= {}
Expand All @@ -96,6 +99,7 @@ def bootloader_by_name(name)
nil # in other cases it means that read failed
end
end
# rubocop:enable Metrics/CyclomaticComplexity

private

Expand Down
2 changes: 1 addition & 1 deletion src/lib/bootloader/config_dialog.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def contents
if BootloaderFactory.current.is_a?(SystemdBoot)
boot_code_tab = ::Bootloader::SystemdBootWidget::BootCodeTab.new
kernel_tab = ::Bootloader::SystemdBootWidget::KernelTab.new
bootloader_tab = ::Bootloader::SystemdBootWidget::BootloaderTab.new
bootloader_tab = ::Bootloader::SystemdBootWidget::BootloaderTab.new
else
boot_code_tab = ::Bootloader::Grub2Widget::BootCodeTab.new
kernel_tab = ::Bootloader::Grub2Widget::KernelTab.new
Expand Down
14 changes: 14 additions & 0 deletions src/lib/bootloader/generic_widgets.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,20 @@ def handle
return :redraw if !Yast::Popup.ContinueCancel(popup_msg)
end

if new_bl == "systemd-boot"
# popup - Continue/Cancel
popup_msg = _(
"\n" \
"Systemd-boot support is currently work in progress and\n" \
"may not work as expected. Use at your own risk.\n" \
"\n" \
"Currently we do not provide official maintenance or support.\n" \
"Proceed?\n"
)

return :redraw if !Yast::Popup.ContinueCancel(popup_msg)
end

BootloaderFactory.current_name = new_bl
BootloaderFactory.current.propose

Expand Down
18 changes: 11 additions & 7 deletions src/lib/bootloader/grub2_widgets.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
Yast.import "Arch"

module Bootloader
module Grub2Widget
module Grub2Widget
# Adds to generic widget grub2 specific helpers
module Grub2Helper
def grub_default
Expand Down Expand Up @@ -459,7 +459,7 @@ def initialize
textdomain "bootloader"

super
end
end

def label
_("Update &NVRAM Entry")
Expand Down Expand Up @@ -534,7 +534,7 @@ def validate

Yast::Report.Error(_(
"'Password' and 'Retype password'\ndo not match. Retype the password."
))
))
Yast::UI.SetFocus(Id(:pw1))
false
end
Expand Down Expand Up @@ -850,7 +850,7 @@ def store
# Represents stage1 location for bootloader
class LoaderLocationWidget < CWM::CustomWidget
include Grub2Helper

def contents
textdomain "bootloader"

Expand All @@ -877,7 +877,10 @@ def handle(event)
end

def init
Yast::UI.ChangeWidget(Id(:boot), :Value, stage1.boot_partition?) if locations.include?(:boot)
if locations.include?(:boot)
Yast::UI.ChangeWidget(Id(:boot), :Value,
stage1.boot_partition?)
end
if locations.include?(:logical)
Yast::UI.ChangeWidget(Id(:logical), :Value, stage1.boot_partition?)
end
Expand Down Expand Up @@ -1160,7 +1163,8 @@ def device_map_button?
end
end

# Represents bootloader specific options like its timeout, default section or password protection
# Represents bootloader specific options like its timeout,
# default section or password protection
class BootloaderTab < CWM::Tab
def label
textdomain "bootloader"
Expand Down Expand Up @@ -1190,7 +1194,7 @@ def contents
)
end

private
private

def os_prober_widget
if OsProber.available? # Checks !Arch.s390 and if package is available
Expand Down
2 changes: 1 addition & 1 deletion src/lib/bootloader/grub2base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def write(etc_only: false)

# reset eventl. already installed systemd bootloader
systemd_boot = BootloaderFactory.bootloader_by_name("systemd-boot")
systemd_boot.delete if systemd_boot
systemd_boot&.delete

Yast::Execute.on_target("/usr/sbin/grub2-mkconfig", "-o", "/boot/grub2/grub.cfg",
env: systemwide_locale)
Expand Down
4 changes: 2 additions & 2 deletions src/lib/bootloader/proposal_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ def boot_map

{
# TRANSLATORS: kind of boot. It is term for way how x86_64 can boot
"grub2" => _("Legacy BIOS boot"),
"grub2" => _("Legacy BIOS boot"),
# TRANSLATORS: kind of boot. It is term for way how x86_64 can boot
"grub2-efi" => _("EFI boot"),
"grub2-efi" => _("EFI boot"),
# TRANSLATORS: kind of boot. It is term for way how can boot.
"systemd-boot" => _("Systemd boot")
}
Expand Down
Loading

0 comments on commit 83c7ee5

Please sign in to comment.