Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package yast2-bootloader for openSUSE:Factory checked in at 2021-11-22 23:03:46 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/yast2-bootloader (Old) and /work/SRC/openSUSE:Factory/.yast2-bootloader.new.1895 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "yast2-bootloader" Mon Nov 22 23:03:46 2021 rev:313 rq:932470 version:4.4.8 Changes: -------- --- /work/SRC/openSUSE:Factory/yast2-bootloader/yast2-bootloader.changes 2021-09-20 23:32:34.487130704 +0200 +++ /work/SRC/openSUSE:Factory/.yast2-bootloader.new.1895/yast2-bootloader.changes 2021-11-22 23:03:57.561977273 +0100 @@ -1,0 +2,9 @@ +Thu Nov 18 10:26:38 UTC 2021 - Michal Filka <mfi...@suse.com> + +- bnc#1092950 + - improved invalid input handling for custom boot partition + - added support for defining custom boot partition by UUID and/or + LABEL +- 4.4.8 + +------------------------------------------------------------------- Old: ---- yast2-bootloader-4.4.7.tar.bz2 New: ---- yast2-bootloader-4.4.8.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ yast2-bootloader.spec ++++++ --- /var/tmp/diff_new_pack.vdHEHK/_old 2021-11-22 23:03:58.333974682 +0100 +++ /var/tmp/diff_new_pack.vdHEHK/_new 2021-11-22 23:03:58.337974669 +0100 @@ -17,7 +17,7 @@ Name: yast2-bootloader -Version: 4.4.7 +Version: 4.4.8 Release: 0 Summary: YaST2 - Bootloader Configuration License: GPL-2.0-or-later ++++++ yast2-bootloader-4.4.7.tar.bz2 -> yast2-bootloader-4.4.8.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-bootloader-4.4.7/.github/workflows/ci.yml new/yast2-bootloader-4.4.8/.github/workflows/ci.yml --- old/yast2-bootloader-4.4.7/.github/workflows/ci.yml 2021-09-15 21:37:53.000000000 +0200 +++ new/yast2-bootloader-4.4.8/.github/workflows/ci.yml 2021-11-19 11:13:16.000000000 +0100 @@ -8,7 +8,8 @@ jobs: Tests: runs-on: ubuntu-latest - container: registry.opensuse.org/yast/head/containers/yast-ruby:latest + container: + image: registry.opensuse.org/yast/head/containers/yast-ruby:latest steps: @@ -33,7 +34,8 @@ Rubocop: runs-on: ubuntu-latest - container: registry.opensuse.org/yast/head/containers/yast-ruby:latest + container: + image: registry.opensuse.org/yast/head/containers/yast-ruby:latest steps: @@ -45,7 +47,8 @@ Package: runs-on: ubuntu-latest - container: registry.opensuse.org/yast/head/containers/yast-ruby:latest + container: + image: registry.opensuse.org/yast/head/containers/yast-ruby:latest steps: @@ -57,7 +60,8 @@ Yardoc: runs-on: ubuntu-latest - container: registry.opensuse.org/yast/head/containers/yast-ruby:latest + container: + image: registry.opensuse.org/yast/head/containers/yast-ruby:latest steps: @@ -71,7 +75,8 @@ # checks into one job avoids that overhead Checks: runs-on: ubuntu-latest - container: registry.opensuse.org/yast/head/containers/yast-ruby:latest + container: + image: registry.opensuse.org/yast/head/containers/yast-ruby:latest steps: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-bootloader-4.4.7/package/yast2-bootloader.changes new/yast2-bootloader-4.4.8/package/yast2-bootloader.changes --- old/yast2-bootloader-4.4.7/package/yast2-bootloader.changes 2021-09-15 21:37:53.000000000 +0200 +++ new/yast2-bootloader-4.4.8/package/yast2-bootloader.changes 2021-11-19 11:13:16.000000000 +0100 @@ -1,4 +1,13 @@ ------------------------------------------------------------------- +Thu Nov 18 10:26:38 UTC 2021 - Michal Filka <mfi...@suse.com> + +- bnc#1092950 + - improved invalid input handling for custom boot partition + - added support for defining custom boot partition by UUID and/or + LABEL +- 4.4.8 + +------------------------------------------------------------------- Fri Sep 10 08:11:16 UTC 2021 - Josef Reidinger <jreidin...@suse.com> - Fix calling dracut to regenerate all initrds (bsc#1189915) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-bootloader-4.4.7/package/yast2-bootloader.spec new/yast2-bootloader-4.4.8/package/yast2-bootloader.spec --- old/yast2-bootloader-4.4.7/package/yast2-bootloader.spec 2021-09-15 21:37:53.000000000 +0200 +++ new/yast2-bootloader-4.4.8/package/yast2-bootloader.spec 2021-11-19 11:13:16.000000000 +0100 @@ -17,7 +17,7 @@ Name: yast2-bootloader -Version: 4.4.7 +Version: 4.4.8 Release: 0 Summary: YaST2 - Bootloader Configuration License: GPL-2.0-or-later diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-bootloader-4.4.7/src/lib/bootloader/device_path.rb new/yast2-bootloader-4.4.8/src/lib/bootloader/device_path.rb --- old/yast2-bootloader-4.4.7/src/lib/bootloader/device_path.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-bootloader-4.4.8/src/lib/bootloader/device_path.rb 2021-11-19 11:13:16.000000000 +0100 @@ -0,0 +1,68 @@ +# frozen_string_literal: true + +require "yast" +require "y2storage" + +module Bootloader + # Class for device path + # + # @example device path can be defined explicitly + # DevicePath.new("/devs/sda") + # @example definition by UUID is translated to device path + # dev = DevicePath.new("UUID=\"0000-00-00\"") + # dev.path -> "/dev/disk/by-uuid/0000-00-00" + class DevicePath + attr_reader :path + + # Performs initialization + # + # @param dev [<String>] either a path like /dev/sda or special string for uuid or label + def initialize(dev) + dev = dev.strip + + @path = if dev_by_uuid?(dev) + # if defined by uuid, convert it + dev.sub(/UUID="([-a-zA-Z0-9]*)"/, '/dev/disk/by-uuid/\1') + elsif dev_by_label?(dev) + # as well for label + dev.sub(/LABEL="(.*)"/, '/dev/disk/by-label/\1') + else + # add it exactly (but whitespaces) as specified by the user + dev + end + end + + # @return [Boolean] true if the @path exists in the system + def exists? + !devicegraph.find_by_any_name(path).nil? + end + + alias_method :valid?, :exists? + + def uuid? + !!(path =~ /by-uuid/) + end + + def label? + !!(path =~ /by-label/) + end + + private + + def dev_by_uuid?(dev) + dev =~ /UUID=".+"/ + end + + def dev_by_label?(dev) + dev =~ /LABEL=".+"/ + end + + def devicegraph + if Yast::Mode.installation + Y2Storage::StorageManager.instance.staging + else + Y2Storage::StorageManager.instance.system + end + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-bootloader-4.4.7/src/lib/bootloader/grub2_widgets.rb new/yast2-bootloader-4.4.8/src/lib/bootloader/grub2_widgets.rb --- old/yast2-bootloader-4.4.7/src/lib/bootloader/grub2_widgets.rb 2021-09-15 21:37:53.000000000 +0200 +++ new/yast2-bootloader-4.4.8/src/lib/bootloader/grub2_widgets.rb 2021-11-19 11:13:16.000000000 +0100 @@ -8,6 +8,7 @@ require "bootloader/cpu_mitigations" require "bootloader/systeminfo" require "bootloader/os_prober" +require "bootloader/device_path" require "cfa/matcher" Yast.import "BootStorage" @@ -880,16 +881,35 @@ devs = Yast::UI.QueryWidget(:custom_list, :Value) devs.split(",").each do |dev| - # Add it exactly as specified by the user - stage1.add_device(dev.strip) + stage1.add_device(DevicePath.new(dev).path) end end def validate - if Yast::UI.QueryWidget(:custom, :Value) - devs = Yast::UI.QueryWidget(:custom_list, :Value) - if devs.strip.empty? - Yast::Report.Error(_("Custom boot device have to be specied if checked")) + return true if !Yast::UI.QueryWidget(:custom, :Value) + + devs = Yast::UI.QueryWidget(:custom_list, :Value) + + if devs.strip.empty? + Yast::Report.Error(_("Custom boot device has to be specified if checked")) + Yast::UI.SetFocus(Id(:custom_list)) + return false + end + + invalid_devs = invalid_custom_devices(devs) + if !invalid_devs.empty? + ret = Yast::Popup.ContinueCancel( + format( + _( + "These custom devices can be invalid: %s." \ + "Please check if exist and spelled correctly." \ + "Do you want to continue?" + ), + invalid_devs.join(", ") + ) + ) + + if !ret Yast::UI.SetFocus(Id(:custom_list)) return false end @@ -911,6 +931,30 @@ end end + # Checks list of custom devices + # + # @param devs_list[String] comma separated list of device definitions + # + # @return [Array<String>] devices which didn't pass validation + def invalid_custom_devices(devs_list) + # almost any byte sequence is potentially valid path in unix like systems + # AY profile can be generated for whatever system so we cannot decite if + # particular byte sequence is valid or not + return [] if Yast::Mode.config + + devs_list.split(",").reject do |d| + dev_path = DevicePath.new(d) + + if Yast::Mode.installation + # uuids are generated later by mkfs, so not known in time of installation + # so whatever can be true + dev_path.uuid? || dev_path.valid? + else + dev_path.valid? + end + end + end + def locations @locations ||= stage1.available_locations end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-bootloader-4.4.7/src/lib/bootloader/stage1.rb new/yast2-bootloader-4.4.8/src/lib/bootloader/stage1.rb --- old/yast2-bootloader-4.4.7/src/lib/bootloader/stage1.rb 2021-09-15 21:37:53.000000000 +0200 +++ new/yast2-bootloader-4.4.8/src/lib/bootloader/stage1.rb 2021-11-19 11:13:16.000000000 +0100 @@ -157,7 +157,15 @@ log.info "known devices #{known_devices.inspect}" devices.reject do |dev| - kernel_dev = Bootloader::UdevMapping.to_kernel_device(dev) + dev_path = DevicePath.new(dev) + + # in installation do not care of uuids - not know at this time + kernel_dev = if dev_path.uuid? + dev + else + Bootloader::UdevMapping.to_kernel_device(dev) + end + log.info "stage1 devices for #{dev} is #{kernel_dev.inspect}" known_devices.include?(kernel_dev) end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-bootloader-4.4.7/src/lib/bootloader/udev_mapping.rb new/yast2-bootloader-4.4.8/src/lib/bootloader/udev_mapping.rb --- old/yast2-bootloader-4.4.7/src/lib/bootloader/udev_mapping.rb 2021-09-15 21:37:53.000000000 +0200 +++ new/yast2-bootloader-4.4.8/src/lib/bootloader/udev_mapping.rb 2021-11-19 11:13:16.000000000 +0100 @@ -58,8 +58,12 @@ end def udev_to_kernel(dev) + dev_path = DevicePath.new(dev) + # in mode config if not found, then return itself return dev if Yast::Mode.config + # in installation do not care of uuids - not know at this time + return dev if Yast::Mode.installation && dev_path.uuid? device = staging.find_by_any_name(dev) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-bootloader-4.4.7/test/device_path_test.rb new/yast2-bootloader-4.4.8/test/device_path_test.rb --- old/yast2-bootloader-4.4.7/test/device_path_test.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-bootloader-4.4.8/test/device_path_test.rb 2021-11-19 11:13:16.000000000 +0100 @@ -0,0 +1,139 @@ +# frozen_string_literal: true + +require_relative "test_helper" + +require "bootloader/device_path" + +describe Bootloader::DevicePath do + subject(:dev_path) { Bootloader::DevicePath.new(param) } + let(:storage_manager) { double(Y2Storage::StorageManager, system: device_graph) } + + before do + end + + context "When activated with path for device file" do + let(:param) { "/dev/sda1" } + + it "Stores the path as obtained" do + expect(dev_path.path).to eql param + end + + describe "#exists?" do + context "when the path exists" do + let(:device_graph) do + double(Y2Storage::Devicegraph, find_by_any_name: double(Y2Storage::Device)) + end + + it "succeedes" do + allow(Y2Storage::StorageManager) + .to receive(:instance) + .and_return(storage_manager) + + expect(dev_path.exists?).to be true + end + end + + context "when the path doesn't exist" do + let(:device_graph) do + double(Y2Storage::Devicegraph, find_by_any_name: nil) + end + + it "fails" do + allow(Y2Storage::StorageManager) + .to receive(:instance) + .and_return(storage_manager) + + expect(Bootloader::DevicePath.new("/nonsense").exists?).to be false + end + end + end + + describe "#uuid?" do + it "fails for real device path" do + expect(dev_path.uuid?).to be false + end + end + + describe "#label?" do + it "fails for real device path" do + expect(dev_path.label?).to be false + end + end + end + + context "When activated with UUID" do + let(:uuid) { "00000000-1111-2222-3333-444444444444" } + let(:param) { "UUID=\"#{uuid}\"" } + let(:fs_path) { "/dev/disk/by-uuid/#{uuid}" } + + it "Converts UUID to fs path" do + expect(dev_path.path).to eql fs_path + end + + describe "#exists?" do + context "when the path exists" do + let(:device_graph) do + double(Y2Storage::Devicegraph, find_by_any_name: double(Y2Storage::Device)) + end + + it "succeedes" do + allow(Y2Storage::StorageManager) + .to receive(:instance) + .and_return(storage_manager) + + expect(dev_path.exists?).to be true + end + end + end + + describe "#uuid?" do + it "succeedes" do + expect(dev_path.uuid?).to be true + end + end + + describe "#label?" do + it "fails for uuid activated path" do + expect(dev_path.label?).to be false + end + end + end + + context "When activated with LABEL" do + let(:label) { "OpenSUSE" } + let(:param) { "LABEL=\"#{label}\"" } + let(:fs_path) { "/dev/disk/by-label/#{label}" } + + it "Converts LABEL to fs path" do + expect(dev_path.path).to eql fs_path + end + + describe "#exists?" do + context "when the path exists" do + let(:device_graph) do + double(Y2Storage::Devicegraph, find_by_any_name: double(Y2Storage::Device)) + end + + it "succeedes for existing device" do + allow(Y2Storage::StorageManager) + .to receive(:instance) + .and_return(storage_manager) + + expect(dev_path.exists?).to be true + end + end + end + + describe "#uuid?" do + it "fails for label activated path" do + expect(dev_path.uuid?).to be false + end + end + + describe "#label?" do + it "succeedes" do + expect(dev_path.label?).to be true + end + end + end +end