Skip to content

Commit

Permalink
read agama kernel params if available (bsc#1234678)
Browse files Browse the repository at this point in the history
  • Loading branch information
jreidinger committed Jan 30, 2025
1 parent 037b94b commit 2c8bd91
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
5 changes: 4 additions & 1 deletion library/system/src/modules/Kernel.rb
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,10 @@ def ParseInstallationKernelCmdline
# not using dedicated agent in order to use the same parser for cmdline
# independently on whether it comes from /proc/cmdline or /etc/install.inf
# use local read as it does not make sense to depend on binding it to chroot
WFM.Read(path(".local.string"), "/proc/cmdline").to_s
# and first check if there is dedicated agama filtered kernel parameters (bsc#1234678)
agama_path = "/run/agama/cmdline.d/kernel"
file_path = File.exist?(agama_path) ? agama_path : "/proc/cmdline"
WFM.Read(path(".local.string"), file_path).to_s
else
SCR.Read(path(".etc.install_inf.Cmdline")).to_s
end
Expand Down
38 changes: 38 additions & 0 deletions library/system/test/kernel_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,44 @@
allow(Yast::Arch).to receive(:architecture).and_return("x86_64")
end

context "if install.inf is not available" do
let(:cmdline) { "splash=verbose silent" }
before do
allow(Yast::SCR).to receive(:Dir).with(path(".etc.install_inf")).and_return([])
allow(::File).to receive(:exist?).and_call_original
end

context "if /run/agama/cmdline.d/kernel is available" do
before do
expect(::File).to receive(:exist?).with("/run/agama/cmdline.d/kernel")
.and_return(true)
allow(Yast::WFM).to receive(:Read)
.with(path(".local.string"), "/run/agama/cmdline.d/kernel")
.and_return(cmdline)
end

it "reads kernel command line from /run/agama/cmdline.d/kernel" do
subject.ParseInstallationKernelCmdline
expect(subject.GetCmdLine).to eq " splash=verbose silent"
end
end

context "if /run/agama/cmdline.d/kernel is not available" do
before do
expect(::File).to receive(:exist?).with("/run/agama/cmdline.d/kernel")
.and_return(false)
allow(Yast::WFM).to receive(:Read)
.with(path(".local.string"), "/proc/cmdline")
.and_return(cmdline)
end

it "reads kernel command line from /proc/cmdline" do
subject.ParseInstallationKernelCmdline
expect(subject.GetCmdLine).to eq " splash=verbose silent"
end
end
end

context "for common options" do
let(:cmdline) { "splash=verbose silent" }

Expand Down

0 comments on commit 2c8bd91

Please sign in to comment.