Skip to content

Commit

Permalink
Merge ae3203d into 04d3d6c
Browse files Browse the repository at this point in the history
  • Loading branch information
jreidinger committed Apr 7, 2022
2 parents 04d3d6c + ae3203d commit 231a905
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 21 deletions.
9 changes: 8 additions & 1 deletion package/yast2-bootloader.changes
@@ -1,3 +1,11 @@
-------------------------------------------------------------------
Thu Apr 7 13:21:58 UTC 2022 - Josef Reidinger <jreidinger@suse.com>

- AutoYaST: do not clone device for hibernation and also check
during autoinstallation if device for hibernation exists and if
not then use proposed one. (bsc#1187690 and bsc#1197192)
- 4.5.1

-------------------------------------------------------------------
Wed Apr 06 13:24:58 UTC 2022 - Ladislav Slezák <lslezak@suse.cz>

Expand Down Expand Up @@ -75,7 +83,6 @@ Mon Aug 16 14:16:16 UTC 2021 - Josef Reidinger <jreidinger@suse.com>

-------------------------------------------------------------------
Wed Jul 7 09:22:03 UTC 2021 - Stefan Hundhammer <shundhammer@suse.com>

- Add the os-prober package to the set of packages to install
if the package is available and supported on the arch
(bsc#1186369)
Expand Down
2 changes: 1 addition & 1 deletion package/yast2-bootloader.spec
Expand Up @@ -17,7 +17,7 @@


Name: yast2-bootloader
Version: 4.5.0
Version: 4.5.1
Release: 0
Summary: YaST2 - Bootloader Configuration
License: GPL-2.0-or-later
Expand Down
31 changes: 24 additions & 7 deletions src/lib/bootloader/autoyast_converter.rb
Expand Up @@ -117,12 +117,7 @@ def import_password(data, bootloader)

def import_default(data, default)
# import first kernel params as cpu_mitigations can later modify it
DEFAULT_KERNEL_PARAMS_MAPPING.each do |key, method|
val = data.global.public_send(key)
next unless val

default.public_send(method).replace(val)
end
import_kernel_params(data, default)

DEFAULT_BOOLEAN_MAPPING.each do |key, method|
val = data.global.public_send(key)
Expand All @@ -148,6 +143,22 @@ def import_default(data, default)
import_timeout(data, default)
end

def import_kernel_params(data, default)
DEFAULT_KERNEL_PARAMS_MAPPING.each do |key, method|
val = data.global.public_send(key)
next unless val

# import resume only if device exists (bsc#1187690)
resume = val[/(?:\s|\A)resume=(\S+)/, 1]
if resume && !Yast::BootStorage.staging.find_by_any_name(resume)
log.warn "Remove 'resume' parameter due to usage of non existing device '#{resume}'"
val = val.gsub(/(?:\s|\A)resume=#{Regexp.escape(resume)}/, "")
end

default.public_send(method).replace(val)
end
end

def import_timeout(data, default)
return unless data.global.timeout

Expand Down Expand Up @@ -297,7 +308,13 @@ def export_default(res, default)

DEFAULT_KERNEL_PARAMS_MAPPING.each do |key, method|
val = default.public_send(method)
res[key] = val.serialize unless val.empty?
result = val.serialize
# Do not export the 'resume' parameter as it depends on storage, which is not
# cloned by default. The only exception is partition label which is cloned,
# but we decided to be consistent and also remove it.
# Anyways, 'resume' will be proposed if it's missing (bsc#1187690).
result.gsub!(/(?:\s|\A)resume=\S+/, "")
res[key] = result unless result.empty?
end

DEFAULT_STRING_MAPPING.each do |key, method|
Expand Down
29 changes: 17 additions & 12 deletions test/autoyast_converter_test.rb
Expand Up @@ -48,17 +48,19 @@

it "import configuration to returned bootloader" do
data = {
"append" => "verbose nomodeset",
"terminal" => "gfxterm",
"os_prober" => "true",
"hiddenmenu" => "true",
"timeout" => 10,
"activate" => "true",
"generic_mbr" => "false",
"trusted_grub" => "true",
"update_nvram" => "true",
"boot_boot" => "true",
"password" => {
"append" => "verbose nomodeset resume=/dev/disk/by-uuid/bla-bla",
# /dev/sda exists on mocked trivial system, so it should not be removed
"xen_kernel_append" => "verbose nomodeset resume=/dev/sda1",
"terminal" => "gfxterm",
"os_prober" => "true",
"hiddenmenu" => "true",
"timeout" => 10,
"activate" => "true",
"generic_mbr" => "false",
"trusted_grub" => "true",
"update_nvram" => "true",
"boot_boot" => "true",
"password" => {
"value" => "test",
"encrypted" => "true", # if changed to false, then also mock grub2-mkpasswd
"unrestricted" => "true"
Expand All @@ -71,6 +73,9 @@
bootloader = subject.import(section)

expect(bootloader.grub_default.kernel_params.serialize).to eq "verbose nomodeset"
expect(
bootloader.grub_default.xen_hypervisor_params.serialize
).to eq "verbose nomodeset resume=/dev/sda1"
expect(bootloader.grub_default.terminal).to eq [:gfxterm]
expect(bootloader.grub_default.os_prober).to be_enabled
expect(bootloader.grub_default.hidden_timeout).to eq "10"
Expand Down Expand Up @@ -124,7 +129,7 @@
end

it "export to global key configuration" do
bootloader.grub_default.kernel_params.replace("verbose nomodeset")
bootloader.grub_default.kernel_params.replace("verbose nomodeset resume=/dev/sda")
bootloader.grub_default.terminal = [:gfxterm]
bootloader.grub_default.os_prober.enable
bootloader.grub_default.hidden_timeout = "10"
Expand Down

0 comments on commit 231a905

Please sign in to comment.