Skip to content

Commit

Permalink
simplify code for boot proposal summary
Browse files Browse the repository at this point in the history
  • Loading branch information
jreidinger committed Feb 12, 2014
1 parent 99a1069 commit f187f95
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 163 deletions.
115 changes: 34 additions & 81 deletions src/modules/BootGRUB.rb
Expand Up @@ -658,98 +658,51 @@ def Save(clean, init, flush)
#
def urlLocationSummary
Builtins.y2milestone("Prepare url summary for GRUB")
ret = ""
line = ""
locations = []
line = "<ul>\n<li>"
if Ops.get(BootCommon.globals, "boot_mbr", "") == "true"
line = Ops.add(
Ops.add(
line,
_(
"Install bootcode into MBR (<a href=\"disable_boot_mbr\">do not install</a>"
)
),
")</li>\n"
if BootCommon.globals["boot_mbr"] == "true"
line << _(
"Install bootcode into MBR (<a href=\"disable_boot_mbr\">do not install</a>)"
)
else
line = Ops.add(
Ops.add(
line,
_(
"Do not install bootcode into MBR (<a href=\"enable_boot_mbr\">install</a>"
)
),
")</li>\n"
line << _(
"Do not install bootcode into MBR (<a href=\"enable_boot_mbr\">install</a>)"
)
end
locations = Builtins.add(locations, line)
line << "</li>\n"
locations << line

line = "<li>"

set_boot_boot = false
if Ops.get(BootCommon.globals, "boot_boot", "") == "true" &&
BootStorage.BootPartitionDevice != BootStorage.RootPartitionDevice
set_boot_boot = true
line = Ops.add(
Ops.add(
line,
_(
"Install bootcode into /boot partition (<a href=\"disable_boot_boot\">do not install</a>"
)
),
")</li></ul>"
)
elsif Ops.get(BootCommon.globals, "boot_boot", "") == "false" &&
BootStorage.BootPartitionDevice != BootStorage.RootPartitionDevice
set_boot_boot = true
line = Ops.add(
Ops.add(
line,
_(
"Do not install bootcode into /boot partition (<a href=\"enable_boot_boot\">install</a>"
)
),
")</li></ul>"
)
end
if line != "<li>"
locations = Builtins.add(locations, line)
line = "<li>"
end
if Ops.get(BootCommon.globals, "boot_root", "") == "true" &&
!set_boot_boot
line = Ops.add(
Ops.add(
line,
_(
"Install bootcode into \"/\" partition (<a href=\"disable_boot_root\">do not install</a>"
)
),
")</li></ul>"
)
elsif Ops.get(BootCommon.globals, "boot_root", "") == "false" &&
!set_boot_boot
line = Ops.add(
Ops.add(
line,
_(
# check for separated boot partition, use root otherwise
if BootStorage.BootPartitionDevice != BootStorage.RootPartitionDevice
if BootCommon.globals["boot_boot"] == "true"
line << _(
"Install bootcode into /boot partition (<a href=\"disable_boot_boot\">do not install</a>)"
)
else
line << _(
"Do not install bootcode into /boot partition (<a href=\"enable_boot_boot\">install</a>)"
)
end
else
if BootCommon.globals["boot_root"] == "true"
line << _(
"Install bootcode into \"/\" partition (<a href=\"disable_boot_root\">do not install</a>)"
)
else
line << _(
"Do not install bootcode into \"/\" partition (<a href=\"enable_boot_root\">do not install</a>"
)
),
")</li></ul>"
)
end
locations = Builtins.add(locations, line) if !set_boot_boot

if Ops.greater_than(Builtins.size(locations), 0)
# FIXME: should we translate all devices to names and add MBR suffixes?
ret = Builtins.sformat(
_("Change Location: %1"),
Builtins.mergestring(locations, " ")
)
)
end
end
line << "</li></ul>"
locations << line

ret
return Builtins.sformat(
_("Change Location: %1"),
locations.join(" ")
)
end

# Display bootloader summary
Expand Down
118 changes: 36 additions & 82 deletions src/modules/BootGRUB2.rb
Expand Up @@ -228,99 +228,53 @@ def Propose
#
#
def urlLocationSummary
Builtins.y2milestone("Prepare url summary for GRUB")
ret = ""
line = ""
Builtins.y2milestone("Prepare url summary for GRUB2")
# FIXME identical code in BootGRUB module
locations = []
line = "<ul>\n<li>"
if Ops.get(BootCommon.globals, "boot_mbr", "") == "true"
line = Ops.add(
Ops.add(
line,
_(
"Install bootcode into MBR (<a href=\"disable_boot_mbr\">do not install</a>"
)
),
")</li>\n"
if BootCommon.globals["boot_mbr"] == "true"
line << _(
"Install bootcode into MBR (<a href=\"disable_boot_mbr\">do not install</a>)"
)
else
line = Ops.add(
Ops.add(
line,
_(
"Do not install bootcode into MBR (<a href=\"enable_boot_mbr\">install</a>"
)
),
")</li>\n"
line << _(
"Do not install bootcode into MBR (<a href=\"enable_boot_mbr\">install</a>)"
)
end
locations = Builtins.add(locations, line)
line << "</li>\n"
locations << line

line = "<li>"

set_boot_boot = false
if Ops.get(BootCommon.globals, "boot_boot", "") == "true" &&
BootStorage.BootPartitionDevice != BootStorage.RootPartitionDevice
set_boot_boot = true
line = Ops.add(
Ops.add(
line,
_(
"Install bootcode into /boot partition (<a href=\"disable_boot_boot\">do not install</a>"
)
),
")</li></ul>"
)
elsif Ops.get(BootCommon.globals, "boot_boot", "") == "false" &&
BootStorage.BootPartitionDevice != BootStorage.RootPartitionDevice
set_boot_boot = true
line = Ops.add(
Ops.add(
line,
_(
"Do not install bootcode into /boot partition (<a href=\"enable_boot_boot\">install</a>"
)
),
")</li></ul>"
)
end
if line != "<li>"
locations = Builtins.add(locations, line)
line = "<li>"
end
if Ops.get(BootCommon.globals, "boot_root", "") == "true" &&
!set_boot_boot
line = Ops.add(
Ops.add(
line,
_(
"Install bootcode into \"/\" partition (<a href=\"disable_boot_root\">do not install</a>"
)
),
")</li></ul>"
)
elsif Ops.get(BootCommon.globals, "boot_root", "") == "false" &&
!set_boot_boot
line = Ops.add(
Ops.add(
line,
_(
# check for separated boot partition, use root otherwise
if BootStorage.BootPartitionDevice != BootStorage.RootPartitionDevice
if BootCommon.globals["boot_boot"] == "true"
line << _(
"Install bootcode into /boot partition (<a href=\"disable_boot_boot\">do not install</a>)"
)
else
line << _(
"Do not install bootcode into /boot partition (<a href=\"enable_boot_boot\">install</a>)"
)
end
else
if BootCommon.globals["boot_root"] == "true"
line << _(
"Install bootcode into \"/\" partition (<a href=\"disable_boot_root\">do not install</a>)"
)
else
line << _(
"Do not install bootcode into \"/\" partition (<a href=\"enable_boot_root\">do not install</a>"
)
),
")</li></ul>"
)
end
locations = Builtins.add(locations, line) if !set_boot_boot

if Ops.greater_than(Builtins.size(locations), 0)
# FIXME: should we translate all devices to names and add MBR suffixes?
ret = Builtins.sformat(
_("Change Location: %1"),
Builtins.mergestring(locations, " ")
)
)
end
end
line << "</li></ul>"
locations << line

ret
return Builtins.sformat(
_("Change Location: %1"),
locations.join(" ")
)
end


Expand Down

0 comments on commit f187f95

Please sign in to comment.