Hello community,
here is the log from the commit of package yast2-bootloader for
openSUSE:Factory checked in at 2020-03-01 21:27:14
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/yast2-bootloader (Old)
and /work/SRC/openSUSE:Factory/.yast2-bootloader.new.26092 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "yast2-bootloader"
Sun Mar 1 21:27:14 2020 rev:285 rq:780419 version:4.2.17
Changes:
--------
--- /work/SRC/openSUSE:Factory/yast2-bootloader/yast2-bootloader.changes
2020-01-04 19:21:05.389130553 +0100
+++
/work/SRC/openSUSE:Factory/.yast2-bootloader.new.26092/yast2-bootloader.changes
2020-03-01 21:27:33.076500077 +0100
@@ -1,0 +2,13 @@
+Fri Feb 28 14:23:30 UTC 2020 - Steffen Winterfeldt <[email protected]>
+
+- add support for S390 secure boot (jsc#SLE-9471, jsc#SLE-9425)
+- 4.2.17
+
+-------------------------------------------------------------------
+Fri Feb 21 11:10:24 UTC 2020 - José Iván López González <[email protected]>
+
+- Delegate the logic for calculating a device udev link to
+ yast2-storage-ng module (related to bsc#1151075).
+- 4.2.16
+
+-------------------------------------------------------------------
Old:
----
yast2-bootloader-4.2.15.tar.bz2
New:
----
yast2-bootloader-4.2.17.tar.bz2
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ yast2-bootloader.spec ++++++
--- /var/tmp/diff_new_pack.fjIIFH/_old 2020-03-01 21:27:33.528500995 +0100
+++ /var/tmp/diff_new_pack.fjIIFH/_new 2020-03-01 21:27:33.532501003 +0100
@@ -17,7 +17,7 @@
Name: yast2-bootloader
-Version: 4.2.15
+Version: 4.2.17
Release: 0
Summary: YaST2 - Bootloader Configuration
License: GPL-2.0-or-later
@@ -29,8 +29,8 @@
BuildRequires: yast2 >= 3.1.176
BuildRequires: yast2-devtools >= 4.2.2
BuildRequires: yast2-ruby-bindings >= 1.0.0
-# Y2Storage::Mountable#mount_path
-BuildRequires: yast2-storage-ng >= 4.0.90
+# Y2Storage::Mountable#preferred_mount_by
+BuildRequires: yast2-storage-ng >= 4.2.90
# lenses needed also for tests
BuildRequires: augeas-lenses
BuildRequires: update-desktop-files
@@ -46,8 +46,8 @@
Requires: yast2-core >= 2.18.7
Requires: yast2-packager >= 2.17.24
Requires: yast2-pkg-bindings >= 2.17.25
-# Y2Storage::Mountable#mount_path
-Requires: yast2-storage-ng >= 4.0.90
+# Y2Storage::Mountable#preferred_mount_by
+Requires: yast2-storage-ng >= 4.2.90
# Support for multiple values in GRUB_TERMINAL
Requires: rubygem(%rb_default_ruby_abi:cfa_grub2) >= 1.0.1
# lenses are needed as cfa_grub2 depends only on augeas bindings, but also
++++++ yast2-bootloader-4.2.15.tar.bz2 -> yast2-bootloader-4.2.17.tar.bz2 ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/yast2-bootloader-4.2.15/package/yast2-bootloader.changes
new/yast2-bootloader-4.2.17/package/yast2-bootloader.changes
--- old/yast2-bootloader-4.2.15/package/yast2-bootloader.changes
2020-01-03 14:22:31.000000000 +0100
+++ new/yast2-bootloader-4.2.17/package/yast2-bootloader.changes
2020-02-28 15:32:22.000000000 +0100
@@ -1,4 +1,17 @@
-------------------------------------------------------------------
+Fri Feb 28 14:23:30 UTC 2020 - Steffen Winterfeldt <[email protected]>
+
+- add support for S390 secure boot (jsc#SLE-9471, jsc#SLE-9425)
+- 4.2.17
+
+-------------------------------------------------------------------
+Fri Feb 21 11:10:24 UTC 2020 - José Iván López González <[email protected]>
+
+- Delegate the logic for calculating a device udev link to
+ yast2-storage-ng module (related to bsc#1151075).
+- 4.2.16
+
+-------------------------------------------------------------------
Fri Jan 3 13:08:10 UTC 2020 - Josef Reidinger <[email protected]>
- deduplicate kernel parameters after merging them
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/yast2-bootloader-4.2.15/package/yast2-bootloader.spec
new/yast2-bootloader-4.2.17/package/yast2-bootloader.spec
--- old/yast2-bootloader-4.2.15/package/yast2-bootloader.spec 2020-01-03
14:22:31.000000000 +0100
+++ new/yast2-bootloader-4.2.17/package/yast2-bootloader.spec 2020-02-28
15:32:22.000000000 +0100
@@ -17,7 +17,7 @@
Name: yast2-bootloader
-Version: 4.2.15
+Version: 4.2.17
Release: 0
Summary: YaST2 - Bootloader Configuration
License: GPL-2.0-or-later
@@ -29,8 +29,8 @@
BuildRequires: yast2 >= 3.1.176
BuildRequires: yast2-devtools >= 4.2.2
BuildRequires: yast2-ruby-bindings >= 1.0.0
-# Y2Storage::Mountable#mount_path
-BuildRequires: yast2-storage-ng >= 4.0.90
+# Y2Storage::Mountable#preferred_mount_by
+BuildRequires: yast2-storage-ng >= 4.2.90
# lenses needed also for tests
BuildRequires: augeas-lenses
BuildRequires: rubygem(%rb_default_ruby_abi:cfa_grub2) >= 1.0.1
@@ -46,8 +46,8 @@
Requires: yast2-core >= 2.18.7
Requires: yast2-packager >= 2.17.24
Requires: yast2-pkg-bindings >= 2.17.25
-# Y2Storage::Mountable#mount_path
-Requires: yast2-storage-ng >= 4.0.90
+# Y2Storage::Mountable#preferred_mount_by
+Requires: yast2-storage-ng >= 4.2.90
# Support for multiple values in GRUB_TERMINAL
Requires: rubygem(%rb_default_ruby_abi:cfa_grub2) >= 1.0.1
# lenses are needed as cfa_grub2 depends only on augeas bindings, but also
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/yast2-bootloader-4.2.15/src/lib/bootloader/autoyast_converter.rb
new/yast2-bootloader-4.2.17/src/lib/bootloader/autoyast_converter.rb
--- old/yast2-bootloader-4.2.15/src/lib/bootloader/autoyast_converter.rb
2020-01-03 14:22:31.000000000 +0100
+++ new/yast2-bootloader-4.2.17/src/lib/bootloader/autoyast_converter.rb
2020-02-28 15:32:22.000000000 +0100
@@ -234,6 +234,7 @@
# only for grub2, not for others
GRUB2_BOOLEAN_MAPPING = {
+ "secure_boot" => :secure_boot,
"trusted_grub" => :trusted_boot
}.freeze
private_constant :GRUB2_BOOLEAN_MAPPING
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yast2-bootloader-4.2.15/src/lib/bootloader/grub2.rb
new/yast2-bootloader-4.2.17/src/lib/bootloader/grub2.rb
--- old/yast2-bootloader-4.2.15/src/lib/bootloader/grub2.rb 2020-01-03
14:22:31.000000000 +0100
+++ new/yast2-bootloader-4.2.17/src/lib/bootloader/grub2.rb 2020-02-28
15:32:22.000000000 +0100
@@ -7,6 +7,7 @@
require "bootloader/device_map"
require "bootloader/stage1"
require "bootloader/grub_install"
+require "bootloader/systeminfo"
Yast.import "Arch"
Yast.import "BootStorage"
@@ -15,7 +16,6 @@
module Bootloader
# Represents non-EFI variant of GRUB2
class Grub2 < Grub2Base
- attr_reader :stage1
attr_reader :device_map
def initialize
@@ -65,7 +65,9 @@
# powernv must not call grub2-install (bnc#970582)
unless Yast::Arch.board_powernv
- failed = @grub_install.execute(devices: stage1.devices, trusted_boot:
trusted_boot)
+ failed = @grub_install.execute(
+ devices: stage1.devices, secure_boot: secure_boot, trusted_boot:
trusted_boot
+ )
failed.each { |f| stage1.remove_device(f) }
stage1.write
end
@@ -100,12 +102,12 @@
Yast::Builtins.sformat(
_("Boot Loader Type: %1"),
"GRUB2"
- ),
- Yast::Builtins.sformat(
- _("Enable Trusted Boot: %1"),
- trusted_boot ? _("yes") : _("no")
)
]
+
+ result << secure_boot_summary if Systeminfo.secure_boot_available?(name)
+ result << trusted_boot_summary if
Systeminfo.trusted_boot_available?(name)
+
locations_val = locations
if !locations_val.empty?
result << Yast::Builtins.sformat(
@@ -142,7 +144,9 @@
# FIXME: refactor with injection like super(prewrite: prewrite, sysconfig
= ...)
# overwrite BootloaderBase version to save trusted boot
def write_sysconfig(prewrite: false)
- sysconfig = Bootloader::Sysconfig.new(bootloader: name, trusted_boot:
trusted_boot)
+ sysconfig = Bootloader::Sysconfig.new(
+ bootloader: name, secure_boot: secure_boot, trusted_boot: trusted_boot
+ )
prewrite ? sysconfig.pre_write : sysconfig.write
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/yast2-bootloader-4.2.15/src/lib/bootloader/grub2_widgets.rb
new/yast2-bootloader-4.2.17/src/lib/bootloader/grub2_widgets.rb
--- old/yast2-bootloader-4.2.15/src/lib/bootloader/grub2_widgets.rb
2020-01-03 14:22:31.000000000 +0100
+++ new/yast2-bootloader-4.2.17/src/lib/bootloader/grub2_widgets.rb
2020-02-28 15:32:22.000000000 +0100
@@ -6,6 +6,7 @@
require "bootloader/device_map_dialog"
require "bootloader/serial_console"
require "bootloader/cpu_mitigations"
+require "bootloader/systeminfo"
require "cfa/matcher"
Yast.import "BootStorage"
@@ -14,6 +15,7 @@
Yast.import "Report"
Yast.import "UI"
Yast.import "Mode"
+Yast.import "Arch"
module Bootloader
# Adds to generic widget grub2 specific helpers
@@ -326,7 +328,7 @@
end
def help
- _("<p><b>Enable Secure Boot Support</b> if checked enables UEFI Secure
Boot support.</p>")
+ _("<p><b>Enable Secure Boot Support</b> if checked enables Secure Boot
support.</p>")
end
def init
@@ -336,6 +338,19 @@
def store
grub2.secure_boot = value
end
+
+ def validate
+ return true if Yast::Mode.config ||
+ !Yast::Arch.s390 ||
+ value == Systeminfo.secure_boot_active?
+
+ Yast::Popup.ContinueCancel(
+ _(
+ "Make sure the Secure Boot setting matches the configuration of the
HMC.\n\n" \
+ "Otherwise this system will not boot."
+ )
+ )
+ end
end
# Represents switcher for Trusted Boot
@@ -978,18 +993,11 @@
end
def secure_boot_widget?
- (Yast::Arch.x86_64 || Yast::Arch.i386 || Yast::Arch.aarch64) &&
grub2.name == "grub2-efi"
+ Systeminfo.secure_boot_available?(grub2.name)
end
def trusted_boot_widget?
- return false if !(Yast::Arch.x86_64 || Yast::Arch.i386)
-
- return true if grub2.name == "grub2"
-
- # for details about grub2 efi trusted boot support see FATE#315831
- return File.exist?("/dev/tpm0") if grub2.name == "grub2-efi"
-
- false
+ Systeminfo.trusted_boot_available?(grub2.name)
end
def pmbr_widget?
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/yast2-bootloader-4.2.15/src/lib/bootloader/grub2base.rb
new/yast2-bootloader-4.2.17/src/lib/bootloader/grub2base.rb
--- old/yast2-bootloader-4.2.15/src/lib/bootloader/grub2base.rb 2020-01-03
14:22:31.000000000 +0100
+++ new/yast2-bootloader-4.2.17/src/lib/bootloader/grub2base.rb 2020-02-28
15:32:22.000000000 +0100
@@ -45,13 +45,22 @@
attr_accessor :pmbr_action
- # @return [Boolean]
+ # @!attribute trusted_boot
+ # @return [Boolean] current trusted boot setting
attr_accessor :trusted_boot
+ # @!attribute secure_boot
+ # @return [Boolean] current secure boot setting
+ attr_accessor :secure_boot
+
# @!attribute console
# @return [::Bootloader::SerialConsole] serial console or nil if none
attr_reader :console
+ # @!attribute stage1
+ # @return [::Bootloader::Stage1, nil] bootloader stage1, if one is needed
+ attr_reader :stage1
+
def initialize
super
@@ -114,7 +123,8 @@
@sections = ::Bootloader::Sections.new(grub_cfg)
log.info "grub sections: #{@sections.all}"
- self.trusted_boot = Sysconfig.from_system.trusted_boot
+ self.trusted_boot = Systeminfo.trusted_boot_active?
+ self.secure_boot = Systeminfo.secure_boot_active?
end
def write
@@ -151,7 +161,7 @@
propose_xen_hypervisor
self.trusted_boot = false
- nil
+ self.secure_boot = Systeminfo.secure_boot_active?
end
def merge(other)
@@ -163,6 +173,7 @@
merge_sections(other)
self.trusted_boot = other.trusted_boot unless other.trusted_boot.nil?
+ self.secure_boot = other.secure_boot unless other.secure_boot.nil?
end
def enable_serial_console(console_arg_string)
@@ -365,6 +376,30 @@
def propose_encrypted
grub_default.cryptodisk.value = !!Yast::BootStorage.encrypted_boot?
end
+
+ # Secure boot setting shown in summary screen.
+ #
+ # @return [String]
+ def secure_boot_summary
+ _("Secure Boot:") + " " + (secure_boot ? _("enabled") : _("disabled")) +
" " +
+ if secure_boot
+ "<a href=\"disable_secure_boot\">(" + _("disable") + ")</a>"
+ else
+ "<a href=\"enable_secure_boot\">(" + _("enable") + ")</a>"
+ end
+ end
+
+ # Trusted boot setting shown in summary screen.
+ #
+ # @return [String]
+ def trusted_boot_summary
+ _("Trusted Boot:") + " " + (trusted_boot ? _("enabled") : _("disabled"))
+ " " +
+ if trusted_boot
+ "<a href=\"disable_trusted_boot\">(" + _("disable") + ")</a>"
+ else
+ "<a href=\"enable_trusted_boot\">(" + _("enable") + ")</a>"
+ end
+ end
end
# rubocop:enable Metrics/ClassLength
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/yast2-bootloader-4.2.15/src/lib/bootloader/grub2efi.rb
new/yast2-bootloader-4.2.17/src/lib/bootloader/grub2efi.rb
--- old/yast2-bootloader-4.2.15/src/lib/bootloader/grub2efi.rb 2020-01-03
14:22:31.000000000 +0100
+++ new/yast2-bootloader-4.2.17/src/lib/bootloader/grub2efi.rb 2020-02-28
15:32:22.000000000 +0100
@@ -13,7 +13,6 @@
# Represents grub2 bootloader with efi target
class Grub2EFI < Grub2Base
include Yast::Logger
- attr_accessor :secure_boot
def initialize
super
@@ -25,8 +24,6 @@
# Read settings from disk overwritting already set values
def read
- @secure_boot = Sysconfig.from_system.secure_boot
-
super
end
@@ -50,7 +47,7 @@
pmbr_setup(*disks.map(&:name))
end
- @grub_install.execute(secure_boot: @secure_boot, trusted_boot:
trusted_boot)
+ @grub_install.execute(secure_boot: secure_boot, trusted_boot:
trusted_boot)
true
end
@@ -61,34 +58,27 @@
# for UEFI always remove PMBR flag on disk (bnc#872054)
self.pmbr_action = :remove
- # Only x86_64 and aarch64 systems support secure boot
- @secure_boot = (Yast::Arch.x86_64 || Yast::Arch.aarch64) ? true : false
grub_default.generic_set("GRUB_USE_LINUXEFI", Yast::Arch.aarch64 ?
"false" : "true")
end
def merge(other)
super
-
- @secure_boot = other.secure_boot unless other.secure_boot.nil?
end
# Display bootloader summary
# @return a list of summary lines
def summary(*)
- [
+ result = [
Yast::Builtins.sformat(
_("Boot Loader Type: %1"),
"GRUB2 EFI"
- ),
- Yast::Builtins.sformat(
- _("Enable Secure Boot: %1"),
- @secure_boot ? _("yes") : _("no")
- ),
- Yast::Builtins.sformat(
- _("Enable Trusted Boot: %1"),
- trusted_boot ? _("yes") : _("no")
)
]
+
+ result << secure_boot_summary if Systeminfo.secure_boot_available?(name)
+ result << trusted_boot_summary if
Systeminfo.trusted_boot_available?(name)
+
+ result
end
def name
@@ -103,7 +93,7 @@
res << "grub2-i386-efi"
when "x86_64"
res << "grub2-x86_64-efi"
- res << "shim" << "mokutil" if @secure_boot
+ res << "shim" << "mokutil" if secure_boot
when "arm"
res << "grub2-arm-efi"
when "aarch64"
@@ -118,7 +108,7 @@
# overwrite BootloaderBase version to save secure boot
def write_sysconfig(prewrite: false)
sysconfig = Bootloader::Sysconfig.new(bootloader: name,
- secure_boot: @secure_boot, trusted_boot: trusted_boot)
+ secure_boot: secure_boot, trusted_boot: trusted_boot)
prewrite ? sysconfig.pre_write : sysconfig.write
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/yast2-bootloader-4.2.15/src/lib/bootloader/grub_install.rb
new/yast2-bootloader-4.2.17/src/lib/bootloader/grub_install.rb
--- old/yast2-bootloader-4.2.15/src/lib/bootloader/grub_install.rb
2020-01-03 14:22:31.000000000 +0100
+++ new/yast2-bootloader-4.2.17/src/lib/bootloader/grub_install.rb
2020-02-28 15:32:22.000000000 +0100
@@ -2,6 +2,7 @@
require "yast"
require "yast2/execute"
+require "bootloader/systeminfo"
Yast.import "Arch"
Yast.import "Report"
@@ -14,6 +15,7 @@
def initialize(efi: false)
@efi = efi
+ @grub2_name = "grub2" + (@efi ? "-efi" : "")
textdomain "bootloader"
end
@@ -25,7 +27,13 @@
# @param trusted_boot [Boolean] if trusted boot variant should be used
# @return [Array<String>] list of devices for which install failed
def execute(devices: [], secure_boot: false, trusted_boot: false)
- raise "cannot have secure boot without efi" if secure_boot && !efi
+ if secure_boot && !Systeminfo.secure_boot_available?(@grub2_name)
+ # There might be some secure boot setting left over when the
+ # bootloader had been switched.
+ # Simply ignore it when it is not applicable instead of raising an
+ # error.
+ log.warn "Ignoring secure boot setting on this machine"
+ end
cmd = basic_cmd(secure_boot, trusted_boot)
@@ -71,7 +79,7 @@
# creates basic command for grub2 install without specifying any stage1
# locations
def basic_cmd(secure_boot, trusted_boot)
- if secure_boot && !Yast::Arch.aarch64
+ if Systeminfo.shim_needed?(@grub2_name, secure_boot)
cmd = ["/usr/sbin/shim-install", "--config-file=/boot/grub2/grub.cfg"]
else
cmd = ["/usr/sbin/grub2-install", "--target=#{target}"]
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/yast2-bootloader-4.2.15/src/lib/bootloader/proposal_client.rb
new/yast2-bootloader-4.2.17/src/lib/bootloader/proposal_client.rb
--- old/yast2-bootloader-4.2.15/src/lib/bootloader/proposal_client.rb
2020-01-03 14:22:31.000000000 +0100
+++ new/yast2-bootloader-4.2.17/src/lib/bootloader/proposal_client.rb
2020-02-28 15:32:22.000000000 +0100
@@ -4,12 +4,14 @@
require "bootloader/exceptions"
require "bootloader/main_dialog"
require "bootloader/bootloader_factory"
+require "bootloader/systeminfo"
require "yast2/popup"
Yast.import "BootArch"
module Bootloader
# Proposal client for bootloader configuration
+ # rubocop:disable Metrics/ClassLength
class ProposalClient < ::Installation::ProposalClient
# Error when during update media is booted by different technology than
target system.
class MismatchBootloader < RuntimeError
@@ -72,7 +74,11 @@
"enable_boot_mbr",
"disable_boot_mbr",
"enable_boot_boot",
- "disable_boot_boot"
+ "disable_boot_boot",
+ "enable_secure_boot",
+ "disable_secure_boot",
+ "enable_trusted_boot",
+ "disable_trusted_boot"
].freeze
def make_proposal(attrs)
@@ -94,7 +100,7 @@
case chosen_id
when *PROPOSAL_LINKS
value = (chosen_id =~ /enable/) ? true : false
- option = chosen_id[/(enable|disable)_boot_(.*)/, 2]
+ option = chosen_id[/(enable|disable)_(.*)/, 2]
single_click_action(option, value)
else
settings = export_settings
@@ -336,12 +342,31 @@
end
def single_click_action(option, value)
- stage1 = ::Bootloader::BootloaderFactory.current.stage1
- devices = (option.to_sym == :mbr) ? stage1.boot_disk_names :
stage1.boot_partition_names
- log.info "single_click_action #{option} #{value.inspect} #{devices}"
+ bootloader = ::Bootloader::BootloaderFactory.current
- devices.each do |device|
- value ? stage1.add_udev_device(device) : stage1.remove_device(device)
+ log.info "single_click_action: option #{option}, value #{value.inspect}"
+
+ case option
+ when "boot_mbr", "boot_boot"
+ stage1 = bootloader.stage1
+ devices = (option == "boot_mbr") ? stage1.boot_disk_names :
stage1.boot_partition_names
+ log.info "single_click_action: devices #{devices}"
+ devices.each do |device|
+ value ? stage1.add_udev_device(device) : stage1.remove_device(device)
+ end
+ when "trusted_boot"
+ bootloader.trusted_boot = value
+ when "secure_boot"
+ bootloader.secure_boot = value
+ if value && Yast::Arch.s390
+ Yast2::Popup.show(
+ _(
+ "Make sure to also enable Secure Boot in the HMC.\n\n" \
+ "Otherwise this system will not boot."
+ ),
+ headline: :warning, buttons: :ok
+ )
+ end
end
Yast::Bootloader.proposed_cfg_changed = true
@@ -355,4 +380,5 @@
Yast::PackagesProposal.AddResolvables("yast2-bootloader", :package,
bl.packages)
end
end
+ # rubocop:enable Metrics/ClassLength
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/yast2-bootloader-4.2.15/src/lib/bootloader/sysconfig.rb
new/yast2-bootloader-4.2.17/src/lib/bootloader/sysconfig.rb
--- old/yast2-bootloader-4.2.15/src/lib/bootloader/sysconfig.rb 2020-01-03
14:22:31.000000000 +0100
+++ new/yast2-bootloader-4.2.17/src/lib/bootloader/sysconfig.rb 2020-02-28
15:32:22.000000000 +0100
@@ -1,6 +1,7 @@
# frozen_string_literal: true
require "yast"
+require "bootloader/systeminfo"
Yast.import "Arch"
@@ -33,11 +34,7 @@
bootloader = Yast::SCR.Read(AGENT_PATH + "LOADER_TYPE")
# propose secure boot always to true (bnc#872054), otherwise respect
user choice
# but only on architectures that support it
- secure_boot = if Yast::Arch.x86_64 || Yast::Arch.i386 ||
Yast::Arch.aarch64
- Yast::SCR.Read(AGENT_PATH + "SECURE_BOOT") != "no"
- else
- false
- end
+ secure_boot = Yast::SCR.Read(AGENT_PATH + "SECURE_BOOT") != "no"
trusted_boot = Yast::SCR.Read(AGENT_PATH + "TRUSTED_BOOT") == "yes"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/yast2-bootloader-4.2.15/src/lib/bootloader/systeminfo.rb
new/yast2-bootloader-4.2.17/src/lib/bootloader/systeminfo.rb
--- old/yast2-bootloader-4.2.15/src/lib/bootloader/systeminfo.rb
1970-01-01 01:00:00.000000000 +0100
+++ new/yast2-bootloader-4.2.17/src/lib/bootloader/systeminfo.rb
2020-02-28 15:32:22.000000000 +0100
@@ -0,0 +1,109 @@
+# frozen_string_literal: true
+
+require "yast"
+require "bootloader/bootloader_factory"
+require "bootloader/sysconfig"
+
+Yast.import "Arch"
+
+module Bootloader
+ # Provide system and architecture dependent information
+ class Systeminfo
+ class << self
+ # Check current secure boot state.
+ #
+ # This prefers the 'real' state over the config file setting, if
possible.
+ #
+ # @return [Boolean] true if secure boot is currently active
+ def secure_boot_active?
+ (efi_supported? && Sysconfig.from_system.secure_boot) ||
s390_secure_boot_active?
+ end
+
+ # Check if secure boot is in principle supported.
+ #
+ # @return [Boolean] true if secure boot is (in principle) supported on
this system
+ # def secure_boot_supported?
+ # efi_supported? || s390_secure_boot_supported?
+ # end
+
+ # Check if secure boot is configurable with a bootloader.
+ #
+ # @param bootloader_name [String] bootloader name
+ # @return [Boolean] true if secure boot setting is available with this
bootloader
+ def secure_boot_available?(bootloader_name)
+ efi_used?(bootloader_name) || s390_secure_boot_supported?
+ end
+
+ # Check current trusted boot state.
+ #
+ # ATM this just returns the config file setting.
+ #
+ # @return [Boolean] true if trusted boot is currently active
+ def trusted_boot_active?
+ # FIXME: this should probably be a real check as in
Grub2Widget#validate
+ # and then Grub2Widget#validate could use
Systeminfo.trusted_boot_active?
+ Sysconfig.from_system.trusted_boot
+ end
+
+ # Check if trusted boot is configurable with a bootloader.
+ #
+ # param bootloader_name [String] bootloader name
+ # @return [Boolean] true if trusted boot setting is available with this
bootloader
+ def trusted_boot_available?(bootloader_name)
+ # for details about grub2 efi trusted boot support see FATE#315831
+ (
+ bootloader_name == "grub2" &&
+ (Yast::Arch.x86_64 || Yast::Arch.i386)
+ ) || (
+ bootloader_name == "grub2-efi" &&
+ File.exist?("/dev/tpm0")
+ )
+ end
+
+ # Check if UEFI will be used.
+ #
+ # param bootloader_name [String] bootloader name
+ # @return [Boolean] true if UEFI will be used for booting with this
bootloader
+ def efi_used?(bootloader_name)
+ bootloader_name == "grub2-efi"
+ end
+
+ # Check if UEFI is available on this system.
+ #
+ # It need not currently be used. It should just be possible to put the
+ # system into UEFI mode.
+ #
+ # @return [Boolean] true if system can (in principle) boot via UEFI
+ def efi_supported?
+ Yast::Arch.x86_64 || Yast::Arch.i386 || Yast::Arch.aarch64
+ end
+
+ # Check if shim-install should be used instead of grub2-install.
+ #
+ # param bootloader_name [String] bootloader name
+ # param secure_boot [Boolean] secure boot setting
+ # @return [Boolean] true if shim has to be used
+ def shim_needed?(bootloader_name, secure_boot)
+ (Yast::Arch.x86_64 || Yast::Arch.i386) && secure_boot &&
efi_used?(bootloader_name)
+ end
+
+ # Check if secure boot is supported on an s390 machine.
+ #
+ # @return [Boolean] true if this is an s390 machine and it has secure
boot support
+ def s390_secure_boot_supported?
+ # FIXME: this is just a stub - replace with real code later
+ Yast::Arch.s390
+ end
+
+ # Check if secure boot is currently active on an s390 machine.
+ #
+ # The 'real' state, not any config file setting.
+ #
+ # @return [Boolean] true if 390x machine has secure boot enabled
+ def s390_secure_boot_active?
+ # FIXME: this is just a stub - replace with real code later
+ false
+ end
+ end
+ end
+end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/yast2-bootloader-4.2.15/src/lib/bootloader/udev_mapping.rb
new/yast2-bootloader-4.2.17/src/lib/bootloader/udev_mapping.rb
--- old/yast2-bootloader-4.2.15/src/lib/bootloader/udev_mapping.rb
2020-01-03 14:22:31.000000000 +0100
+++ new/yast2-bootloader-4.2.17/src/lib/bootloader/udev_mapping.rb
2020-02-28 15:32:22.000000000 +0100
@@ -38,26 +38,10 @@
# Converts udev or kernel device (disk or partition) to udev name that
fits best.
#
- # Here is description of strategy for finding the best possible udev
persistent name.
- # There are three scenarios we consider:
- # S1. disk with boot configuration is moved to different PC
- # S2. disk dies and its content is loaded to new disk from backup
- # S3. path to disk dies and disk is moved to different one
- #
- # Strategy is:
- #
- # 1. if device have filesystem and it have its mount_by, then respect it
- # 2. if there is by-label use it, as it allows to handle S1, S2 and S3
just with using same
- # label
- # 3. if there is by-uuid then use it as it can also handle S1, S2 and S3
as uuid can be
- # changed, but it is harder to do
- # 4. if there is by-id use it, as it can handle S3 in some scenarios, but
not always.
- # 5. if there is by-path use it as it is last supported udev symlink that
at least prevent
- # change of kernel device during boot
- # 6. as fallback use kernel name
+ # The strategy to discover the best mount by option when the device is not
mounted is delegated
+ # to storage-ng, see Y2Storage::Mountable#preferred_mount_by.
#
# @param dev [String] device udev or kernel one like /dev/disk/by-id/blabla
- # @raise when device have udev format but do not exists
# @return [String] udev name
def to_mountby_device(dev)
kernel_dev = to_kernel_device(dev)
@@ -92,6 +76,14 @@
device.name
end
+ # Udev name for the device
+ #
+ # The selected udev name depends on the mount by option. In case of an
unmounted device,
+ # storage-ng has logic to discover the preferred mount by option.
+ #
+ # @see #to_mountby_device
+ #
+ # @return [String]
def kernel_to_udev(dev)
device = Y2Storage::BlkDevice.find_by_name(staging, dev)
if device.nil?
@@ -99,54 +91,22 @@
return dev
end
- result = udev_name_for(device)
- log.info "udev device for #{dev.inspect} is #{result.inspect}"
-
- result
- end
+ udev = mount_by_udev(device) || device.name
+ log.info "udev device for #{dev.inspect} is #{udev.inspect}"
- # picks udev name according to strategy
- # @see #to_mountby_device
- def udev_name_for(device)
- mount_by_udev(device) ||
- udev_by_label(device) ||
- udev_by_uuid(device) ||
- udev_by_id(device) ||
- udev_by_path(device) ||
- device.name
+ udev
end
+ # @return [String, nil] nil if the udev name cannot be found
def mount_by_udev(device)
filesystem = device.filesystem
return nil unless filesystem
- # mount_by is nil, so not mounted and we need to use our own strategy
- return nil if filesystem.mount_by.nil?
- case filesystem.mount_by.to_sym
- when :device then device.name
- when :uuid then udev_by_uuid(device)
- when :label then udev_by_label(device)
- when :id then udev_by_id(device)
- when :path then udev_by_path(device)
- else
- raise "Unknown mount by option #{filesystem.mount_by.inspect} for
#{filesystem.inspect}"
- end
- end
-
- def udev_by_uuid(device)
- device.udev_full_uuid
- end
-
- def udev_by_label(device)
- device.udev_full_label
- end
-
- def udev_by_id(device)
- device.udev_full_ids.first
- end
+ # If the device is not mounted, a preferred mount by option is
calculated.
+ mount_by = filesystem.mount_by || filesystem.preferred_mount_by
+ return nil unless mount_by
- def udev_by_path(device)
- device.udev_full_paths.first
+ device.path_for_mount_by(mount_by)
end
end
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yast2-bootloader-4.2.15/test/grub2_efi_test.rb
new/yast2-bootloader-4.2.17/test/grub2_efi_test.rb
--- old/yast2-bootloader-4.2.15/test/grub2_efi_test.rb 2020-01-03
14:22:31.000000000 +0100
+++ new/yast2-bootloader-4.2.17/test/grub2_efi_test.rb 2020-02-28
15:32:22.000000000 +0100
@@ -17,6 +17,7 @@
allow(Bootloader::Sections).to
receive(:new).and_return(double("Sections").as_null_object)
allow(Yast::BootStorage).to
receive(:available_swap_partitions).and_return([])
allow(Bootloader::GrubInstall).to
receive(:new).and_return(double.as_null_object)
+ allow(Yast::Arch).to receive(:architecture).and_return("x86_64")
end
describe "#read" do
@@ -142,7 +143,7 @@
it "returns line with secure boot option specified" do
subject.secure_boot = false
- expect(subject.summary).to include("Enable Secure Boot: no")
+ expect(subject.summary).to include(match(/Secure Boot: disabled/))
end
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yast2-bootloader-4.2.15/test/grub2_test.rb
new/yast2-bootloader-4.2.17/test/grub2_test.rb
--- old/yast2-bootloader-4.2.15/test/grub2_test.rb 2020-01-03
14:22:31.000000000 +0100
+++ new/yast2-bootloader-4.2.17/test/grub2_test.rb 2020-02-28
15:32:22.000000000 +0100
@@ -81,7 +81,7 @@
grub2_install = double(Bootloader::GrubInstall)
expect(grub2_install).to receive(:execute)
- .with(devices: ["/dev/sda", "/dev/sdb1"], trusted_boot:
false).and_return([])
+ .with(devices: ["/dev/sda", "/dev/sdb1"], secure_boot: nil,
trusted_boot: false).and_return([])
expect(Bootloader::GrubInstall).to receive(:new).with(efi:
false).and_return(grub2_install)
subject.trusted_boot = false
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yast2-bootloader-4.2.15/test/grub_install_test.rb
new/yast2-bootloader-4.2.17/test/grub_install_test.rb
--- old/yast2-bootloader-4.2.15/test/grub_install_test.rb 2020-01-03
14:22:31.000000000 +0100
+++ new/yast2-bootloader-4.2.17/test/grub_install_test.rb 2020-02-28
15:32:22.000000000 +0100
@@ -131,8 +131,9 @@
subject { Bootloader::GrubInstall.new(efi: false) }
- it "raise exception if secure_boot: true passed" do
- expect { subject.execute(secure_boot: true) }.to
raise_error(RuntimeError)
+ it "do not raise exception if secure_boot: true passed" do
+ stub_arch("x86_64")
+ expect { subject.execute(secure_boot: true) }.to_not
raise_error(RuntimeError)
end
it "runs for each device passed in devices" do
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yast2-bootloader-4.2.15/test/systeminfo_test.rb
new/yast2-bootloader-4.2.17/test/systeminfo_test.rb
--- old/yast2-bootloader-4.2.15/test/systeminfo_test.rb 1970-01-01
01:00:00.000000000 +0100
+++ new/yast2-bootloader-4.2.17/test/systeminfo_test.rb 2020-02-28
15:32:22.000000000 +0100
@@ -0,0 +1,313 @@
+# frozen_string_literal: true
+
+require_relative "test_helper"
+
+require "bootloader/systeminfo"
+
+describe Bootloader::Systeminfo do
+ let(:arch) { nil }
+
+ before do
+ allow(Yast::Arch).to receive(:architecture).and_return(arch)
+ allow(Yast::SCR).to receive(:Write)
+ allow(Yast::SCR).to receive(:Read)
+ end
+
+ describe ".secure_boot_active?" do
+ context "if arch is x86_64" do
+ let(:arch) { "x86_64" }
+
+ context "if SECURE_BOOT is 'yes' in sysconfig" do
+ it "returns true" do
+ allow(Yast::SCR).to receive(:Read).with(
+ Yast::Path.new(".sysconfig.bootloader.SECURE_BOOT")
+ ).and_return("yes")
+ expect(described_class.secure_boot_active?).to be true
+ end
+ end
+
+ context "if SECURE_BOOT is 'no' in sysconfig" do
+ it "returns false" do
+ allow(Yast::SCR).to receive(:Read).with(
+ Yast::Path.new(".sysconfig.bootloader.SECURE_BOOT")
+ ).and_return("no")
+ expect(described_class.secure_boot_active?).to be false
+ end
+ end
+ end
+
+ context "if arch is s390x" do
+ let(:arch) { "s390_64" }
+
+ context "if SECURE_BOOT is 'yes' in sysconfig" do
+ it "returns true" do
+ allow(Yast::SCR).to receive(:Read).with(
+ Yast::Path.new(".sysconfig.bootloader.SECURE_BOOT")
+ ).and_return("yes")
+ expect(described_class.secure_boot_active?).to be false
+ end
+ end
+
+ context "if SECURE_BOOT is 'no' in sysconfig" do
+ it "returns false" do
+ allow(Yast::SCR).to receive(:Read).with(
+ Yast::Path.new(".sysconfig.bootloader.SECURE_BOOT")
+ ).and_return("no")
+ expect(described_class.secure_boot_active?).to be false
+ end
+ end
+ end
+ end
+
+ describe ".secure_boot_available?" do
+ context "if bootloader is grub2" do
+ context "and arch is x86_64" do
+ let(:arch) { "x86_64" }
+ it "returns false" do
+ expect(described_class.secure_boot_available?("grub2")).to be false
+ end
+ end
+
+ context "and arch is s390x" do
+ let(:arch) { "s390_64" }
+ it "returns true" do
+ expect(described_class.secure_boot_available?("grub2")).to be true
+ end
+ end
+ end
+
+ context "if bootloader is grub2-efi" do
+ context "and arch is x86_64" do
+ let(:arch) { "x86_64" }
+
+ it "returns true" do
+ expect(described_class.secure_boot_available?("grub2-efi")).to be
true
+ end
+ end
+
+ context "and arch is aarch64" do
+ let(:arch) { "aarch64" }
+
+ it "returns true" do
+ expect(described_class.secure_boot_available?("grub2-efi")).to be
true
+ end
+ end
+ end
+ end
+
+ describe ".trusted_boot_active?" do
+ context "if TRUSTED_BOOT is 'yes' in sysconfig" do
+ it "returns true" do
+ allow(Yast::SCR).to receive(:Read).with(
+ Yast::Path.new(".sysconfig.bootloader.TRUSTED_BOOT")
+ ).and_return("yes")
+ expect(described_class.trusted_boot_active?).to be true
+ end
+ end
+
+ context "if TRUSTED_BOOT is 'no' in sysconfig" do
+ it "returns true" do
+ allow(Yast::SCR).to receive(:Read).with(
+ Yast::Path.new(".sysconfig.bootloader.TRUSTED_BOOT")
+ ).and_return("no")
+ expect(described_class.trusted_boot_active?).to be false
+ end
+ end
+ end
+
+ describe ".trusted_boot_available?" do
+ context "if bootloader is grub2" do
+ context "and arch is x86_64" do
+ let(:arch) { "x86_64" }
+
+ it "returns true" do
+ expect(described_class.trusted_boot_available?("grub2")).to be true
+ end
+ end
+
+ context "and arch is i386" do
+ let(:arch) { "i386" }
+
+ it "returns true" do
+ expect(described_class.trusted_boot_available?("grub2")).to be true
+ end
+ end
+
+ context "and arch is ppc64" do
+ let(:arch) { "ppc64" }
+
+ it "returns false" do
+ expect(described_class.trusted_boot_available?("grub2")).to be false
+ end
+ end
+
+ context "and arch is s390x" do
+ let(:arch) { "s390_64" }
+
+ it "returns false" do
+ expect(described_class.trusted_boot_available?("grub2")).to be false
+ end
+ end
+ end
+
+ context "if bootloader is grub2-efi" do
+ context "and a tpm device exists" do
+ it "returns true" do
+ allow(File).to receive(:exist?).with("/dev/tpm0").and_return(true)
+ expect(described_class.trusted_boot_available?("grub2-efi")).to be
true
+ end
+ end
+
+ context "and a tpm device does not exist" do
+ it "returns false" do
+ allow(File).to receive(:exist?).with("/dev/tpm0").and_return(false)
+ expect(described_class.trusted_boot_available?("grub2-efi")).to be
false
+ end
+ end
+ end
+ end
+
+ describe ".efi_used?" do
+ context "if bootloader is grub2-efi" do
+ it "returns true" do
+ expect(described_class.efi_used?("grub2-efi")).to be true
+ end
+ end
+
+ context "if bootloader is grub2" do
+ it "returns false" do
+ expect(described_class.efi_used?("grub2")).to be false
+ end
+ end
+ end
+
+ describe ".efi_supported?" do
+ context "if arch is x86_64" do
+ let(:arch) { "x86_64" }
+
+ it "returns true" do
+ expect(described_class.efi_supported?).to be true
+ end
+ end
+
+ context "if arch is i386" do
+ let(:arch) { "i386" }
+
+ it "returns true" do
+ expect(described_class.efi_supported?).to be true
+ end
+ end
+
+ context "if arch is aarch64" do
+ let(:arch) { "aarch64" }
+
+ it "returns true" do
+ expect(described_class.efi_supported?).to be true
+ end
+ end
+
+ context "if arch is ppc64" do
+ let(:arch) { "ppc64" }
+
+ it "returns false" do
+ expect(described_class.efi_supported?).to be false
+ end
+ end
+
+ context "if arch is s390x" do
+ let(:arch) { "s390_64" }
+
+ it "returns false" do
+ expect(described_class.efi_supported?).to be false
+ end
+ end
+ end
+
+ describe ".shim_needed?" do
+ context "if UEFI is used and arch is x86_64" do
+ let(:arch) { "x86_64" }
+
+ context "and secure boot is enabled" do
+ it "returns true" do
+ expect(described_class.shim_needed?("grub2-efi", true)).to be true
+ end
+ end
+
+ context "and secure boot is disabled" do
+ it "returns false" do
+ expect(described_class.shim_needed?("grub2-efi", false)).to be false
+ end
+ end
+ end
+
+ context "if UEFI is used and arch is aarch64" do
+ let(:arch) { "aarch64" }
+
+ context "and secure boot is enabled" do
+ it "returns false" do
+ expect(described_class.shim_needed?("grub2-efi", true)).to be false
+ end
+ end
+
+ context "and secure boot is disabled" do
+ it "returns false" do
+ expect(described_class.shim_needed?("grub2-efi", false)).to be false
+ end
+ end
+ end
+
+ context "if UEFI is not used and arch is x86_64" do
+ let(:arch) { "x86_64" }
+
+ context "and secure boot is disabled" do
+ it "returns true" do
+ expect(described_class.shim_needed?("grub2", false)).to be false
+ end
+ end
+ end
+
+ context "if UEFI is not used and arch is s390x" do
+ let(:arch) { "s390_64" }
+
+ context "and secure boot is enabled" do
+ it "returns false" do
+ expect(described_class.shim_needed?("grub2", true)).to be false
+ end
+ end
+
+ context "and secure boot is disabled" do
+ it "returns false" do
+ expect(described_class.shim_needed?("grub2", false)).to be false
+ end
+ end
+ end
+ end
+
+ describe ".s390_secure_boot_supported?" do
+ context "if arch is s390x" do
+ let(:arch) { "s390_64" }
+
+ it "returns true" do
+ expect(described_class.s390_secure_boot_supported?).to be true
+ end
+ end
+
+ context "if arch is x86_64" do
+ let(:arch) { "x86_64" }
+
+ it "returns false" do
+ expect(described_class.s390_secure_boot_supported?).to be false
+ end
+ end
+ end
+
+ describe ".s390_secure_boot_active?" do
+ context "if arch is s390x" do
+ let(:arch) { "s390_64" }
+
+ it "returns false" do
+ expect(described_class.s390_secure_boot_active?).to be false
+ end
+ end
+ end
+end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yast2-bootloader-4.2.15/test/udev_mapping_test.rb
new/yast2-bootloader-4.2.17/test/udev_mapping_test.rb
--- old/yast2-bootloader-4.2.15/test/udev_mapping_test.rb 2020-01-03
14:22:31.000000000 +0100
+++ new/yast2-bootloader-4.2.17/test/udev_mapping_test.rb 2020-02-28
15:32:22.000000000 +0100
@@ -42,56 +42,66 @@
end
describe ".to_mountby_device" do
- let(:device) { find_device("/dev/sda3") }
-
before do
# find by name creates always new instance, so to make mocking easier,
mock it to return always same instance
allow(Y2Storage::BlkDevice).to receive(:find_by_name).and_return(device)
+
+ allow(device).to
receive(:path_for_mount_by).with(mount_by).and_return(udev_name)
end
- it "returns udev link in same format as used to its mounting" do
- device.filesystem.mount_point.mount_by =
Y2Storage::Filesystems::MountByType.new(:uuid)
+ let(:device) { find_device("/dev/sda3") }
- expect(subject.to_mountby_device(device.name)).to eq
"/dev/disk/by-uuid/3de29985-8cc6-4c9d-8562-2ede26b0c5b6"
- end
+ let(:mount_by) { Y2Storage::Filesystems::MountByType.new(mount_by_option) }
- it "returns udev link by label if defined" do
- device.filesystem.remove_mount_point
+ context "when the device is mounted" do
+ before do
+ device.filesystem.mount_point.mount_by = mount_by
+ end
- expect(subject.to_mountby_device(device.name)).to eq
"/dev/disk/by-label/DATA"
- end
+ let(:mount_by_option) { :label }
- it "returns udev link by uuid if defined" do
- device.filesystem.remove_mount_point
- allow(device).to receive(:udev_full_label).and_return(nil)
+ context "and the udev name is available for the mount by option in the
mount point" do
+ let(:udev_name) { "/dev/disk/by-label/test" }
- expect(subject.to_mountby_device(device.name)).to eq
"/dev/disk/by-uuid/3de29985-8cc6-4c9d-8562-2ede26b0c5b6"
- end
+ it "returns the udev name according to the mount by option in the
mount point" do
+ expect(subject.to_mountby_device(device.name)).to eq(udev_name)
+ end
+ end
- it "returns first udev link by id if defined" do
- device.filesystem.remove_mount_point
- allow(device).to receive(:udev_full_label).and_return(nil)
- allow(device).to receive(:udev_full_uuid).and_return(nil)
- allow(device).to receive(:udev_ids).and_return(["abc", "cde"])
+ context "and the udev name is not available for the mount by option in
the mount point" do
+ let(:udev_name) { nil }
- expect(subject.to_mountby_device(device.name)).to eq
"/dev/disk/by-id/abc"
+ it "returns the kernel name as fallback" do
+ expect(subject.to_mountby_device(device.name)).to eq("/dev/sda3")
+ end
+ end
end
- it "returns first udev link by path if defined" do
- device.filesystem.remove_mount_point
- allow(device).to receive(:udev_full_label).and_return(nil)
- allow(device).to receive(:udev_full_uuid).and_return(nil)
- allow(device).to receive(:udev_paths).and_return(["abc", "cde"])
+ context "when the device is not mounted" do
+ before do
+ device.filesystem&.remove_mount_point
- expect(subject.to_mountby_device(device.name)).to eq
"/dev/disk/by-path/abc"
- end
+ allow_any_instance_of(Y2Storage::MountPoint).to
receive(:preferred_mount_by)
+ .and_return(mount_by)
+ end
+
+ let(:mount_by_option) { :label }
+
+ context "and the udev name is available for the preferred mount by
option" do
+ let(:udev_name) { "/dev/disk/by-label/test" }
+
+ it "returns the udev name according to the preferred mount by option"
do
+ expect(subject.to_mountby_device(device.name)).to eq(udev_name)
+ end
+ end
- it "returns kernel name as last fallback" do
- device.filesystem.remove_mount_point
- allow(device).to receive(:udev_full_label).and_return(nil)
- allow(device).to receive(:udev_full_uuid).and_return(nil)
+ context "and the udev name is not available for the preferred mount by
option" do
+ let(:udev_name) { nil }
- expect(subject.to_mountby_device(device.name)).to eq device.name
+ it "returns the kernel name as fallback" do
+ expect(subject.to_mountby_device(device.name)).to eq("/dev/sda3")
+ end
+ end
end
end
end