diff --git a/rust/agama-lib/share/profile.schema.json b/rust/agama-lib/share/profile.schema.json index 59e7e1af8b..0f71b2d6d3 100644 --- a/rust/agama-lib/share/profile.schema.json +++ b/rust/agama-lib/share/profile.schema.json @@ -66,6 +66,10 @@ "title": "Specify how long bootloader should wait on menu before going with default entry.", "type": "integer", "minimum": 0 + }, + "extraKernelParams": { + "title": "Specify additional kernel parameters that are added beside ones added by the installer.", + "type": "string" } }, "oneOf": [ diff --git a/rust/agama-lib/src/bootloader/model.rs b/rust/agama-lib/src/bootloader/model.rs index b4491a4a8c..1f235e187f 100644 --- a/rust/agama-lib/src/bootloader/model.rs +++ b/rust/agama-lib/src/bootloader/model.rs @@ -30,11 +30,16 @@ pub struct BootloaderSettings { pub stop_on_boot_menu: Option, #[serde(skip_serializing_if = "Option::is_none")] pub timeout: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub extra_kernel_params: Option, } impl BootloaderSettings { pub fn to_option(self) -> Option { - if self.stop_on_boot_menu.is_none() && self.timeout.is_none() { + if self.stop_on_boot_menu.is_none() + && self.timeout.is_none() + && self.extra_kernel_params.is_none() + { None } else { Some(self) diff --git a/rust/package/agama.changes b/rust/package/agama.changes index 7c55bfbc0e..2243e5c12b 100644 --- a/rust/package/agama.changes +++ b/rust/package/agama.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Thu Apr 10 20:24:06 UTC 2025 - Josef Reidinger + +- Allow to specify extra kernel parameters in profile + (jsc#PED-10810) + ------------------------------------------------------------------- Wed Apr 9 09:06:18 UTC 2025 - Martin Vidner diff --git a/service/lib/agama/storage/bootloader.rb b/service/lib/agama/storage/bootloader.rb index 33c1fd7f74..0ac8f364b3 100644 --- a/service/lib/agama/storage/bootloader.rb +++ b/service/lib/agama/storage/bootloader.rb @@ -34,6 +34,8 @@ class Config # bootloader timeout. Only positive numbers are supported and stop_on_boot_menu has # precedence attr_accessor :timeout + # bootloader extra kernel parameters beside ones that is proposed. + attr_accessor :extra_kernel_params # as both previous keys are conflicting, remember which one to set or none. It can be empty # and it means export nothing attr_accessor :keys_to_export @@ -42,6 +44,7 @@ def initialize @keys_to_export = [] @stop_on_boot_menu = false # false means use proposal, which has timeout @timeout = 10 # just some reasonable timeout, we do not send it anywhere + @extra_kernel_params = "" end def to_json(*_args) @@ -50,6 +53,10 @@ def to_json(*_args) # our json use camel case result[:stopOnBootMenu] = stop_on_boot_menu if keys_to_export.include?(:stop_on_boot_menu) result[:timeout] = timeout if keys_to_export.include?(:timeout) + if keys_to_export.include?(:extra_kernel_params) + result[:extraKernelParams] = + @extra_kernel_params + end result.to_json end @@ -58,11 +65,22 @@ def load_json(serialized_config) hsh = JSON.parse(serialized_config, symbolize_names: true) if hsh.include?(:timeout) self.timeout = hsh[:timeout] - self.keys_to_export = [:timeout] + keys_to_export.delete(:stop_on_boot_menu) + keys_to_export.push(:timeout) unless keys_to_export.include?(:timeout) + end if hsh.include?(:stopOnBootMenu) self.stop_on_boot_menu = hsh[:stopOnBootMenu] - self.keys_to_export = [:stop_on_boot_menu] + keys_to_export.delete(:timeout) + unless keys_to_export.include?(:stop_on_boot_menu) + keys_to_export.push(:stop_on_boot_menu) + end + end + if hsh.include?(:extraKernelParams) + self.extra_kernel_params = hsh[:extraKernelParams] + unless keys_to_export.include?(:extra_kernel_params) + keys_to_export.push(:extra_kernel_params) + end end self @@ -80,10 +98,25 @@ def write_config bootloader = ::Bootloader::BootloaderFactory.current write_stop_on_boot(bootloader) if @config.keys_to_export.include?(:stop_on_boot_menu) write_timeout(bootloader) if @config.keys_to_export.include?(:timeout) + if @config.keys_to_export.include?(:extra_kernel_params) + write_extra_kernel_params(bootloader) + end + + bootloader end private + def write_extra_kernel_params(bootloader) + # no systemd boot support for now + return unless bootloader.respond_to?(:grub_default) + + new_bl = bootloader.class.new + new_bl.grub_default.kernel_params.replace(@config.extra_kernel_params) + # and now just merge extra kernel params with all merge logic + bootloader.merge(new_bl) + end + def write_timeout(bootloader) # grub2 based bootloaders if bootloader.respond_to?(:grub_default) diff --git a/service/package/rubygem-agama-yast.changes b/service/package/rubygem-agama-yast.changes index 9ce0537935..300c3db69a 100644 --- a/service/package/rubygem-agama-yast.changes +++ b/service/package/rubygem-agama-yast.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Thu Apr 10 20:26:29 UTC 2025 - Josef Reidinger + +- Allow to specify extra kernel parameters for bootloader + (jsc#PED-10810) + ------------------------------------------------------------------- Wed Apr 9 06:52:58 UTC 2025 - José Iván López González diff --git a/service/test/agama/storage/bootloader_test.rb b/service/test/agama/storage/bootloader_test.rb index e38bd929b9..d312182872 100644 --- a/service/test/agama/storage/bootloader_test.rb +++ b/service/test/agama/storage/bootloader_test.rb @@ -45,8 +45,8 @@ it "exports only what was previously set" do expect(config.to_json).to eq "{\"stopOnBootMenu\":true}" - config.load_json({ "timeout" => 10 }.to_json) - expect(config.to_json).to eq "{\"timeout\":10}" + config.load_json({ "timeout" => 10, "extraKernelParams" => "verbose" }.to_json) + expect(config.to_json).to eq "{\"timeout\":10,\"extraKernelParams\":\"verbose\"}" end end