Skip to content

Commit

Permalink
unify also proposal
Browse files Browse the repository at this point in the history
  • Loading branch information
jreidinger committed Feb 19, 2014
1 parent 8659279 commit e86a514
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 143 deletions.
73 changes: 73 additions & 0 deletions src/lib/bootloader/grub2base.rb
Expand Up @@ -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 <string, string>"
)
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")
Expand Down
73 changes: 2 additions & 71 deletions src/modules/BootGRUB2.rb
Expand Up @@ -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 <string, string>"
)
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
Expand Down
72 changes: 0 additions & 72 deletions src/modules/BootGRUB2EFI.rb
Expand Up @@ -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 <string, string>"
)
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

Expand Down

0 comments on commit e86a514

Please sign in to comment.