Hello community,

here is the log from the commit of package yast2-bootloader for 
openSUSE:Leap:15.2 checked in at 2020-03-02 17:21:22
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Leap:15.2/yast2-bootloader (Old)
 and      /work/SRC/openSUSE:Leap:15.2/.yast2-bootloader.new.26092 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "yast2-bootloader"

Mon Mar  2 17:21:22 2020 rev:115 rq:779788 version:4.2.16

Changes:
--------
--- /work/SRC/openSUSE:Leap:15.2/yast2-bootloader/yast2-bootloader.changes      
2020-01-15 16:32:07.040878051 +0100
+++ 
/work/SRC/openSUSE:Leap:15.2/.yast2-bootloader.new.26092/yast2-bootloader.changes
   2020-03-02 17:21:22.654066865 +0100
@@ -1,0 +2,7 @@
+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.16.tar.bz2

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

Other differences:
------------------
++++++ yast2-bootloader.spec ++++++
--- /var/tmp/diff_new_pack.Vnz9WY/_old  2020-03-02 17:21:23.170067859 +0100
+++ /var/tmp/diff_new_pack.Vnz9WY/_new  2020-03-02 17:21:23.170067859 +0100
@@ -17,7 +17,7 @@
 
 
 Name:           yast2-bootloader
-Version:        4.2.15
+Version:        4.2.16
 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.16.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.16/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.16/package/yast2-bootloader.changes        
2020-02-26 12:06:56.000000000 +0100
@@ -1,4 +1,11 @@
 -------------------------------------------------------------------
+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.16/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.16/package/yast2-bootloader.spec   2020-02-26 
12:06:56.000000000 +0100
@@ -17,7 +17,7 @@
 
 
 Name:           yast2-bootloader
-Version:        4.2.15
+Version:        4.2.16
 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/udev_mapping.rb 
new/yast2-bootloader-4.2.16/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.16/src/lib/bootloader/udev_mapping.rb      
2020-02-26 12:06:56.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/udev_mapping_test.rb 
new/yast2-bootloader-4.2.16/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.16/test/udev_mapping_test.rb       2020-02-26 
12:06:56.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


Reply via email to