Hello community, here is the log from the commit of package yast2-bootloader for openSUSE:Factory checked in at 2015-08-28 08:24:58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/yast2-bootloader (Old) and /work/SRC/openSUSE:Factory/.yast2-bootloader.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "yast2-bootloader" Changes: -------- --- /work/SRC/openSUSE:Factory/yast2-bootloader/yast2-bootloader.changes 2015-08-21 12:42:41.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.yast2-bootloader.new/yast2-bootloader.changes 2015-08-28 08:24:59.000000000 +0200 @@ -1,0 +2,22 @@ +Thu Aug 27 13:21:25 UTC 2015 - jreidin...@suse.com + +- use extended partition to boot even for non software raids + (bnc#940765) +- for separate boot partition with btrfs prefer MBR bootloader + location (bnc#940797) +- 3.1.145 + +------------------------------------------------------------------- +Tue Aug 25 07:31:56 UTC 2015 - igonzalezs...@suse.com + +- Add support for kernel parameter with multiple values + (bsc#882082) +- 3.1.144 + +------------------------------------------------------------------- +Mon Aug 24 12:44:51 UTC 2015 - jreidin...@suse.com + +- fix removing password protection (bnc#942867) +- 3.1.143 + +------------------------------------------------------------------- Old: ---- yast2-bootloader-3.1.142.tar.bz2 New: ---- yast2-bootloader-3.1.145.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ yast2-bootloader.spec ++++++ --- /var/tmp/diff_new_pack.iqAbod/_old 2015-08-28 08:25:00.000000000 +0200 +++ /var/tmp/diff_new_pack.iqAbod/_new 2015-08-28 08:25:00.000000000 +0200 @@ -17,7 +17,7 @@ Name: yast2-bootloader -Version: 3.1.142 +Version: 3.1.145 Release: 0 BuildRoot: %{_tmppath}/%{name}-%{version}-build ++++++ yast2-bootloader-3.1.142.tar.bz2 -> yast2-bootloader-3.1.145.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-bootloader-3.1.142/package/yast2-bootloader.changes new/yast2-bootloader-3.1.145/package/yast2-bootloader.changes --- old/yast2-bootloader-3.1.142/package/yast2-bootloader.changes 2015-08-19 15:07:13.000000000 +0200 +++ new/yast2-bootloader-3.1.145/package/yast2-bootloader.changes 2015-08-27 15:42:09.000000000 +0200 @@ -1,4 +1,26 @@ ------------------------------------------------------------------- +Thu Aug 27 13:21:25 UTC 2015 - jreidin...@suse.com + +- use extended partition to boot even for non software raids + (bnc#940765) +- for separate boot partition with btrfs prefer MBR bootloader + location (bnc#940797) +- 3.1.145 + +------------------------------------------------------------------- +Tue Aug 25 07:31:56 UTC 2015 - igonzalezs...@suse.com + +- Add support for kernel parameter with multiple values + (bsc#882082) +- 3.1.144 + +------------------------------------------------------------------- +Mon Aug 24 12:44:51 UTC 2015 - jreidin...@suse.com + +- fix removing password protection (bnc#942867) +- 3.1.143 + +------------------------------------------------------------------- Wed Aug 19 12:42:41 UTC 2015 - jreidin...@suse.com - do not require parted on target system (bnc#937066) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-bootloader-3.1.142/package/yast2-bootloader.spec new/yast2-bootloader-3.1.145/package/yast2-bootloader.spec --- old/yast2-bootloader-3.1.142/package/yast2-bootloader.spec 2015-08-19 15:07:13.000000000 +0200 +++ new/yast2-bootloader-3.1.145/package/yast2-bootloader.spec 2015-08-27 15:42:09.000000000 +0200 @@ -17,7 +17,7 @@ Name: yast2-bootloader -Version: 3.1.142 +Version: 3.1.145 Release: 0 BuildRoot: %{_tmppath}/%{name}-%{version}-build diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-bootloader-3.1.142/src/include/bootloader/routines/misc.rb new/yast2-bootloader-3.1.145/src/include/bootloader/routines/misc.rb --- old/yast2-bootloader-3.1.142/src/include/bootloader/routines/misc.rb 2015-08-19 15:07:13.000000000 +0200 +++ new/yast2-bootloader-3.1.145/src/include/bootloader/routines/misc.rb 2015-08-27 15:42:09.000000000 +0200 @@ -139,35 +139,51 @@ ret end - # get kernel parameter from kernel command line + # get kernel parameter values from kernel command line + # # @param [String] line string original line # @param [String] key string parameter key - # @return [String] value, "false" if not present, - # "true" if present key without value + # @return [String,Array<String>] value, "false" if not present or "true" if present without + # value. If the parameter has on more than 1 value, an array will be returned. def getKernelParamFromLine(line, key) # FIXME: this doesn't work with quotes and spaces res = "false" # we can get nil if params is not yet proposed, so return not there (bnc#902397) return res unless line params = line.split(" ").reject(&:empty?) - params.each do |p| - l = p.split("=") - res = l[1] || "true" if l[0] == key + values = params.map { |p| kernel_param_parts(p) }.select { |p| p[0] == key }.map(&:last).uniq + if values.empty? # not present + "false" + elsif values.size == 1 # only one value + values.first + else # more than 1 value + values end - res end - def kernel_param_key(value) - value.split("=").first + def kernel_param_key(param) + param.split("=").first + end + + # Split kernel parameters into [key, value] form + # + # It also takes care about converting parameters without a value + # (ie. "quiet" will be ["quiet", "true"]). + # + # @param [String] param Parameter string in "key=value" form. + # @return [Array<String>] Parameter key and value. + def kernel_param_parts(param) + key, value = param.split("=") + [key, value || "true"] end # set kernel parameter to GRUB command line # @param [String] line string original line # @param [String] key string parameter key - # @param [String] value string value, "false" to remove key, - # "true" to add key without value + # @param [String,Array<String>] values string (or array of strings) containing values, + # "false" to remove key, "true" to add key without value # @return [String] new kernel command line - def setKernelParamToLine(line, key, value) + def setKernelParamToLine(line, key, values) line ||= "" # FIXME: this doesn't work with quotes and spaces params = line.split(" ").reject(&:empty?) @@ -182,25 +198,28 @@ k = kernel_param_key(param) if k != key # not our param res << param - elsif value == "false" + elsif values == "false" next # do nothing as we want to remove this param elsif occurences[k] == 1 # last parameter with given key done = true - if value == "true" + if values == "true" res << key - elsif value != "false" - res << Builtins.sformat("%1=%2", key, value) + elsif values != "false" + Array(values).each do |v| + res << Builtins.sformat("%1=%2", key, v) + end end else occurences[k] -= 1 - res << param end end if !done - if value == "true" + if values == "true" params << key - elsif value != "false" - params << Builtins.sformat("%1=%2", key, value) + elsif values != "false" + Array(values).each do |v| + params << Builtins.sformat("%1=%2", key, v) + end end end params.join(" ") diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-bootloader-3.1.142/src/lib/bootloader/grub2pwd.rb new/yast2-bootloader-3.1.145/src/lib/bootloader/grub2pwd.rb --- old/yast2-bootloader-3.1.142/src/lib/bootloader/grub2pwd.rb 2015-08-19 15:07:13.000000000 +0200 +++ new/yast2-bootloader-3.1.145/src/lib/bootloader/grub2pwd.rb 2015-08-27 15:42:09.000000000 +0200 @@ -114,7 +114,8 @@ def disable return unless used_on_target? - Yast::SCR.Execute(YAST_BASH_PATH, "rm '#{PWD_ENCRYPTION_FILE}'") + # operate on target as we have to remove password during installation from target grub2 + Yast::SCR.Execute(Yast::Path.new(".target.bash"), "rm '#{PWD_ENCRYPTION_FILE}'") end def encrypt(password) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-bootloader-3.1.142/src/lib/bootloader/stage1.rb new/yast2-bootloader-3.1.145/src/lib/bootloader/stage1.rb --- old/yast2-bootloader-3.1.142/src/lib/bootloader/stage1.rb 2015-08-19 15:07:13.000000000 +0200 +++ new/yast2-bootloader-3.1.145/src/lib/bootloader/stage1.rb 2015-08-27 15:42:09.000000000 +0200 @@ -60,24 +60,30 @@ def propose_boot_location raise "Boot partition disk not found" if boot_partition_disk.empty? selected_location = :mbr + separate_boot = Yast::BootStorage.BootPartitionDevice != Yast::BootStorage.RootPartitionDevice # there was check if boot device is on logical partition # IMO it is good idea check MBR also in this case # see bug #279837 comment #53 if boot_partition_on_mbr_disk? - separate_boot = Yast::BootStorage.BootPartitionDevice != Yast::BootStorage.RootPartitionDevice selected_location = separate_boot ? :boot : :root elsif underlying_boot_partition_devices.size > 1 selected_location = :mbr end - if logical_boot? && extended_partition && - underlying_boot_partition_devices.size > 1 + if logical_boot? && extended_partition + log.info "/boot is on logical partition and extended detected, extended proposed" selected_location = :extended end - if logical_boot_with_btrfs? - log.info "/boot is on logical parititon and uses btrfs, mbr is favored in this situration" + if boot_with_btrfs? && logical_boot? + log.info "/boot is on logical partition and uses btrfs, mbr is favored in this situation" + selected_location = :mbr + end + + # for separate btrfs partition prefer MBR (bnc#940797) + if boot_with_btrfs? && separate_boot + log.info "separated /boot is used and uses btrfs, mbr is favored in this situation" selected_location = :mbr end @@ -108,35 +114,29 @@ @logical_boot end - def logical_boot_with_btrfs? + def boot_with_btrfs? init_boot_info unless @boot_initialized - @logical_boot_with_btrfs + @boot_with_btrfs end def init_boot_info boot_disk_map = target_map[boot_partition_disk] || {} partitions_on_boot_partition_disk = boot_disk_map["partitions"] || [] @logical_boot = false - @logical_boot_with_btrfs = false + @boot_with_btrfs = false partitions_on_boot_partition_disk.each do |p| if p["type"] == :extended @extended = p["device"] - elsif underlying_boot_partition_devices.include?(p["device"]) && - p["type"] == :logical - # If any of the underlying_boot_partition_devices can be found on - # the boot_partition_disk AND is a logical partition, set - # is_logical to true. - # For soft-RAID this will not match anyway ("/dev/[hs]da*" does not - # match "/dev/md*"). - @logical_boot = true - @logical_boot_with_btrfs = true if p["used_fs"] == :btrfs + elsif underlying_boot_partition_devices.include?(p["device"]) + @boot_with_btrfs = true if p["used_fs"] == :btrfs + @logical_boot = true if p["type"] == :logical end end log.info "/boot is in logical partition: #{@logical_boot}" - log.info "/boot is in logical partition and use btrfs: #{@logical_boot_with_btrfs}" + log.info "/boot use btrfs: #{@boot_with_btrfs}" log.info "The extended partition: #{@extended}" end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-bootloader-3.1.142/src/modules/BootCommon.rb new/yast2-bootloader-3.1.145/src/modules/BootCommon.rb --- old/yast2-bootloader-3.1.142/src/modules/BootCommon.rb 2015-08-19 15:07:13.000000000 +0200 +++ new/yast2-bootloader-3.1.145/src/modules/BootCommon.rb 2015-08-27 15:42:09.000000000 +0200 @@ -555,8 +555,8 @@ publish :function => :remapGlobals, :type => "map <string, string> (map <string, string>)" publish :function => :GetBootloaderDevice, :type => "string ()" publish :function => :GetBootloaderDevices, :type => "list <string> ()" - publish :function => :getKernelParamFromLine, :type => "string (string, string)" - publish :function => :setKernelParamToLine, :type => "string (string, string, string)" + publish :function => :getKernelParamFromLine, :type => "any (string, string)" + publish :function => :setKernelParamToLine, :type => "string (string, string, any)" publish :function => :restoreMBR, :type => "boolean (string)" publish :function => :UpdateInstallationKernelParameters, :type => "void ()" publish :function => :BootloaderInstallable, :type => "boolean ()" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-bootloader-3.1.142/src/modules/Bootloader.rb new/yast2-bootloader-3.1.145/src/modules/Bootloader.rb --- old/yast2-bootloader-3.1.142/src/modules/Bootloader.rb 2015-08-19 15:07:13.000000000 +0200 +++ new/yast2-bootloader-3.1.145/src/modules/Bootloader.rb 2015-08-27 15:42:09.000000000 +0200 @@ -22,6 +22,8 @@ class BootloaderClass < Module include Yast::Logger + OLD_API_MAPPING = { "true" => :present, "false" => :missing } + def main Yast.import "UI" @@ -447,11 +449,14 @@ raise ArgumentError, "Unknown flavor #{flavor}" unless kernel_line_key line = BootCommon.globals[kernel_line_key] - ret = BootCommon.getKernelParamFromLine(line, key) + values = BootCommon.getKernelParamFromLine(line, key) # map old api response to new one - api_mapping = { "true" => :present, "false" => :missing } - api_mapping[ret] || ret + if values.is_a?(Array) # more than one value + values + else # only one value + OLD_API_MAPPING[values] || values + end end # Modify kernel parameters for installed kernels according to values @@ -463,6 +468,7 @@ # - `:recovery` DEPRECATED: no longer use # - `:xen_guest` for xen guest kernels # - `:xen_host` for xen host kernels + # @return [Boolean] true if params were modified; false otherwise. # # @example add crashkernel parameter to common kernel and xen guest # Bootloader.modify_kernel_params(:common, :xen_guest, "crashkernel" => "256M@64M") @@ -499,23 +505,19 @@ values[key] = remap_values[values[key]] || values[key] end + kernel_lines = args.map do |a| + FLAVOR_KERNEL_LINE_MAP[a] || + raise(ArgumentError, "Invalid argument #{a.inspect}") + end + + changed = false values.each do |key, value| - next if key == "root" # grub2 does not support modifying root - if key == "vga" - BootCommon.globals["vgamode"] = value == "false" ? "" : value - next - else - kernel_lines = args.map do |a| - FLAVOR_KERNEL_LINE_MAP[a] || - raise(ArgumentError, "Invalid argument #{a.inspect}") - end - kernel_lines.each do |line_key| - BootCommon.globals[line_key] = BootCommon.setKernelParamToLine(BootCommon.globals[line_key], key, value) - end - end - BootCommon.globals["__modified"] = "1" - BootCommon.changed = true + changed = true if add_kernel_param(kernel_lines, key, value) end + + return false unless changed + BootCommon.globals["__modified"] = "1" + BootCommon.changed = true end # Get currently used bootloader, detect if not set yet @@ -624,6 +626,26 @@ ret end + # Add a kernel parameter + # + # @param [Array<Symbol>] kernel_lines Kernel lines to update + # @param [String] key Parameter name + # @param [String] value Parameter value + # @return [true,false] True if the parameter was added to some kernel line; + # false otherwise (not added or added to as 'global'). + def add_kernel_param(kernel_lines, key, value) + return false if key == "root" # grub2 does not support modifying root + if key == "vga" + BootCommon.globals["vgamode"] = value == "false" ? "" : value + false + else + kernel_lines.each do |line_key| + BootCommon.globals[line_key] = BootCommon.setKernelParamToLine(BootCommon.globals[line_key], key, value) + end + true + end + end + publish :function => :Export, :type => "map ()" publish :function => :Import, :type => "boolean (map)" publish :function => :Propose, :type => "void ()" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-bootloader-3.1.142/test/boot_common_test.rb new/yast2-bootloader-3.1.145/test/boot_common_test.rb --- old/yast2-bootloader-3.1.142/test/boot_common_test.rb 2015-08-19 15:07:13.000000000 +0200 +++ new/yast2-bootloader-3.1.145/test/boot_common_test.rb 2015-08-27 15:42:09.000000000 +0200 @@ -23,6 +23,24 @@ new: "quit silent=1 vga=800") end + context "when kernel parameter is duplicated" do + it "return line with modified kernel parameter to given value avoiding duplications" do + expect_set(key: "crashkernel", + val: "64M,low", + old: "quit silent=1 crashkernel=128M,low crashkernel=256M,high", + new: "quit silent=1 crashkernel=64M,low") + end + end + + context "when value is an array" do + it "return line with modified kernel parameter to given values if line contain key" do + expect_set(key: "crashkernel", + val: ["128M,low", "256M,high"], + old: "quit silent=1", + new: "quit silent=1 crashkernel=128M,low crashkernel=256M,high") + end + end + it "return line with added parameter to kernel parameter line if value is \"true\"" do expect_set(key: "verbose", val: "true", @@ -72,4 +90,49 @@ new: "") end end + + describe ".getKernelParamFromLine" do + context "when parameter is not defined" do + let(:line) { "quiet" } + + it "returns 'false'" do + expect(Yast::BootCommon.getKernelParamFromLine("quiet", "crashkernel")).to eq("false") + end + end + + context "when parameter is present but hasn't got a value" do + let(:line) { "quiet" } + + it "returns 'true'" do + expect(Yast::BootCommon.getKernelParamFromLine(line, "quiet")).to eq("true") + end + + context "and is duplicated" do + let(:line) { "quiet crashkernel=72M,low quiet" } + + it "returns the value" do + expect(Yast::BootCommon.getKernelParamFromLine(line, "quiet")).to eq("true") + end + end + end + + context "when parameter has a value" do + let(:line) { "quiet crashkernel=72M,low" } + + it "returns the value" do + expect(Yast::BootCommon.getKernelParamFromLine(line, "crashkernel")) + .to eq("72M,low") + end + end + + context "when parameter has many values" do + let(:line) { "quiet crashkernel=72M,low crashkernel=128M,high" } + + it "returns all the values as an array" do + expect(Yast::BootCommon.getKernelParamFromLine(line, "crashkernel")) + .to eq(["72M,low", "128M,high"]) + end + end + end + end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-bootloader-3.1.142/test/bootloader_test.rb new/yast2-bootloader-3.1.145/test/bootloader_test.rb --- old/yast2-bootloader-3.1.142/test/bootloader_test.rb 2015-08-19 15:07:13.000000000 +0200 +++ new/yast2-bootloader-3.1.145/test/bootloader_test.rb 2015-08-27 15:42:09.000000000 +0200 @@ -3,6 +3,14 @@ Yast.import "Bootloader" describe Yast::Bootloader do + # Helper method to grab the kernel line for a given target. + # + # @param [Symbol] target Name of the kernel (:common, :xen_host, etc.) + # @return [String] Name of the kernel line to modify (:append, :xen_host_append, etc.) + def kernel_line(target) + Yast::BootloaderClass::FLAVOR_KERNEL_LINE_MAP[target] + end + subject { Yast::Bootloader } describe ".Import" do @@ -150,4 +158,174 @@ subject.ReadOrProposeIfNeeded end end + + describe ".modify_kernel_params" do + let(:initial_lines) { {} } + let(:params) { { "crashkernel" => "256M" } } + let(:append) { "crashkernel=256M" } + + before do + Yast::BootCommon.changed = false + end + + around do |example| + old_globals_value = Yast::BootCommon.globals + Yast::BootCommon.globals = initial_lines + example.run + Yast::BootCommon.globals = old_globals_value + end + + context "when no parameters are passed" do + it "raises an ArgumentError exception" do + expect { subject.modify_kernel_params(:common) }.to raise_error(ArgumentError) + expect(Yast::BootCommon.changed).to eq(false) + end + end + + context "when target does not exist" do + it "raises an ArgumentError exception" do + expect { subject.modify_kernel_params(:unknown, params) }.to raise_error(ArgumentError) + expect(Yast::BootCommon.changed).to eq(false) + end + end + + context "when no target is specified" do + it "uses :common by default" do + subject.modify_kernel_params(params) + + expect(Yast::BootCommon.globals[kernel_line(:common)]).to eq(append) + expect(Yast::BootCommon.globals["__modified"]).to eq("1") + expect(Yast::BootCommon.changed).to eq(true) + end + end + + context "when a target is specified" do + it "adds parameter for that target" do + subject.modify_kernel_params(:xen_guest, params) + + expect(Yast::BootCommon.globals[kernel_line(:xen_guest)]).to eq(append) + expect(Yast::BootCommon.globals["__modified"]).to eq("1") + expect(Yast::BootCommon.changed).to eq(true) + end + end + + context "when multiple targets are specified" do + it "adds parameters to each target" do + subject.modify_kernel_params(:xen_host, :xen_guest, params) + + expect(Yast::BootCommon.globals[kernel_line(:xen_host)]).to eq(append) + expect(Yast::BootCommon.globals[kernel_line(:xen_guest)]).to eq(append) + expect(Yast::BootCommon.globals["__modified"]).to eq("1") + expect(Yast::BootCommon.changed).to eq(true) + end + end + + context "when targets are specified as an array" do + it "adds parameters to each target" do + subject.modify_kernel_params([:xen_host, :xen_guest], params) + + expect(Yast::BootCommon.globals[kernel_line(:xen_host)]).to eq(append) + expect(Yast::BootCommon.globals[kernel_line(:xen_guest)]).to eq(append) + expect(Yast::BootCommon.globals["__modified"]).to eq("1") + expect(Yast::BootCommon.changed).to eq(true) + end + end + + context "when a parameter is set to be removed" do + let(:initial_lines) { { kernel_line(:common) => "quiet #{append}" } } + let(:params) { { "quiet" => :missing } } + + it "removes parameter from the given target" do + subject.modify_kernel_params(:common, params) + + expect(Yast::BootCommon.globals[kernel_line(:common)]).to eq(append) + expect(Yast::BootCommon.globals["__modified"]).to eq("1") + expect(Yast::BootCommon.changed).to eq(true) + end + end + + context "when a parameter is set to be just present" do + let(:params) { { "quiet" => :present } } + + it "adds the parameter to the given target without any value" do + subject.modify_kernel_params(:common, params) + + expect(Yast::BootCommon.globals[kernel_line(:common)]).to eq("quiet") + expect(Yast::BootCommon.globals["__modified"]).to eq("1") + expect(Yast::BootCommon.changed).to eq(true) + end + end + + context "when parameter is 'vga'" do + let(:params) { { "vga" => "80" } } + + it "adds the parameter as 'vgamode' to the global scope and does not mark BootCommon as 'modified'" do + subject.modify_kernel_params(:common, params) + expect(Yast::BootCommon.globals["vgamode"]).to eq("80") + expect(Yast::BootCommon.globals).to_not have_key("__modified") + expect(Yast::BootCommon.changed).to eq(false) + end + end + + context "when parameter is 'root' (cannot be modified)" do + let(:params) { { "root" => "/dev/sda1" } } + + it "makes no changes" do + expect { subject.modify_kernel_params(:common, params) } + .to_not change { Yast::BootCommon.globals } + expect(Yast::BootCommon.changed).to eq(false) + end + end + + context "when multiple values are specified for a parameter" do + let(:params) { { "crashkernel" => ["256M,low", "1024M,high"] } } + + it "adds the parameter multiple times" do + subject.modify_kernel_params(:common, params) + + expect(Yast::BootCommon.globals[kernel_line(:common)]) + .to eq("crashkernel=256M,low crashkernel=1024M,high") + expect(Yast::BootCommon.globals["__modified"]).to eq("1") + expect(Yast::BootCommon.changed).to eq(true) + end + end + end + + describe ".kernel_param" do + let(:initial_lines) do + { kernel_line(:common) => "quiet verbose=1 crashkernel=256M,low crashkernel=1024M,high" } + end + + around do |example| + old_value = Yast::BootCommon.globals + Yast::BootCommon.globals = initial_lines + example.run + Yast::BootCommon.globals = old_value + end + + context "when parameter does not exist" do + it "returns 'false'" do + expect(subject.kernel_param(:common, "nothing")).to eq(:missing) + end + end + + context "when parameter exists but has no value" do + it "returns 'true'" do + expect(subject.kernel_param(:common, "quiet")).to eq(:present) + end + end + + context "when parameter exists and has one value" do + it "returns the value" do + expect(subject.kernel_param(:common, "verbose")).to eq("1") + end + end + + context "when parameter exists but has multiple values" do + it "returns all the values" do + expect(subject.kernel_param(:common, "crashkernel")) + .to eq(["256M,low", "1024M,high"]) + end + end + end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-bootloader-3.1.142/test/grub2pwd_test.rb new/yast2-bootloader-3.1.145/test/grub2pwd_test.rb --- old/yast2-bootloader-3.1.142/test/grub2pwd_test.rb 2015-08-19 15:07:13.000000000 +0200 +++ new/yast2-bootloader-3.1.145/test/grub2pwd_test.rb 2015-08-27 15:42:09.000000000 +0200 @@ -138,7 +138,7 @@ .and_return(true) expect(Yast::SCR).to receive(:Execute) - .with(described_class::YAST_BASH_PATH, "rm '#{described_class::PWD_ENCRYPTION_FILE}'") + .with(path(".target.bash"), "rm '#{described_class::PWD_ENCRYPTION_FILE}'") subject.write end