Skip to content

Commit

Permalink
Merge a6b0753 into f722667
Browse files Browse the repository at this point in the history
  • Loading branch information
jreidinger committed Nov 30, 2017
2 parents f722667 + a6b0753 commit aa6b017
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 10 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
-------------------------------------------------------------------
Thu Nov 30 07:45:45 UTC 2017 - jreidinger@suse.com

- avoid crash if config file uses trailing comment (bsc#1068578)
- 0.6.4

-------------------------------------------------------------------
Wed Aug 2 08:47:20 UTC 2017 - jreidinger@suse.com

Expand Down
2 changes: 1 addition & 1 deletion cfa_grub2.gemspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Gem::Specification.new do |s|
s.name = "cfa_grub2"
s.version = "0.6.3"
s.version = "0.6.4"
s.platform = Gem::Platform::RUBY
s.authors = ["Josef Reidinger"]
s.email = ["jreidinger@suse.cz"]
Expand Down
24 changes: 16 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,28 @@ 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 +103,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 +129,13 @@ def serial_console=(value)
end

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

private

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

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

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 aa6b017

Please sign in to comment.