Skip to content

Commit

Permalink
Merge 3d81863 into e21a169
Browse files Browse the repository at this point in the history
  • Loading branch information
jreidinger committed Apr 5, 2022
2 parents e21a169 + 3d81863 commit 9f43e7e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 12 deletions.
12 changes: 11 additions & 1 deletion src/lib/bootloader/autoyast_converter.rb
Expand Up @@ -101,6 +101,12 @@ def import_default(data, default)
val = data.global.public_send(key)
next unless val

# import resume only if device exists (bsc#1187690)
resume = val[/[\s^]resume=(\S+)/, 1]
if resume && !Yast::BootStorage.staging.find_by_any_name(resume)
val = val.gsub(/[\s^]resume=#{Regexp.escape(resume)}/, "")
end

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

Expand Down Expand Up @@ -277,7 +283,11 @@ 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 resume parameter as it depends on storage which is
# not cloned by default and if missing it is proposed (bsc#1187690)
result.gsub!(/[\s^]resume=\S+/, "")
res[key] = result unless result.empty?
end

DEFAULT_STRING_MAPPING.each do |key, method|
Expand Down
27 changes: 16 additions & 11 deletions test/autoyast_converter_test.rb
Expand Up @@ -48,16 +48,18 @@

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"
"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"
}

section = Bootloader::AutoinstProfile::BootloaderSection.new_from_hashes(
Expand All @@ -66,6 +68,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 @@ -117,7 +122,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 9f43e7e

Please sign in to comment.