Skip to content

Commit

Permalink
Merge f71c1be into f722667
Browse files Browse the repository at this point in the history
  • Loading branch information
jreidinger committed Nov 29, 2017
2 parents f722667 + f71c1be commit db696ce
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
23 changes: 15 additions & 8 deletions lib/cfa/grub2/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def load
kernels = [kernel_params, xen_hypervisor_params, xen_kernel_params,
recovery_params]
kernels.each do |kernel|
param_line = data[kernel.key]
param_line = value_for(kernel.key)
kernel.replace(param_line) if param_line
end
end
Expand All @@ -64,27 +64,27 @@ def os_prober

def kernel_params
@kernel_params ||= KernelParams.new(
data["GRUB_CMDLINE_LINUX_DEFAULT"], "GRUB_CMDLINE_LINUX_DEFAULT"
value_for("GRUB_CMDLINE_LINUX_DEFAULT"), "GRUB_CMDLINE_LINUX_DEFAULT"
)
end

def xen_hypervisor_params
@xen_hypervisor_params ||= KernelParams.new(
data["GRUB_CMDLINE_XEN_DEFAULT"],
value_for("GRUB_CMDLINE_XEN_DEFAULT"),
"GRUB_CMDLINE_XEN_DEFAULT"
)
end

def xen_kernel_params
@xen_kernel_params ||= KernelParams.new(
data["GRUB_CMDLINE_LINUX_XEN_REPLACE_DEFAULT"],
value_for("GRUB_CMDLINE_LINUX_XEN_REPLACE_DEFAULT"),
"GRUB_CMDLINE_LINUX_XEN_REPLACE_DEFAULT"
)
end

def recovery_params
@recovery_params ||= KernelParams.new(
data["GRUB_CMDLINE_LINUX_RECOVERY"], "GRUB_CMDLINE_LINUX_RECOVERY"
value_for("GRUB_CMDLINE_LINUX_RECOVERY"), "GRUB_CMDLINE_LINUX_RECOVERY"
)
end

Expand All @@ -102,13 +102,14 @@ def cryptodisk
end

def terminal
case data["GRUB_TERMINAL"]
value = value_for("GRUB_ENABLE_CRYPTODISK")
case value
when "", nil then nil
when "console" then :console
when "serial" then :serial
when "gfxterm" then :gfxterm
else
raise "unknown GRUB_TERMINAL option #{data["GRUB_TERMINAL"].inspect}"
raise "unknown GRUB_TERMINAL option #{value.inspect}"
end
end

Expand All @@ -127,7 +128,13 @@ def serial_console=(value)
end

def serial_console
data["GRUB_SERIAL_COMMAND"]
value_for("GRUB_SERIAL_COMMAND")
end

private

def value_for(key)
value = data[key].respond_to?(:value) ? data[key].value : data[key]
end

# Represents kernel append line with helpers to easier modification.
Expand Down
2 changes: 1 addition & 1 deletion spec/grub2_default_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@

describe "#kernel_params" do
let(:file_content) do
"GRUB_CMDLINE_LINUX_DEFAULT=\"quite console=S0 console=S1 vga=0x400\"\n"
"GRUB_CMDLINE_LINUX_DEFAULT=\"quite console=S0 console=S1 vga=0x400\" # comment 1\n"
end

it "returns KernelParams object" do
Expand Down

0 comments on commit db696ce

Please sign in to comment.