Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package yast2-storage-ng for 
openSUSE:Factory checked in at 2021-01-18 11:27:40
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/yast2-storage-ng (Old)
 and      /work/SRC/openSUSE:Factory/.yast2-storage-ng.new.28504 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "yast2-storage-ng"

Mon Jan 18 11:27:40 2021 rev:98 rq:863140 version:4.3.37

Changes:
--------
--- /work/SRC/openSUSE:Factory/yast2-storage-ng/yast2-storage-ng.changes        
2020-12-23 14:21:36.957748019 +0100
+++ 
/work/SRC/openSUSE:Factory/.yast2-storage-ng.new.28504/yast2-storage-ng.changes 
    2021-01-18 11:30:50.068556671 +0100
@@ -1,0 +2,16 @@
+Thu Jan 14 13:40:54 UTC 2021 - Ancor Gonzalez Sosa <[email protected]>
+
+- Partitioner: removed warning for too small EFI system partition.
+- Proposal: reuse pre-existing EFI partition even if it's small
+- Related to bsc#1177358, bsc#1170625 and bsc#1119318.
+- 4.3.37
+
+-------------------------------------------------------------------
+Tue Jan 12 12:59:07 UTC 2021 - Ancor Gonzalez Sosa <[email protected]>
+
+- Added API methods to get the preferred name to reference a block
+  device or its filesystem (jsc#SLE-17081, also related to
+  bsc#1177926 and bsc#1169874).
+- 4.3.36
+
+-------------------------------------------------------------------

Old:
----
  yast2-storage-ng-4.3.35.tar.bz2

New:
----
  yast2-storage-ng-4.3.37.tar.bz2

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ yast2-storage-ng.spec ++++++
--- /var/tmp/diff_new_pack.gXfXKG/_old  2021-01-18 11:30:50.696564541 +0100
+++ /var/tmp/diff_new_pack.gXfXKG/_new  2021-01-18 11:30:50.700564591 +0100
@@ -1,7 +1,7 @@
 #
 # spec file for package yast2-storage-ng
 #
-# Copyright (c) 2020 SUSE LLC
+# Copyright (c) 2021 SUSE LLC
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -17,7 +17,7 @@
 
 
 Name:           yast2-storage-ng
-Version:        4.3.35
+Version:        4.3.37
 Release:        0
 Summary:        YaST2 - Storage Configuration
 License:        GPL-2.0-only OR GPL-3.0-only

++++++ yast2-storage-ng-4.3.35.tar.bz2 -> yast2-storage-ng-4.3.37.tar.bz2 ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yast2-storage-ng-4.3.35/doc/boot-partition.md 
new/yast2-storage-ng-4.3.37/doc/boot-partition.md
--- old/yast2-storage-ng-4.3.35/doc/boot-partition.md   2020-12-22 
14:37:02.000000000 +0100
+++ new/yast2-storage-ng-4.3.37/doc/boot-partition.md   2021-01-14 
16:49:25.000000000 +0100
@@ -28,7 +28,7 @@
 
 ### Grub2 and disk abstractions
 
-- Grub natively suppors lvm raid 0/1/4/5/6, encryption with or without lvm
+- Grub natively supports lvm raid 0/1/4/5/6, encryption with or without lvm
 - The problem with disk abstractions like lvm or raid is not exactly about
   booting. The system will boot fine but some features have an additional
   requirement - having a pre-boot environment block writable by grub-once.
@@ -65,7 +65,7 @@
  * generic boot loader installed into mbr
  * we have generic boot code for both dos/gpt partition table
  * stage1 installed into /boot or / partition (if possible, note: not on xfs)
- * **OR** separate grub boot partition for embdding stage1 (like prep on ppc)
+ * **OR** separate grub boot partition for embedding stage1 (like prep on ppc)
 
      > *[mchang]* gpt has bios_grub partition but only if you instruct 
grub2-install to
 install stage1 on mbr then it will search bios_grub to embed stage2
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-storage-ng-4.3.35/package/yast2-storage-ng.changes 
new/yast2-storage-ng-4.3.37/package/yast2-storage-ng.changes
--- old/yast2-storage-ng-4.3.35/package/yast2-storage-ng.changes        
2020-12-22 14:37:02.000000000 +0100
+++ new/yast2-storage-ng-4.3.37/package/yast2-storage-ng.changes        
2021-01-14 16:49:25.000000000 +0100
@@ -1,4 +1,20 @@
 -------------------------------------------------------------------
+Thu Jan 14 13:40:54 UTC 2021 - Ancor Gonzalez Sosa <[email protected]>
+
+- Partitioner: removed warning for too small EFI system partition.
+- Proposal: reuse pre-existing EFI partition even if it's small
+- Related to bsc#1177358, bsc#1170625 and bsc#1119318.
+- 4.3.37
+
+-------------------------------------------------------------------
+Tue Jan 12 12:59:07 UTC 2021 - Ancor Gonzalez Sosa <[email protected]>
+
+- Added API methods to get the preferred name to reference a block
+  device or its filesystem (jsc#SLE-17081, also related to
+  bsc#1177926 and bsc#1169874).
+- 4.3.36
+
+-------------------------------------------------------------------
 Tue Dec 22 13:09:47 UTC 2020 - Ancor Gonzalez Sosa <[email protected]>
 
 - Partitioner: do not allow to modify the path of Btrfs subvolumes
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-storage-ng-4.3.35/package/yast2-storage-ng.spec 
new/yast2-storage-ng-4.3.37/package/yast2-storage-ng.spec
--- old/yast2-storage-ng-4.3.35/package/yast2-storage-ng.spec   2020-12-22 
14:37:02.000000000 +0100
+++ new/yast2-storage-ng-4.3.37/package/yast2-storage-ng.spec   2021-01-14 
16:49:25.000000000 +0100
@@ -16,7 +16,7 @@
 #
 
 Name:           yast2-storage-ng
-Version:        4.3.35
+Version:        4.3.37
 Release:        0
 Summary:        YaST2 - Storage Configuration
 License:        GPL-2.0-only OR GPL-3.0-only
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-storage-ng-4.3.35/src/lib/y2storage/blk_device.rb 
new/yast2-storage-ng-4.3.37/src/lib/y2storage/blk_device.rb
--- old/yast2-storage-ng-4.3.35/src/lib/y2storage/blk_device.rb 2020-12-22 
14:37:02.000000000 +0100
+++ new/yast2-storage-ng-4.3.37/src/lib/y2storage/blk_device.rb 2021-01-14 
16:49:25.000000000 +0100
@@ -1,4 +1,4 @@
-# Copyright (c) [2017-2019] SUSE LLC
+# Copyright (c) [2017-2020] SUSE LLC
 #
 # All Rights Reserved.
 #
@@ -182,7 +182,7 @@
     # @see #udev_paths
     # @return [Array<String>]
     def udev_full_paths
-      udev_paths.map { |path| File.join("/dev", "disk", "by-path", path) }
+      udev_paths.map { |path| Filesystems::MountByType::PATH.udev_name(path) }
     end
 
     # @!method udev_ids
@@ -207,7 +207,7 @@
     # @see #udev_ids
     # @return [Array<String>]
     def udev_full_ids
-      udev_ids.map { |id| File.join("/dev", "disk", "by-id", id) }
+      udev_ids.map { |id| Filesystems::MountByType::ID.udev_name(id) }
     end
 
     # @!attribute dm_table_name
@@ -287,6 +287,15 @@
     #   @return [Encryption] nil if the device is not encrypted
     storage_forward :encryption, as: "Encryption", check_with: :has_encryption
 
+    # @!method possible_mount_bys
+    #   Possible mount-by methods to reference the block device itself, 
regardless of its content
+    #
+    #   @see #preferred_name
+    #
+    #   @return [Array<Filesystems::MountByType>]
+    storage_forward :possible_mount_bys, as: "Filesystems::MountByType"
+    private :possible_mount_bys
+
     # Checks whether the device is encrypted
     #
     # @return [boolean]
@@ -482,6 +491,24 @@
       component_of.map(&:display_name).compact
     end
 
+    # Device name (full path) to use for the given mount by option
+    #
+    # This returns a file name that references the block device itself, 
regardless of its content.
+    # I.e. this would return the same result if the device is formatted or if 
it's empty.
+    # See also {Filesystems::BlkFilesystem#path_for_mount_by}.
+    #
+    # @return [String, nil] nil if the name cannot be determined for the given 
mount by option
+    def path_for_mount_by(mount_by)
+      case mount_by
+      when Filesystems::MountByType::DEVICE
+        name
+      when Filesystems::MountByType::ID
+        udev_full_ids.first
+      when Filesystems::MountByType::PATH
+        udev_full_paths.first
+      end
+    end
+
     # Label of the filesystem, if any
     # @return [String, nil]
     def filesystem_label
@@ -490,16 +517,18 @@
       blk_filesystem.label
     end
 
-    # full path of the udev by-label link or `nil` if it does not exist.
+    # Full path of the udev by-label link or `nil` if it does not exist.
     # e.g. "/dev/disk/by-label/DATA"
+    #
+    # Note this is based on the label of the filesystem contained in the block 
device,
+    # so the result of this method actually depends on the content of the 
device.
+    # That's different from {#path_for_mount_by} and other methods aimed to 
get the udev
+    # names of the block device, but it's kept that way for backwards 
compatibility.
+    #
     # @see #udev_paths
     # @return [String, nil]
     def udev_full_label
-      label = filesystem_label
-
-      return nil if label.nil? || label.empty?
-
-      File.join("/dev", "disk", "by-label", label)
+      Filesystems::MountByType::LABEL.udev_name(filesystem_label)
     end
 
     # UUID of the filesystem, if any
@@ -510,16 +539,18 @@
       blk_filesystem.uuid
     end
 
-    # full path of the udev by-uuid link or `nil` if it does not exist.
+    # Full path of the udev by-uuid link or `nil` if it does not exist.
     # e.g. "/dev/disk/by-uuid/a1dc747af-6ef7-44b9-b4f8-d200a5f933ec"
+    #
+    # Note this is based on the UUID of the filesystem contained in the block 
device,
+    # so the result of this method actually depends on the content of the 
device.
+    # That's different from {#path_for_mount_by} and other methods aimed to 
get the udev
+    # names of the block device, but it's kept that way for backwards 
compatibility.
+    #
     # @see #udev_paths
     # @return [String, nil]
     def udev_full_uuid
-      uuid = filesystem_uuid
-
-      return nil if uuid.nil? || uuid.empty?
-
-      File.join("/dev", "disk", "by-uuid", uuid)
+      Filesystems::MountByType::UUID.udev_name(filesystem_uuid)
     end
 
     # Type of the filesystem, if any
@@ -655,6 +686,23 @@
       false
     end
 
+    # Most convenient file path to reference the block device itself,
+    # regardless of its content
+    #
+    # This method returns the same result if the device is formatted or if 
it's empty.
+    # To determine the name that must be used to reference a filesytem (e.g. 
in fstab),
+    # call {Filesystems::BlkFilesystem#preferred_name} on the filesystem 
object.
+    #
+    # This method always returns a valid full-path filename inferred from the
+    # information already available in the devicegraph. To choose from all the 
possible
+    # names, it relies on {Filesystems::MountByType.best_for}, which already 
takes
+    # {Configuration#default_mount_by} into account.
+    #
+    # @return [String]
+    def preferred_name
+      path_for_mount_by(preferred_mount_by)
+    end
+
     protected
 
     # Values for volume specification matching
@@ -669,6 +717,20 @@
       }
     end
 
+    # Most convenient mount_by option to reference the block device itself,
+    # regardless of its content
+    #
+    # @see #preferred_name
+    #
+    # This method always returns an option that can be safely used by
+    # {#path_for_mount_by} to construct a valid filename.
+    #
+    # @return [Filesystems::MountByType]
+    def preferred_mount_by
+      Filesystems::MountByType.best_for(self, possible_mount_bys)
+    end
+
+    # @see Device#is?
     def types_for_is
       super << :blk_device
     end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-storage-ng-4.3.35/src/lib/y2storage/boot_requirements_strategies/base.rb
 
new/yast2-storage-ng-4.3.37/src/lib/y2storage/boot_requirements_strategies/base.rb
--- 
old/yast2-storage-ng-4.3.35/src/lib/y2storage/boot_requirements_strategies/base.rb
  2020-12-22 14:37:02.000000000 +0100
+++ 
new/yast2-storage-ng-4.3.37/src/lib/y2storage/boot_requirements_strategies/base.rb
  2021-01-14 16:49:25.000000000 +0100
@@ -203,9 +203,10 @@
       # Whether there is no partition that matches the volume
       #
       # @param volume [VolumeSpecification]
+      # @param exclude [Array<Symbol>, Symbol] see 
{MatchVolumeSpec#match_volume?}
       # @return [Boolean] true if there is no partition; false otherwise.
-      def missing_partition_for?(volume)
-        Partition.all(devicegraph).none? { |p| p.match_volume?(volume) }
+      def missing_partition_for?(volume, exclude: [])
+        Partition.all(devicegraph).none? { |p| p.match_volume?(volume, 
exclude: exclude) }
       end
 
       # Specific error when the boot disk cannot be detected
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-storage-ng-4.3.35/src/lib/y2storage/boot_requirements_strategies/uefi.rb
 
new/yast2-storage-ng-4.3.37/src/lib/y2storage/boot_requirements_strategies/uefi.rb
--- 
old/yast2-storage-ng-4.3.35/src/lib/y2storage/boot_requirements_strategies/uefi.rb
  2020-12-22 14:37:02.000000000 +0100
+++ 
new/yast2-storage-ng-4.3.37/src/lib/y2storage/boot_requirements_strategies/uefi.rb
  2021-01-14 16:49:25.000000000 +0100
@@ -59,7 +59,7 @@
 
         # Missing EFI does not need to be a fatal (e.g. when boot from 
network).
         # User just has to not select grub2-efi bootloader.
-        res_new << esp_missing_warning if res_new.empty? && 
missing_partition_for?(efi_volume)
+        res_new << esp_missing_warning if res_new.empty? && 
!valid_esp_configured?
 
         res + res_new
       end
@@ -88,6 +88,9 @@
         SetupError.new(message: msg)
       end
 
+      # Error about missing EFI system partition
+      #
+      # @return [SetupError]
       def esp_missing_warning
         SetupError.new(missing_volume: efi_volume)
       end
@@ -96,6 +99,18 @@
         free_mountpoint?("/boot/efi")
       end
 
+      # Whether the devicegraph contains a partition mounted at /boot/efi and
+      # that looks like a valid EFI system partition
+      #
+      # @return [boolean]
+      def valid_esp_configured?
+        # The user may have configured an ESP that is smaller than the one the 
proposal
+        # would have suggested, so let's exclude the size from the check (a 
user who sets
+        # the correct partition id, filesystem and mount point deserves some 
trust).
+        # 
https://github.com/yast/yast-storage-ng/issues/1194#issuecomment-756165860
+        !missing_partition_for?(efi_volume, exclude: :size)
+      end
+
       # @return [VolumeSpecification]
       def efi_volume
         if @efi_volume.nil?
@@ -181,7 +196,29 @@
       # @param partition [Y2Storage::Partition]
       # @return [Boolean]
       def suitable_efi_partition?(partition)
-        partition.match_volume?(efi_volume, exclude: :mount_point) && 
partition.id == PartitionId::ESP
+        # Note that checking the partition id is needed because #efi_volume 
does not
+        # include that id as part of the mandatory specification
+        suitable_id?(partition) && suitable_filesystem?(partition)
+      end
+
+      # @see #suitable_efi_partition?
+      #
+      # @return [Boolean]
+      def suitable_id?(partition)
+        partition.id == PartitionId::ESP
+      end
+
+      # @see #suitable_efi_partition?
+      #
+      # @return [Boolean]
+      def suitable_filesystem?(partition)
+        # The size is excluded from the check because it makes no sense to 
discard an ESP that
+        # already exists and looks sane just because it's smaller than what we 
would have proposed.
+        #
+        # We considered to add a check to verify whether there is enough free 
space in the partition
+        # to locate our booting information. But we concluded that would be 
overdoing, we may be
+        # replacing information instead of adding more (eg. during a 
reinstallation).
+        partition.match_volume?(efi_volume, exclude: [:mount_point, :size])
       end
 
       def biggest_partition(partitions)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-storage-ng-4.3.35/src/lib/y2storage/filesystems/blk_filesystem.rb 
new/yast2-storage-ng-4.3.37/src/lib/y2storage/filesystems/blk_filesystem.rb
--- old/yast2-storage-ng-4.3.35/src/lib/y2storage/filesystems/blk_filesystem.rb 
2020-12-22 14:37:02.000000000 +0100
+++ new/yast2-storage-ng-4.3.37/src/lib/y2storage/filesystems/blk_filesystem.rb 
2021-01-14 16:49:25.000000000 +0100
@@ -321,6 +321,45 @@
         self.uuid = uuidgen
       end
 
+      # Most convenient file path to reference the filesystem
+      #
+      # If possible, the path is chosen based on the {#mount_by} attribute of 
the filesystem.
+      # If the filesystem is not mounted or the path for the specified 
mount_by cannot be
+      # calculated from the information present in the devicegraph, an 
alternative name
+      # based on {Filesystems::MountByType.best_for} (which already takes
+      # {Configuration#default_mount_by} into account) is calculated.
+      #
+      # This method always return a valid full-path filename that can be 
inferred from the
+      # information already available in the devicegraph
+      #
+      # @return [String]
+      def preferred_name
+        path_for_mount_by(preferred_mount_by)
+      end
+
+      # File path to reference the filesystem based on the current mount by 
option
+      #
+      # @see #mount_by
+      #
+      # @return [String, nil] nil if the name cannot be determined for the 
current mount by option
+      def mount_by_name
+        return nil unless mount_by
+
+        path_for_mount_by(mount_by)
+      end
+
+      # Name (full path) that can be used to reference the filesystem for the 
given mount by option
+      #
+      # @return [String, nil] nil if the name cannot be determined for the 
given mount by option
+      def path_for_mount_by(mount_by)
+        if mount_by.is?(:label, :uuid)
+          attr_value = public_send(mount_by.to_sym)
+          mount_by.udev_name(attr_value)
+        else
+          blk_devices.first.path_for_mount_by(mount_by)
+        end
+      end
+
       protected
 
       # Whether the network-related mount options (e.g. _netdev) should be part
@@ -346,6 +385,21 @@
       rescue Cheetah::ExecutionFailed
         ""
       end
+
+      # Most convenient mount_by option to reference the filesystem
+      #
+      # @see #preferred_name
+      #
+      # This method always returns an option that can be safely used by
+      # {#path_for_mount_by} to construct a valid filename.
+      #
+      # @return [Filesystems::MountByType]
+      def preferred_mount_by
+        mount_bys = with_mount_point { |mp| mp.suitable_mount_bys(assume_uuid: 
false) }
+        return mount_by if mount_bys.include?(mount_by)
+
+        Filesystems::MountByType.best_for(self, mount_bys)
+      end
     end
   end
 end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-storage-ng-4.3.35/src/lib/y2storage/filesystems/mount_by_type.rb 
new/yast2-storage-ng-4.3.37/src/lib/y2storage/filesystems/mount_by_type.rb
--- old/yast2-storage-ng-4.3.35/src/lib/y2storage/filesystems/mount_by_type.rb  
2020-12-22 14:37:02.000000000 +0100
+++ new/yast2-storage-ng-4.3.37/src/lib/y2storage/filesystems/mount_by_type.rb  
2021-01-14 16:49:25.000000000 +0100
@@ -77,6 +77,18 @@
         name.nil? ? to_s : _(name)
       end
 
+      # Full path of the udev by-* link for this type, given a value of the
+      # referenced attribute
+      #
+      # @param value [String, nil] label, uuid, path or id of the device to 
point to
+      # @return [String, nil] nil if it's not possible to build the path of an 
udev
+      #   link that points to the device
+      def udev_name(value)
+        return nil if value.nil? || value.empty? || is?(:device)
+
+        File.join("/dev", "disk", "by-#{to_sym}", value)
+      end
+
       class << self
         # Type corresponding to the given fstab spec
         #
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yast2-storage-ng-4.3.35/src/lib/y2storage/luks.rb 
new/yast2-storage-ng-4.3.37/src/lib/y2storage/luks.rb
--- old/yast2-storage-ng-4.3.35/src/lib/y2storage/luks.rb       2020-12-22 
14:37:02.000000000 +0100
+++ new/yast2-storage-ng-4.3.37/src/lib/y2storage/luks.rb       2021-01-14 
16:49:25.000000000 +0100
@@ -70,6 +70,17 @@
       super
     end
 
+    # @see BlkDevice#path_for_mount_by
+    def path_for_mount_by(mount_by)
+      # Unlike most block devices, LUKS devices have an UUID and can have a 
label
+      if mount_by.is?(:label, :uuid)
+        attr_value = public_send(mount_by.to_sym)
+        mount_by.udev_name(attr_value)
+      else
+        super
+      end
+    end
+
     protected
 
     # @see Device#is?
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yast2-storage-ng-4.3.35/src/lib/y2storage/md.rb 
new/yast2-storage-ng-4.3.37/src/lib/y2storage/md.rb
--- old/yast2-storage-ng-4.3.35/src/lib/y2storage/md.rb 2020-12-22 
14:37:02.000000000 +0100
+++ new/yast2-storage-ng-4.3.37/src/lib/y2storage/md.rb 2021-01-14 
16:49:25.000000000 +0100
@@ -308,6 +308,16 @@
       in_etc_mdadm?
     end
 
+    # @see BlkDevice#path_for_mount_by
+    def path_for_mount_by(mount_by)
+      # Unlike most block devices, MD RAIDs have an UUID
+      if mount_by.is?(:uuid)
+        mount_by.udev_name(uuid)
+      else
+        super
+      end
+    end
+
     protected
 
     # Holders connecting the MD Raid to its component block devices in the
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-storage-ng-4.3.35/src/lib/y2storage/mount_point.rb 
new/yast2-storage-ng-4.3.37/src/lib/y2storage/mount_point.rb
--- old/yast2-storage-ng-4.3.35/src/lib/y2storage/mount_point.rb        
2020-12-22 14:37:02.000000000 +0100
+++ new/yast2-storage-ng-4.3.37/src/lib/y2storage/mount_point.rb        
2021-01-14 16:49:25.000000000 +0100
@@ -290,9 +290,16 @@
     # @param encryption [Boolean, nil] whether the filesystem sits on top of an
     #   encrypted device. Regarding the possible values (nil, true and false) 
it
     #   behaves like the label argument.
+    # @param assume_uuid [Boolean] whether it can be safely assumed that the
+    #   filesystem has a known UUID (as long as UUIDs are supported for that
+    #   filesystem type). True by default because most filesystems will get an
+    #   UUID assigned to them in the moment they are created in the real 
system,
+    #   even if that UUID is still not known by the devicegraph. If set to 
false,
+    #   mounting by UUID will only be considered suitable if the UUID is 
already
+    #   known in the devicegraph.
     #
     # @return [Array<Filesystems::MountByType>]
-    def suitable_mount_bys(label: nil, encryption: nil)
+    def suitable_mount_bys(label: nil, encryption: nil, assume_uuid: true)
       with_mount_point_for_suitable(encryption) do |mount_point|
         fs = mount_point.filesystem
 
@@ -308,7 +315,9 @@
         return candidates unless fs.is?(:blk_filesystem)
 
         label = (fs.label.size > 0) if label.nil?
-        candidates.delete(Filesystems::MountByType::LABEL) unless label
+        uuid = assume_uuid ? true : !fs.uuid.empty?
+
+        filter_mount_bys(candidates, label, uuid)
         candidates
       end
     end
@@ -435,5 +444,15 @@
 
       mount_point
     end
+
+    # @see #suitable_mount_bys
+    #
+    # @param candidates [Array<Filesystems::MountByType>]
+    # @param label [Boolean]
+    # @param uuid [Boolean]
+    def filter_mount_bys(candidates, label, uuid)
+      candidates.delete(Filesystems::MountByType::LABEL) unless label
+      candidates.delete(Filesystems::MountByType::UUID) unless uuid
+    end
   end
 end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-storage-ng-4.3.35/src/lib/y2storage/mountable.rb 
new/yast2-storage-ng-4.3.37/src/lib/y2storage/mountable.rb
--- old/yast2-storage-ng-4.3.35/src/lib/y2storage/mountable.rb  2020-12-22 
14:37:02.000000000 +0100
+++ new/yast2-storage-ng-4.3.37/src/lib/y2storage/mountable.rb  2021-01-14 
16:49:25.000000000 +0100
@@ -1,4 +1,4 @@
-# Copyright (c) [2017] SUSE LLC
+# Copyright (c) [2017-2020] SUSE LLC
 #
 # All Rights Reserved.
 #
@@ -175,5 +175,27 @@
     def extra_default_mount_options
       []
     end
+
+    private
+
+    # Ensures a mount point before executing the given block
+    #
+    # A temporary mount point is created and removed when there is no mount 
point.
+    #
+    # @return [Object] block result
+    def with_mount_point(&block)
+      tmp_mount_point = false
+
+      if !mount_point
+        storage_create_mount_point("__fake_path__")
+        tmp_mount_point = true
+      end
+
+      result = block.call(mount_point)
+
+      storage_remove_mount_point if tmp_mount_point
+
+      result
+    end
   end
 end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-storage-ng-4.3.35/test/y2storage/blk_device_test.rb 
new/yast2-storage-ng-4.3.37/test/y2storage/blk_device_test.rb
--- old/yast2-storage-ng-4.3.35/test/y2storage/blk_device_test.rb       
2020-12-22 14:37:02.000000000 +0100
+++ new/yast2-storage-ng-4.3.37/test/y2storage/blk_device_test.rb       
2021-01-14 16:49:25.000000000 +0100
@@ -444,6 +444,147 @@
     end
   end
 
+  describe "#path_for_mount_by" do
+    let(:device_name) { "/dev/sda1" }
+
+    context "when mounting by device" do
+      let(:mount_by) { Y2Storage::Filesystems::MountByType::DEVICE }
+
+      it "returns the kernel name" do
+        expect(subject.path_for_mount_by(mount_by)).to eq(device_name)
+      end
+    end
+
+    context "when mounting by UUID" do
+      let(:mount_by) { Y2Storage::Filesystems::MountByType::UUID }
+
+      context "and the device contains a filesystem with uuid" do
+        before { subject.filesystem.uuid = "111222333444" }
+
+        it "returns nil" do
+          expect(subject.path_for_mount_by(mount_by)).to be_nil
+        end
+      end
+
+      context "and the device contains no filesystem" do
+        before { subject.remove_descendants }
+
+        it "returns nil" do
+          expect(subject.path_for_mount_by(mount_by)).to be_nil
+        end
+      end
+
+      context "and the device is an MD" do
+        let(:scenario) { "md-imsm1-devicegraph.xml" }
+        let(:device_name) { "/dev/md/a" }
+
+        context "with uuid" do
+          it "returns the by-uuid udev path" do
+            expect(subject.path_for_mount_by(mount_by))
+              .to eq "/dev/disk/by-uuid/8f600ff3:ccc9872c:539cd6c8:91e3b4a1"
+          end
+        end
+
+        context "with not uuid defined yet" do
+          before { allow(subject).to receive(:uuid).and_return("") }
+
+          it "returns nil" do
+            expect(subject.path_for_mount_by(mount_by)).to be_nil
+          end
+        end
+      end
+
+      context "and the device is a LUKS" do
+        let(:device_name) { "/dev/mapper/cr_sda4" }
+
+        context "with uuid" do
+          before { allow(subject).to receive(:uuid).and_return("111222333444") 
}
+
+          it "returns the by-uuid udev path" do
+            expect(subject.path_for_mount_by(mount_by)).to eq 
"/dev/disk/by-uuid/111222333444"
+          end
+        end
+
+        context "with not uuid defined yet" do
+          it "returns nil" do
+            expect(subject.path_for_mount_by(mount_by)).to be_nil
+          end
+        end
+      end
+    end
+
+    context "when mounting by label" do
+      let(:mount_by) { Y2Storage::Filesystems::MountByType::LABEL }
+
+      context "and the device contains a filesystem with a label" do
+        it "returns nil" do
+          expect(subject.filesystem.label).to_not be_empty
+          expect(subject.path_for_mount_by(mount_by)).to be_nil
+        end
+      end
+
+      context "and the device contains a filesystem with no label" do
+        before { subject.filesystem.label = "" }
+
+        it "returns nil" do
+          expect(subject.path_for_mount_by(mount_by)).to be_nil
+        end
+      end
+
+      context "and the device contains no filesystem" do
+        before { subject.remove_descendants }
+
+        it "returns nil" do
+          expect(subject.path_for_mount_by(mount_by)).to be_nil
+        end
+      end
+    end
+
+    context "when mounting by path" do
+      let(:mount_by) { Y2Storage::Filesystems::MountByType::PATH }
+
+      context "and the device has by-path udev paths" do
+        before do
+          allow(subject).to receive(:udev_full_paths).and_return 
[path_by_path1, path_by_path2]
+        end
+
+        let(:path_by_path1) { "/dev/disk/by-path/pci1111-part1" }
+        let(:path_by_path2) { "/dev/disk/by-path/pci2222-part1" }
+
+        it "returns the first by-path udev path" do
+          expect(subject.path_for_mount_by(mount_by)).to eq(path_by_path1)
+        end
+      end
+
+      context "and the device has no by-path udev paths" do
+        before do
+          allow(subject).to receive(:udev_full_paths).and_return []
+        end
+
+        it "returns nil" do
+          expect(subject.path_for_mount_by(mount_by)).to be_nil
+        end
+      end
+
+      context "and the device is a LUKS" do
+        let(:device_name) { "/dev/mapper/cr_sda4" }
+
+        it "returns nil" do
+          expect(subject.path_for_mount_by(mount_by)).to be_nil
+        end
+      end
+
+      context "and the device is an MD" do
+        let(:scenario) { "md-imsm1-devicegraph.xml" }
+        let(:device_name) { "/dev/md/a" }
+
+        it "returns nil" do
+          expect(subject.path_for_mount_by(mount_by)).to be_nil
+        end
+      end
+    end
+  end
+
   describe "#udev_full_paths" do
     let(:device_name) { "/dev/sda1" }
     before { allow(device).to receive(:udev_paths).and_return(paths) }
@@ -1323,4 +1464,21 @@
       expect(subject.windows_suitable?).to eq(false)
     end
   end
+
+  describe "#preferred_name" do
+    let(:scenario) { "md-imsm1-devicegraph.xml" }
+    let(:device_name) { "/dev/sda1" }
+
+    let(:by_device) { Y2Storage::Filesystems::MountByType::DEVICE }
+    let(:by_path) { Y2Storage::Filesystems::MountByType::PATH }
+    let(:by_id) { Y2Storage::Filesystems::MountByType::ID }
+    let(:all_suitable) { [by_device, by_path, by_id] }
+
+    it "returns the best name from all the suitable ones" do
+      expect(Y2Storage::Filesystems::MountByType).to receive(:best_for)
+        .with(device, all_suitable).and_return(by_path)
+
+      expect(device.preferred_name).to eq 
"/dev/disk/by-path/pci-0000:00:1f.2-ata-1-part1"
+    end
+  end
 end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-storage-ng-4.3.35/test/y2storage/boot_requirements_errors_test.rb 
new/yast2-storage-ng-4.3.37/test/y2storage/boot_requirements_errors_test.rb
--- old/yast2-storage-ng-4.3.35/test/y2storage/boot_requirements_errors_test.rb 
2020-12-22 14:37:02.000000000 +0100
+++ new/yast2-storage-ng-4.3.37/test/y2storage/boot_requirements_errors_test.rb 
2021-01-14 16:49:25.000000000 +0100
@@ -302,7 +302,21 @@
       context "when there is a /boot/efi partition in the system" do
         let(:scenario) { "efi" }
 
-        include_examples("no warnings")
+        context "and the partition is as big as the ones the proposal 
suggests" do
+          include_examples("no warnings")
+        end
+
+        context "but the partition is smaller than the proposal would have 
suggested" do
+          before do
+            esp = fake_devicegraph.find_by_name("/dev/sda1")
+            allow(esp).to receive(:resize_info).and_return(
+              double("ResizeInfo", resize_ok?: true, min_size: 1.MiB, 
max_size: 8.GiB)
+            )
+            esp.resize(16.MiB)
+          end
+
+          include_examples("no warnings")
+        end
       end
     end
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-storage-ng-4.3.35/test/y2storage/filesystems/blk_filesystem_test.rb 
new/yast2-storage-ng-4.3.37/test/y2storage/filesystems/blk_filesystem_test.rb
--- 
old/yast2-storage-ng-4.3.35/test/y2storage/filesystems/blk_filesystem_test.rb   
    2020-12-22 14:37:02.000000000 +0100
+++ 
new/yast2-storage-ng-4.3.37/test/y2storage/filesystems/blk_filesystem_test.rb   
    2021-01-14 16:49:25.000000000 +0100
@@ -237,6 +237,57 @@
     end
   end
 
+  describe "#preferred_name" do
+    let(:scenario) { "mixed_disks" }
+    let(:dev_name) { "/dev/sdb2" }
+
+    context "when the filesystem contains a mount point" do
+      context "but the path for the given mount_by cannot be calculated" do
+        before do
+          allow(Y2Storage::Filesystems::MountByType).to receive(:best_for)
+            .with(subject, 
anything).and_return(Y2Storage::Filesystems::MountByType::LABEL)
+        end
+
+        it "returns the best udev name that can be calculated" do
+          subject.uuid = ""
+          subject.mount_point.mount_by = 
Y2Storage::Filesystems::MountByType::UUID
+
+          expect(subject.preferred_name).to eq "/dev/disk/by-label/suse_root"
+        end
+      end
+
+      context "and it's possible to honor the specified mount_by" do
+        it "returns the udev name corresponding to the current mount_by" do
+          subject.uuid = "12345678-90ab-cdef-1234-567890abcdef"
+          subject.mount_point.mount_by = 
Y2Storage::Filesystems::MountByType::UUID
+          expect(subject.preferred_name).to eq 
"/dev/disk/by-uuid/12345678-90ab-cdef-1234-567890abcdef"
+
+          subject.mount_point.mount_by = 
Y2Storage::Filesystems::MountByType::LABEL
+          expect(subject.preferred_name).to eq "/dev/disk/by-label/suse_root"
+        end
+      end
+    end
+
+    context "when the filesystem is not mounted" do
+      before do
+        allow(Y2Storage::Filesystems::MountByType).to receive(:best_for)
+          .with(subject, anything).and_return(
+            Y2Storage::Filesystems::MountByType::LABEL, 
Y2Storage::Filesystems::MountByType::UUID
+          )
+
+        subject.remove_mount_point
+        subject.uuid = "12345678-90ab-cdef-1234-567890abcdef"
+      end
+
+      it "returns the best udev name that can be calculated" do
+        # According to the mock, the first call to #best_for returns LABEL...
+        expect(subject.preferred_name).to eq "/dev/disk/by-label/suse_root"
+        # ...and the second call returns UUID
+        expect(subject.preferred_name).to eq 
"/dev/disk/by-uuid/12345678-90ab-cdef-1234-567890abcdef"
+      end
+    end
+  end
+
   describe "#mount_options" do
     context "when filesystem has no mount point" do
       let(:dev_name) { "/dev/sdb3" }
@@ -455,4 +506,103 @@
       expect(subject.name).to eq("Ext4 sda2")
     end
   end
+
+  describe "#mount_by_name" do
+    let(:dev_name) { "/dev/sda2" }
+    before { subject.mount_point.mount_by = mount_by }
+
+    context "when mounting by device" do
+      let(:mount_by) { Y2Storage::Filesystems::MountByType::DEVICE }
+
+      it "returns the kernel name of the block device" do
+        expect(subject.mount_by_name).to eq(dev_name)
+      end
+    end
+
+    context "when mounting by UUID" do
+      let(:mount_by) { Y2Storage::Filesystems::MountByType::UUID }
+
+      context "if the uuid of the filesystem is known already" do
+        before { subject.uuid = "111222333444" }
+
+        it "returns the by-uuid udev path" do
+          expect(subject.mount_by_name).to eq "/dev/disk/by-uuid/111222333444"
+        end
+      end
+
+      context "if the uuid is still not known" do
+        it "returns nil" do
+          expect(subject.mount_by_name).to be_nil
+        end
+      end
+    end
+
+    context "when mounting by label" do
+      let(:mount_by) { Y2Storage::Filesystems::MountByType::LABEL }
+
+      context "if the filesystem has a label" do
+        it "returns the by-label udev path" do
+          expect(subject.mount_by_name).to eq "/dev/disk/by-label/root"
+        end
+      end
+
+      context "if the filesystem has no label" do
+        before { subject.label = "" }
+
+        it "returns nil" do
+          expect(subject.mount_by_name).to be_nil
+        end
+      end
+    end
+
+    context "when mounting by path" do
+      let(:mount_by) { Y2Storage::Filesystems::MountByType::PATH }
+
+      before do
+        allow(subject).to receive(:blk_devices).and_return [blk_device]
+        allow(blk_device).to receive(:udev_full_paths).and_return(paths)
+      end
+
+      context "if the block device has by-path udev paths" do
+        let(:paths) { ["/dev/disk/by-path/pci1111-part2"] }
+
+        it "returns the first by-path udev path" do
+          expect(subject.mount_by_name).to eq(paths.first)
+        end
+      end
+
+      context "if the block device has no by-path udev paths" do
+        let(:paths) { [] }
+
+        it "returns nil" do
+          expect(subject.mount_by_name).to be_nil
+        end
+      end
+    end
+
+    context "when mounting by id" do
+      let(:mount_by) { Y2Storage::Filesystems::MountByType::ID }
+
+      before do
+        allow(subject).to receive(:blk_devices).and_return [blk_device]
+        allow(blk_device).to receive(:udev_full_ids).and_return(ids)
+      end
+
+      context "if the block device has by-id udev paths" do
+        let(:ids) { ["/dev/disk/by-id/id:pci:00"] }
+
+        it "returns the first by-id udev path" do
+          expect(subject.mount_by_name).to eq(ids.first)
+        end
+      end
+
+      context "if the block device has no by-id udev paths" do
+        let(:ids) { [] }
+
+        it "returns nil" do
+          expect(subject.mount_by_name).to be_nil
+        end
+      end
+    end
+  end
 end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-storage-ng-4.3.35/test/y2storage/mount_point_test.rb 
new/yast2-storage-ng-4.3.37/test/y2storage/mount_point_test.rb
--- old/yast2-storage-ng-4.3.35/test/y2storage/mount_point_test.rb      
2020-12-22 14:37:02.000000000 +0100
+++ new/yast2-storage-ng-4.3.37/test/y2storage/mount_point_test.rb      
2021-01-14 16:49:25.000000000 +0100
@@ -231,6 +231,50 @@
           expect(types).to_not 
include(Y2Storage::Filesystems::MountByType::PATH)
         end
       end
+
+      context "if we take the UUID for granted" do
+        let(:assume_uuid) { true }
+
+        context "and the UUID is already known" do
+          before { filesystem.uuid = "12345678-90ab-cdef-1234-567890abcdef" }
+
+          it "includes MountByType::UUID" do
+            expect(mount_point.suitable_mount_bys(assume_uuid: assume_uuid))
+              .to include(Y2Storage::Filesystems::MountByType::UUID)
+          end
+        end
+
+        context "and the filesystem has no UUID in the devicegraph" do
+          before { filesystem.uuid = "" }
+
+          it "includes MountByType::UUID" do
+            expect(mount_point.suitable_mount_bys(assume_uuid: assume_uuid))
+              .to include(Y2Storage::Filesystems::MountByType::UUID)
+          end
+        end
+      end
+
+      context "if we do not take the UUID for granted" do
+        let(:assume_uuid) { false }
+
+        context "and the UUID is already known" do
+          before { filesystem.uuid = "12345678-90ab-cdef-1234-567890abcdef" }
+
+          it "includes MountByType::UUID" do
+            expect(mount_point.suitable_mount_bys(assume_uuid: assume_uuid))
+              .to include(Y2Storage::Filesystems::MountByType::UUID)
+          end
+        end
+
+        context "and the filesystem has no UUID in the devicegraph" do
+          before { filesystem.uuid = "" }
+
+          it "does not include MountByType::UUID" do
+            expect(mount_point.suitable_mount_bys(assume_uuid: assume_uuid))
+              .to_not include(Y2Storage::Filesystems::MountByType::UUID)
+          end
+        end
+      end
     end
 
     context "for an encrypted device" do
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-storage-ng-4.3.35/test/y2storage/reusing_efi_test.rb 
new/yast2-storage-ng-4.3.37/test/y2storage/reusing_efi_test.rb
--- old/yast2-storage-ng-4.3.35/test/y2storage/reusing_efi_test.rb      
2020-12-22 14:37:02.000000000 +0100
+++ new/yast2-storage-ng-4.3.37/test/y2storage/reusing_efi_test.rb      
2021-01-14 16:49:25.000000000 +0100
@@ -128,7 +128,17 @@
     context "and it is smaller than the proposal min" do
       let(:size) { 32.MiB }
 
-      include_examples "not_reuse_partition_id"
+      context "and the id is ESP" do
+        let(:partition_id) { Y2Storage::PartitionId::ESP }
+
+        include_examples "reuse_efi"
+      end
+
+      context "and the id is not ESP" do
+        let(:partition_id) { Y2Storage::PartitionId::LINUX }
+
+        include_examples "not_reuse_efi"
+      end
     end
 
     context "and it is bigger than the proposal max" do

Reply via email to