From 2c8bd910d7abc569229a1782514b18a5df14a88a Mon Sep 17 00:00:00 2001 From: Josef Reidinger Date: Thu, 30 Jan 2025 15:31:13 +0100 Subject: [PATCH] read agama kernel params if available (bsc#1234678) --- library/system/src/modules/Kernel.rb | 5 +++- library/system/test/kernel_test.rb | 38 ++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/library/system/src/modules/Kernel.rb b/library/system/src/modules/Kernel.rb index 6c4347804..6d14537c3 100644 --- a/library/system/src/modules/Kernel.rb +++ b/library/system/src/modules/Kernel.rb @@ -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 diff --git a/library/system/test/kernel_test.rb b/library/system/test/kernel_test.rb index 8bba6f3c4..932f285d6 100755 --- a/library/system/test/kernel_test.rb +++ b/library/system/test/kernel_test.rb @@ -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" }