From e86a514f2a198ab32a5560caa5fd90c61a5ad55d Mon Sep 17 00:00:00 2001 From: Josef Reidinger Date: Wed, 19 Feb 2014 14:57:39 +0100 Subject: [PATCH] unify also proposal --- src/lib/bootloader/grub2base.rb | 73 +++++++++++++++++++++++++++++++++ src/modules/BootGRUB2.rb | 73 +-------------------------------- src/modules/BootGRUB2EFI.rb | 72 -------------------------------- 3 files changed, 75 insertions(+), 143 deletions(-) diff --git a/src/lib/bootloader/grub2base.rb b/src/lib/bootloader/grub2base.rb index c87b9749d..ba7def878 100644 --- a/src/lib/bootloader/grub2base.rb +++ b/src/lib/bootloader/grub2base.rb @@ -74,6 +74,79 @@ def Dialogs } end + def Propose + if BootCommon.was_proposed + # workaround autoyast config is Imported thus was_proposed always set + if Mode.autoinst + Builtins.y2milestone( + "autoinst mode we ignore meaningless was_proposed as it always set" + ) + else + Builtins.y2milestone( + "calling Propose with was_proposed set is really bogus, clear it to force a re-propose" + ) + return + end + end + + + if BootCommon.globals == nil || Builtins.size(BootCommon.globals) == 0 + BootCommon.globals = StandardGlobals() + else + BootCommon.globals = Convert.convert( + Builtins.union(BootCommon.globals, StandardGlobals()), + :from => "map", + :to => "map " + ) + end + + swap_sizes = BootCommon.getSwapPartitions + swap_parts = Builtins.maplist(swap_sizes) { |name, size| name } + swap_parts = Builtins.sort(swap_parts) do |a, b| + Ops.greater_than(Ops.get(swap_sizes, a, 0), Ops.get(swap_sizes, b, 0)) + end + + largest_swap_part = Ops.get(swap_parts, 0, "") + + resume = BootArch.ResumeAvailable ? largest_swap_part : "" + # try to use label or udev id for device name... FATE #302219 + if resume != "" && resume != nil + resume = BootStorage.Dev2MountByDev(resume) + end + Ops.set( + BootCommon.globals, + "append", + BootArch.DefaultKernelParams(resume) + ) + Ops.set( + BootCommon.globals, + "append_failsafe", + BootArch.FailsafeKernelParams + ) + Ops.set( + BootCommon.globals, + "distributor", + Ops.add(Ops.add(Product.short_name, " "), Product.version) + ) + BootCommon.kernelCmdLine = Kernel.GetCmdLine + + Builtins.y2milestone("Proposed globals: %1", BootCommon.globals) + + # Let grub2 scripts detects correct root= for us. :) + # BootCommon::globals["root"] = BootStorage::Dev2MountByDev(BootStorage::RootPartitionDevice); + + # We don't set vga= if Grub2 gfxterm enabled, because the modesettings + # will be delivered to kernel by Grub2's gfxpayload set to "keep" + #if (BootArch::VgaAvailable () && Kernel::GetVgaType () != "") + #{ + # BootCommon::globals["vgamode"] = Kernel::GetVgaType (); + #} + + nil + end + + + # Initializer of GRUB bootloader def Initializer Builtins.y2milestone("Called GRUB2 initializer") diff --git a/src/modules/BootGRUB2.rb b/src/modules/BootGRUB2.rb index 45da8bb19..9d32bd6b3 100644 --- a/src/modules/BootGRUB2.rb +++ b/src/modules/BootGRUB2.rb @@ -103,78 +103,9 @@ def Write ret end - # Propose bootloader settings - def Propose - if BootCommon.was_proposed - # workaround autoyast config is Imported thus was_proposed always set - if Mode.autoinst - Builtins.y2milestone( - "autoinst mode we ignore meaningless was_proposed as it always set" - ) - else - Builtins.y2milestone( - "calling Propose with was_proposed set is really bogus, clear it to force a re-propose" - ) - return - end - end - - if BootCommon.globals == nil || Builtins.size(BootCommon.globals) == 0 - BootCommon.globals = StandardGlobals() - else - BootCommon.globals = Convert.convert( - Builtins.union(BootCommon.globals, StandardGlobals()), - :from => "map", - :to => "map " - ) - end - - grub_LocationProposal - - swap_sizes = BootCommon.getSwapPartitions - swap_parts = Builtins.maplist(swap_sizes) { |name, size| name } - swap_parts = Builtins.sort(swap_parts) do |a, b| - Ops.greater_than(Ops.get(swap_sizes, a, 0), Ops.get(swap_sizes, b, 0)) - end - - largest_swap_part = Ops.get(swap_parts, 0, "") - - resume = BootArch.ResumeAvailable ? largest_swap_part : "" - # try to use label or udev id for device name... FATE #302219 - if resume != "" && resume != nil - resume = BootStorage.Dev2MountByDev(resume) - end - Ops.set( - BootCommon.globals, - "append", - BootArch.DefaultKernelParams(resume) - ) - Ops.set( - BootCommon.globals, - "append_failsafe", - BootArch.FailsafeKernelParams - ) - Ops.set( - BootCommon.globals, - "distributor", - Ops.add(Ops.add(Product.short_name, " "), Product.version) - ) - BootCommon.kernelCmdLine = Kernel.GetCmdLine - - Builtins.y2milestone("Proposed globals: %1", BootCommon.globals) - - # Let grub2 scripts detects correct root= for us. :) - # BootCommon::globals["root"] = BootStorage::Dev2MountByDev(BootStorage::RootPartitionDevice); - - # We don't set vga= if Grub2 gfxterm enabled, because the modesettings - # will be delivered to kernel by Grub2's gfxpayload set to "keep" - #if (BootArch::VgaAvailable () && Kernel::GetVgaType () != "") - #{ - # BootCommon::globals["vgamode"] = Kernel::GetVgaType (); - #} - - nil + super + grub_LocationProposal if !BootCommon.was_proposed || !Mode.autoinst end # FATE#303643 Enable one-click changes in bootloader proposal diff --git a/src/modules/BootGRUB2EFI.rb b/src/modules/BootGRUB2EFI.rb index 6fda66542..b08657318 100644 --- a/src/modules/BootGRUB2EFI.rb +++ b/src/modules/BootGRUB2EFI.rb @@ -58,78 +58,6 @@ def Write ret end - # Propose bootloader settings - - def Propose - if BootCommon.was_proposed - # workaround autoyast config is Imported thus was_proposed always set - if Mode.autoinst - Builtins.y2milestone( - "autoinst mode we ignore meaningless was_proposed as it always set" - ) - else - Builtins.y2milestone( - "calling Propose with was_proposed set is really bogus, clear it to force a re-propose" - ) - return - end - end - - if BootCommon.globals == nil || Builtins.size(BootCommon.globals) == 0 - BootCommon.globals = StandardGlobals() - else - BootCommon.globals = Convert.convert( - Builtins.union(BootCommon.globals, StandardGlobals()), - :from => "map", - :to => "map " - ) - end - - swap_sizes = BootCommon.getSwapPartitions - swap_parts = Builtins.maplist(swap_sizes) { |name, size| name } - swap_parts = Builtins.sort(swap_parts) do |a, b| - Ops.greater_than(Ops.get(swap_sizes, a, 0), Ops.get(swap_sizes, b, 0)) - end - - largest_swap_part = Ops.get(swap_parts, 0, "") - - resume = BootArch.ResumeAvailable ? largest_swap_part : "" - # try to use label or udev id for device name... FATE #302219 - if resume != "" && resume != nil - resume = BootStorage.Dev2MountByDev(resume) - end - Ops.set( - BootCommon.globals, - "append", - BootArch.DefaultKernelParams(resume) - ) - Ops.set( - BootCommon.globals, - "append_failsafe", - BootArch.FailsafeKernelParams - ) - Ops.set( - BootCommon.globals, - "distributor", - Ops.add(Ops.add(Product.short_name, " "), Product.version) - ) - BootCommon.kernelCmdLine = Kernel.GetCmdLine - - Builtins.y2milestone("Proposed globals: %1", BootCommon.globals) - - # Let grub2 scripts detects correct root= for us. :) - # BootCommon::globals["root"] = BootStorage::Dev2MountByDev(BootStorage::RootPartitionDevice); - - # We don't set vga= if Grub2 gfxterm enabled, because the modesettings - # will be delivered to kernel by Grub2's gfxpayload set to "keep" - #if (BootArch::VgaAvailable () && Kernel::GetVgaType () != "") - #{ - # BootCommon::globals["vgamode"] = Kernel::GetVgaType (); - #} - - nil - end - # Display bootloader summary # @return a list of summary lines