Skip to content

Commit

Permalink
Merge pull request #303 from yast/jreidinger_config_files_proto
Browse files Browse the repository at this point in the history
Jreidinger config files proto
  • Loading branch information
jreidinger committed Mar 30, 2016
2 parents e6e3675 + 733db43 commit f72151a
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 143 deletions.
5 changes: 3 additions & 2 deletions package/yast2-bootloader.spec
Expand Up @@ -28,7 +28,7 @@ BuildRequires: yast2 >= 3.1.176
BuildRequires: yast2-devtools >= 3.1.10
BuildRequires: yast2-ruby-bindings >= 1.0.0
BuildRequires: yast2-storage
BuildRequires: rubygem(%rb_default_ruby_abi:cfa_grub2) >= 0.3.2
BuildRequires: rubygem(%rb_default_ruby_abi:cfa_grub2) >= 0.4.0
BuildRequires: rubygem(%rb_default_ruby_abi:rspec)
BuildRequires: rubygem(%rb_default_ruby_abi:yast-rake)
PreReq: /bin/sed %fillup_prereq
Expand All @@ -40,7 +40,8 @@ Requires: yast2-core >= 2.18.7
Requires: yast2-packager >= 2.17.24
Requires: yast2-pkg-bindings >= 2.17.25
Requires: yast2-storage >= 2.18.18
Requires: rubygem(%rb_default_ruby_abi:cfa_grub2) >= 0.3.2
# GRUB_DEFAULT attribute
Requires: rubygem(%rb_default_ruby_abi:cfa_grub2) >= 0.4.0
# lenses are needed as cfa_grub2 depends only on augeas bindings, but also
# lenses are needed here
Requires: augeas-lenses
Expand Down
144 changes: 3 additions & 141 deletions src/clients/bootloader.rb
Expand Up @@ -21,92 +21,19 @@
module Yast
class BootloaderClient < Client
def main
Yast.import "UI"
textdomain "bootloader"

Yast.import "Bootloader"
Yast.import "CommandLine"
Yast.import "Mode"
Yast.import "RichText"

# the command line description map
cmdline = {
"id" => "bootloader",
# command line help text for Bootloader module
"help" => _(
"Boot loader configuration module"
),
"guihandler" => fun_ref(method(:GuiHandler), "boolean ()"),
"initialize" => fun_ref(Bootloader.method(:Read), "boolean ()"),
"finish" => fun_ref(Bootloader.method(:Write), "boolean ()"),
"actions" => {
"summary" => {
"handler" => fun_ref(
method(:BootloaderSummaryHandler),
"boolean (map)"
),
# command line help text for summary action
"help" => _(
"Configuration summary of boot loader"
)
},
"delete" => {
"handler" => fun_ref(
method(:BootloaderDeleteHandler),
"boolean (map)"
),
# command line help text for delete action
"help" => _(
"Delete a global option"
)
},
"set" => {
"handler" => fun_ref(method(:BootloaderSetHandler), "boolean (map)"),
# command line help text for set action
"help" => _(
"Set a global option"
)
},
"print" => {
"handler" => fun_ref(
method(:BootloaderPrintHandler),
"boolean (map)"
),
# command line help text for print action
"help" => _(
"Print value of specified option"
)
}
},
"options" => {
"option" => {
# command line help text for an option
"help" => _(
"The key of the option"
),
"type" => "string"
},
"value" => {
# command line help text for an option
"help" => _(
"The value of the option"
),
"type" => "string"
}
},
"mappings" => {
"summary" => [],
"delete" => ["option"],
"set" => ["option", "value"],
"print" => ["option"]
}
"help" => _("Boot loader configuration module"),
"guihandler" => fun_ref(method(:GuiHandler), "boolean ()")
}

Builtins.y2milestone("Starting bootloader configuration module")
ret = CommandLine.Run(cmdline)

Builtins.y2milestone("Finishing bootloader configuration module")
ret
CommandLine.Run(cmdline)
end

# --------------------------------------------------------------------------
Expand All @@ -120,71 +47,6 @@ def GuiHandler
return false if ret == :abort || ret == :back || ret == :nil
true
end

# Print summary of basic options
# @param [Hash] options a list of parameters passed as args
# @return [Boolean] false
def BootloaderSummaryHandler(_options)
CommandLine.Print(
RichText.Rich2Plain(
Ops.add("<br>", Builtins.mergestring(Bootloader.Summary, "<br>"))
)
)
false # do not call Write...
end

# Modify the boot loader global option
# @param [String] key string the key to modify
# @param [String] value string the value to set
# @return [Boolean] true on success
def BootloaderModify(key, value)
BootCommon.globals[key] = value
true
end

# Set specified option in global options
# @param [Hash] options a list of parameters passed as args
# @return [Boolean] true on success
def BootloaderSetHandler(options)
option = options["option"]
value = options["value"]
if value.nil?
# command line error report
CommandLine.Print(_("Value was not specified."))
return false
end
BootloaderModify(option, value.to_s)
end

# Delete specified option
# @param [Hash] options a list of parameters passed as args
# @return [Boolean] true on success
def BootloaderDeleteHandler(options)
option = options["option"]
BootloaderModifySection(option, nil)
end

# Print the value of specified option
# @param [Hash] options a list of parameters passed as args
# @return [Boolean] true on success
def BootloaderPrintHandler(options)
options = deep_copy(options)
option = options["option"]
if option.nil?
# command line error report
CommandLine.Print(_("Option was not specified."))
return false
end
value = BootCommon.globals[option]
if value
# command line, %1 is the value of bootloader option
CommandLine.Print(_("Value: %s") % value)
else
# command line error report
CommandLine.Print(_("Specified option does not exist."))
end
false
end
end
end

Expand Down
2 changes: 2 additions & 0 deletions src/lib/bootloader/bootloader_factory.rb
Expand Up @@ -18,6 +18,8 @@ class << self
"grub2-efi"
]

attr_writer :current

def proposed
bootloader_by_name(proposed_name)
end
Expand Down
3 changes: 3 additions & 0 deletions src/lib/bootloader/finish_client.rb
Expand Up @@ -54,6 +54,9 @@ def write
system.merge(bl_current)
system.write

# and remember result of merge as current one
::Bootloader::BootloaderFactory.current = system

# fate #303395: Use kexec to avoid booting between first and second stage
# copy vmlinuz, initrd and flush kernel option into /var/lib/YaST2
if Yast::Linuxrc.InstallInf("kexec_reboot") == "1"
Expand Down
4 changes: 4 additions & 0 deletions src/lib/bootloader/grub2base.rb
Expand Up @@ -103,6 +103,7 @@ def propose
grub_default.gfxmode ||= "auto"
grub_default.recovery_entry.disable unless grub_default.recovery_entry.defined?
grub_default.distributor ||= ""
grub_default.default = "saved"

propose_serial

Expand Down Expand Up @@ -176,6 +177,9 @@ def merge_attributes(default, other)
[:os_prober, :cryptodisk].each do |attr|
default.send(attr).value = other.send(attr).enabled? if other.send(attr).defined?
end

# grub default have special value saved, otherwise choosing sections won't work
default.default = "saved" # yes, default/grub2 have value GRUB_DEFAULT so default.default
end

def serial_console_matcher
Expand Down

0 comments on commit f72151a

Please sign in to comment.