Skip to content

Commit

Permalink
remove section handling from autoyast as we ignore it for grub2
Browse files Browse the repository at this point in the history
  • Loading branch information
jreidinger committed Sep 2, 2014
1 parent 866c6fc commit 8426bc4
Showing 1 changed file with 1 addition and 92 deletions.
93 changes: 1 addition & 92 deletions src/include/bootloader/routines/autoinstall.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,43 +113,6 @@ def initialize_bootloader_routines_autoinstall(include_target)
Yast.import "Popup"
end

# Add missing data (eg. root filesystem) to sections imported from profile
# @param [Array<Hash{String => Object>}] sect a list of all sections
# @return a lit of all updated sections
def UpdateImportedSections(sect)
sect = deep_copy(sect)
sect = Builtins.maplist(sect) do |s|
Builtins.y2milestone("Updating imported section %1", s)
orig_name = Ops.get_string(
s,
"original_name",
Ops.get_string(s, "name", "linux")
)
type = Ops.get_string(s, "type", "image")
next deep_copy(s) if type != "image"
s = Convert.convert(
Builtins.union(BootCommon.CreateLinuxSection(orig_name), s),
:from => "map",
:to => "map <string, any>"
)
# convert "kernel" to "image", if not already defined in the section
if Builtins.haskey(s, "kernel")
if !Builtins.haskey(s, "image")
Ops.set(s, "image", Ops.get_string(s, "kernel", ""))
end
s = Builtins.remove(s, "kernel")
end
# convert "vga" to "vgamode", if not already defined in the section
if Builtins.haskey(s, "vga")
if !Builtins.haskey(s, "vgamode")
Ops.set(s, "vgamode", Ops.get_string(s, "vga", ""))
end
s = Builtins.remove(s, "vga")
end
deep_copy(s)
end
deep_copy(sect)
end

# Translate the autoinstallation map to the Export map
# @param [Hash{String => Object}] ai a map the autoinstallation map
Expand Down Expand Up @@ -259,22 +222,6 @@ def AI2Export(ai)

old_format = false

# section stuff
section_names = []
if Ops.greater_than(Builtins.size(Ops.get_list(ai, "sections", [])), 0)
Builtins.foreach(Ops.get_list(ai, "sections", [])) do |s|
old_format = true if !Ops.is(s, "map <string, any>")
end
if !old_format
sect = Ops.get_list(ai, "sections", [])
sect = UpdateImportedSections(sect)
Ops.set(exp, ["specific", "sections"], sect)
section_names = Builtins.maplist(sect) do |s|
Ops.get_string(s, "name", "")
end
end
end

# global stuff
if !Builtins.haskey(ai, "global") || Ops.is_map?(Ops.get(ai, "global"))
Ops.set(
Expand All @@ -297,13 +244,10 @@ def AI2Export(ai)
# Converting key/value pairs to file contents first, then setting
# as file contents and re-exporting the parsed file contents.

sections = Ops.get_list(ai, "sections", [])
globals = Ops.get_list(ai, "global", [])
sections = Builtins.prepend(sections, globals)
flat = Builtins.flatten(sections)
loader = Ops.get_string(ai, "loader_type", "")
separator = " = "
lines = Builtins.maplist(flat) do |f|
lines = Builtins.maplist(globals) do |f|
Builtins.sformat(
"%1%2%3",
Ops.get_string(f, "key", ""),
Expand All @@ -314,34 +258,9 @@ def AI2Export(ai)
file = Builtins.mergestring(lines, "\n")
BootCommon.InitializeLibrary(true, loader)
BootCommon.SetDeviceMap(BootStorage.device_mapping)
BootCommon.SetSections([])
BootCommon.SetGlobal({})
BootCommon.SetFilesContents(files)
Ops.set(exp, ["specific", "global"], BootCommon.GetGlobal)
sect = BootCommon.GetSections
sect = UpdateImportedSections(sect)
Ops.set(exp, ["specific", "sections"], sect)
section_names = Builtins.maplist(sect) do |s|
Ops.get_string(s, "name", "")
end
end

if Builtins.haskey(
Ops.get_map(exp, ["specific", "global"], {}),
"default"
) &&
!Builtins.contains(
section_names,
Ops.get_string(exp, ["specific", "global", "default"], "")
)
Ops.set(
exp,
["specific", "global"],
Builtins.remove(
Ops.get_map(exp, ["specific", "global"], {}),
"default"
)
)
end

deep_copy(exp)
Expand All @@ -368,16 +287,6 @@ def Export2AI(exp)
{ k => v }
end)
end
# sections stuff
Ops.set(
ai,
"sections",
Builtins.maplist(Ops.get_list(exp, ["specific", "sections"], [])) do |s|
s = Builtins.filter(s) { |k, v| Builtins.substring(k, 0, 2) != "__" }
deep_copy(s)
end
)

# device map stuff
if Ops.greater_than(
Builtins.size(Ops.get_map(exp, ["specific", "device_map"], {})),
Expand Down

0 comments on commit 8426bc4

Please sign in to comment.