Skip to content

Commit

Permalink
rubyfi code
Browse files Browse the repository at this point in the history
  • Loading branch information
jreidinger committed Oct 31, 2014
1 parent 4eabd20 commit d94aba5
Showing 1 changed file with 25 additions and 38 deletions.
63 changes: 25 additions & 38 deletions src/modules/Bootloader.rb
Expand Up @@ -91,7 +91,7 @@ def Export
"specific" => blExport,
"write_settings" => BootCommon.write_settings
}
loader_type = Ops.get_string(out, "loader_type")
loader_type = out["loader_type"]

# export loader_device and selected_location only for bootloaders
# that have not phased them out yet
Expand Down Expand Up @@ -124,24 +124,19 @@ def Import(settings)

# import loader_device and selected_location only for bootloaders
# that have not phased them out yet
BootCommon.loader_device = Ops.get_string(settings, "loader_device", "")
BootCommon.selected_location = Ops.get_string(
settings,
"loader_location",
"custom"
)
BootCommon.loader_device = settings["loader_device"] || ""
BootCommon.selected_location = settings["loader_location"] || "custom"

# FIXME: obsolete for grub (but inactive through the outer "if" now anyway):
# for grub, always correct the bootloader device according to
# selected_location (or fall back to value of loader_device)
if Arch.i386 || Arch.x86_64
BootCommon.loader_device = BootCommon.GetBootloaderDevice
end

if Ops.get_map(settings, "initrd", {}) != nil
Initrd.Import(Ops.get_map(settings, "initrd", {}))
end
ret = blImport(Ops.get_map(settings, "specific", {}))
BootCommon.write_settings = Ops.get_map(settings, "write_settings", {})
Initrd.Import(settings["initrd"] || {})
ret = blImport(settings["specific"] || {})
BootCommon.write_settings = settings["write_settings"] || {}
ret
end

Expand Down Expand Up @@ -424,11 +419,7 @@ def WriteInstallation

# save initrd
if (Initrd.changed || !Mode.normal) &&
!Ops.get_boolean(
BootCommon.write_settings,
"forbid_save_initrd",
false
)
!BootCommon.write_settings["forbid_save_initrd"]
vga = getKernelParam(getDefaultSection, "vgamode")
if vga != "false" && vga != ""
Initrd.setSplash(vga)
Expand Down Expand Up @@ -487,12 +478,12 @@ def getProposedDefaultSection
first_image = ""
default_image = ""
Builtins.foreach(BootCommon.sections) do |s|
title = Ops.get_string(s, "name", "")
if Ops.get(s, "image") != nil
title = s["name"] || ""
if s["image"]
first_image = title if first_image == ""
default_image = title if title == getDefaultSection
end
if defaultv == "" && Ops.get_string(s, "original_name", "") == "linux"
if defaultv == "" && s["original_name"] == "linux"
defaultv = title
end
end
Expand Down Expand Up @@ -522,14 +513,14 @@ def getKernelParam(section, key)
index = -1
Builtins.foreach(BootCommon.sections) do |s|
index = Ops.add(index, 1)
sectnum = index if Ops.get_string(s, "name", "") == section
sectnum = index if s["name"] == section
end
return "" if sectnum == -1
line = ""
if Builtins.contains(["root", "vgamode"], key)
return Ops.get_string(BootCommon.sections, [sectnum, key], "false")
if ["root", "vgamode"].include? (key)
return BootCommon.sections[sectnum][key] || "false"
else
line = Ops.get_string(BootCommon.sections, [sectnum, "append"], "")
line = BootCommon.sections[sectnum]["append"] || ""
return BootCommon.getKernelParamFromLine(line, key)
end
end
Expand Down Expand Up @@ -698,15 +689,14 @@ def ReadOrProposeIfNeeded
def updateAppend(section)
section = deep_copy(section)
ret = deep_copy(section)
if Ops.get_string(section, "append", "") != "" &&
Ops.get_string(section, "console", "") != ""
if !(section["append"] || "").empty? &&
!(section["console"] || "").empty?
updated_append = BootCommon.UpdateSerialConsole(
Ops.get_string(section, "append", ""),
Ops.get_string(section, "console", "")
section["append"], section["console"]
)
Ops.set(ret, "append", updated_append) if updated_append != nil
ret["append"] = updated_append if updated_append
end
deep_copy(ret)
ret
end


Expand All @@ -718,14 +708,11 @@ def updateAppend(section)
# @return [String]: entry
def DMIRead(bios_data, section, key)
bios_data = deep_copy(bios_data)
result = ""
smbios = bios_data.fetch(0, {}).fetch("smbios", [])

Builtins.foreach(Ops.get_list(bios_data, [0, "smbios"], [])) do |x|
if Ops.get_string(x, "type", "") == section
result = Ops.get_string(x, key, "")
raise Break
end
end
result = smbios.find { |x| x["type"] == section }
result = result[key] if result
result ||= ""

log.info "Bootloader::DMIRead(#{section}, #{key}) = #{result}"

Expand Down Expand Up @@ -816,7 +803,7 @@ def CopyKernelInird

log.info "Command for copy: #{cmd}"
out = WFM.Execute(path(".local.bash_output"), cmd)
if Ops.get(out, "exit") != 0
if out["exit"] != 0
log.error "Copy kernel and initrd failed, output: #{out}"
return false
end
Expand Down

0 comments on commit d94aba5

Please sign in to comment.