commit yast2-update for openSUSE:Factory
Hello community, here is the log from the commit of package yast2-update for openSUSE:Factory checked in at 2019-05-05 21:17:20 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/yast2-update (Old) and /work/SRC/openSUSE:Factory/.yast2-update.new.5148 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "yast2-update" Sun May 5 21:17:20 2019 rev:128 rq:699686 version:4.2.2 Changes: -------- --- /work/SRC/openSUSE:Factory/yast2-update/yast2-update.changes 2019-01-26 22:21:36.810894621 +0100 +++ /work/SRC/openSUSE:Factory/.yast2-update.new.5148/yast2-update.changes 2019-05-05 21:17:21.620613731 +0200 @@ -1,0 +2,19 @@ +Fri Apr 26 11:03:27 UTC 2019 - Ladislav Slezák <lslezak@suse.cz> + +- Uninstall the "SUSE-Manager-Proxy" product when upgrading from + SLES12 + SUMA Proxy + SUMA Branch Server (bsc#1133215) +- 4.2.2 + +------------------------------------------------------------------- +Fri Apr 5 14:43:25 UTC 2019 - José Iván López González <jlopez@suse.com> + +- Remove obsolete code. +- 4.2.1 + +------------------------------------------------------------------- +Tue Mar 26 16:29:07 UTC 2019 - José Iván López González <jlopez@suse.com> + +- Remove code related to device name translations. +- 4.2.0 + +------------------------------------------------------------------- Old: ---- yast2-update-4.1.8.tar.bz2 New: ---- yast2-update-4.2.2.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ yast2-update.spec ++++++ --- /var/tmp/diff_new_pack.xwyWcx/_old 2019-05-05 21:17:21.984614722 +0200 +++ /var/tmp/diff_new_pack.xwyWcx/_new 2019-05-05 21:17:21.984614722 +0200 @@ -17,7 +17,7 @@ Name: yast2-update -Version: 4.1.8 +Version: 4.2.2 Release: 0 BuildRoot: %{_tmppath}/%{name}-%{version}-build @@ -25,9 +25,10 @@ Url: http://github.com/yast/yast-update BuildRequires: update-desktop-files -BuildRequires: yast2 >= 3.1.126 BuildRequires: yast2-devtools >= 3.1.15 BuildRequires: yast2-ruby-bindings >= 1.0.0 +# Y2Packager::ProductUpgrade.remove_obsolete_upgrades +BuildRequires: yast2 >= 4.2.1 # Packages#proposal_for_update BuildRequires: yast2-packager >= 3.2.13 @@ -44,8 +45,8 @@ BuildRequires: yast2-storage-ng >= 4.1.31 # Encryption.save_crypttab_names Requires: yast2-storage-ng >= 4.1.31 -# FSSnapshotStore -Requires: yast2 >= 3.1.126 +# Y2Packager::ProductUpgrade.remove_obsolete_upgrades +Requires: yast2 >= 4.2.1 Requires: yast2-installation # handle bind mount at /mnt/dev ++++++ yast2-update-4.1.8.tar.bz2 -> yast2-update-4.2.2.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-update-4.1.8/Dockerfile new/yast2-update-4.2.2/Dockerfile --- old/yast2-update-4.1.8/Dockerfile 2019-01-25 08:26:24.000000000 +0100 +++ new/yast2-update-4.2.2/Dockerfile 2019-04-30 15:40:22.000000000 +0200 @@ -1,3 +1,3 @@ -FROM yastdevel/ruby +FROM registry.opensuse.org/yast/head/containers/yast-ruby:latest COPY . /usr/src/app diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-update-4.1.8/package/yast2-update.changes new/yast2-update-4.2.2/package/yast2-update.changes --- old/yast2-update-4.1.8/package/yast2-update.changes 2019-01-25 08:26:24.000000000 +0100 +++ new/yast2-update-4.2.2/package/yast2-update.changes 2019-04-30 15:40:22.000000000 +0200 @@ -1,4 +1,23 @@ ------------------------------------------------------------------- +Fri Apr 26 11:03:27 UTC 2019 - Ladislav Slezák <lslezak@suse.cz> + +- Uninstall the "SUSE-Manager-Proxy" product when upgrading from + SLES12 + SUMA Proxy + SUMA Branch Server (bsc#1133215) +- 4.2.2 + +------------------------------------------------------------------- +Fri Apr 5 14:43:25 UTC 2019 - José Iván López González <jlopez@suse.com> + +- Remove obsolete code. +- 4.2.1 + +------------------------------------------------------------------- +Tue Mar 26 16:29:07 UTC 2019 - José Iván López González <jlopez@suse.com> + +- Remove code related to device name translations. +- 4.2.0 + +------------------------------------------------------------------- Thu Jan 24 18:49:24 UTC 2019 - lslezak@suse.cz - Added URL tag to the spec file (bsc#1097957) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-update-4.1.8/package/yast2-update.spec new/yast2-update-4.2.2/package/yast2-update.spec --- old/yast2-update-4.1.8/package/yast2-update.spec 2019-01-25 08:26:24.000000000 +0100 +++ new/yast2-update-4.2.2/package/yast2-update.spec 2019-04-30 15:40:22.000000000 +0200 @@ -17,7 +17,7 @@ Name: yast2-update -Version: 4.1.8 +Version: 4.2.2 Release: 0 BuildRoot: %{_tmppath}/%{name}-%{version}-build @@ -29,7 +29,8 @@ BuildRequires: update-desktop-files BuildRequires: yast2-devtools >= 3.1.15 BuildRequires: yast2-ruby-bindings >= 1.0.0 -BuildRequires: yast2 >= 3.1.126 +# Y2Packager::ProductUpgrade.remove_obsolete_upgrades +BuildRequires: yast2 >= 4.2.1 # Packages#proposal_for_update BuildRequires: yast2-packager >= 3.2.13 @@ -46,8 +47,8 @@ BuildRequires: yast2-storage-ng >= 4.1.31 # Encryption.save_crypttab_names Requires: yast2-storage-ng >= 4.1.31 -# FSSnapshotStore -Requires: yast2 >= 3.1.126 +# Y2Packager::ProductUpgrade.remove_obsolete_upgrades +Requires: yast2 >= 4.2.1 Requires: yast2-installation # handle bind mount at /mnt/dev diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-update-4.1.8/src/clients/update_proposal.rb new/yast2-update-4.2.2/src/clients/update_proposal.rb --- old/yast2-update-4.1.8/src/clients/update_proposal.rb 2019-01-25 08:26:24.000000000 +0100 +++ new/yast2-update-4.2.2/src/clients/update_proposal.rb 2019-04-30 15:40:22.000000000 +0200 @@ -27,6 +27,7 @@ # require "cgi/util" +require "y2packager/product_upgrade" module Yast class UpdateProposalClient < Client @@ -450,6 +451,10 @@ # Control the upgrade process better update_sum = Pkg.PkgUpdateAll(GetUpdateConf()) Builtins.y2milestone("Update summary: %1", update_sum) + + # deselect the upgraded obsolete products (bsc#1133215) + Y2Packager::ProductUpgrade.remove_obsolete_upgrades + Update.unknown_packages = Ops.get(update_sum, :ProblemListSze, 0) end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-update-4.1.8/src/include/update/rootpart.rb new/yast2-update-4.2.2/src/include/update/rootpart.rb --- old/yast2-update-4.1.8/src/include/update/rootpart.rb 2019-01-25 08:26:24.000000000 +0100 +++ new/yast2-update-4.2.2/src/include/update/rootpart.rb 2019-04-30 15:40:22.000000000 +0200 @@ -47,10 +47,6 @@ Yast.import "Report" Yast.import "Update" Yast.import "Installation" -# storage-ng -=begin - Yast.import "FileSystems" -=end Yast.import "Mode" Yast.import "Product" end @@ -180,7 +176,7 @@ # exact match if arch_1 == arch_2 - return true + return true # ppc exception elsif Builtins.contains(ppc_archs, arch_1) && Builtins.contains(ppc_archs, arch_2) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-update-4.1.8/src/modules/RootPart.rb new/yast2-update-4.2.2/src/modules/RootPart.rb --- old/yast2-update-4.1.8/src/modules/RootPart.rb 2019-01-25 08:26:24.000000000 +0100 +++ new/yast2-update-4.2.2/src/modules/RootPart.rb 2019-04-30 15:40:22.000000000 +0200 @@ -58,15 +58,6 @@ Yast.import "Stage" Yast.import "Wizard" -# storage-ng -# This include allows to use DlgUpdateCryptFs, which has not equivalent in -# yast-storage-ng. So the whole method invoking DlgUpdateCryptFs should be -# checked (it's hopefully useless now). -=begin - Yast.include self, "partitioning/custom_part_dialogs.rb" -=end - - # Selected root partition for the update or boot. @selectedRootPartition = "" @@ -111,15 +102,6 @@ # include Installation::destdir. @activated = [] - - # Link to SDB article concerning renaming of devices. - @sdb = Builtins.sformat( - _( - "See the SDB article at %1 for details\nabout how to solve this problem." - ), - "http://support.novell.com/techcenter/sdb/en/2003/03/fhassel_update_not_possi..." - ) - # translation from new to old device names # such as /dev/sdc4 -> /dev/hdb4 @backward_translation = {} @@ -626,90 +608,6 @@ options end - # Translates FS or Cryptotab (old devices to new ones). - # Such as /dev/hda5 to /dev/sda5. - # - # @param list <map> of definitions to translate - # @param string key name in map to translate - # @param string key name in map to keep the old value - # @return [Array<Hash>] of translated definitions - # - # @see #https://bugzilla.novell.com/show_bug.cgi?id=258222 - def TranslateFsOrCryptoTab(translate, key_to_translate, key_preserve_as) - translate = deep_copy(translate) - # Check whether there is any hardware information that could be used - check_command = Builtins.sformat( - "/usr/bin/find '%1/var/lib/hardware/'", - String.Quote(Installation.destdir) - ) - cmd = Convert.to_map( - SCR.Execute(path(".target.bash_output"), check_command) - ) - - if Ops.get(cmd, "exit") != nil - files = Builtins.splitstring(Ops.get_string(cmd, "stdout", ""), "\n") - files_count = Builtins.size(files) - if files_count == nil || Ops.less_or_equal(files_count, 2) - Builtins.y2error( - "There are only %1 files in /var/lib/hardware/, translation needn't work!", - files_count - ) - else - Builtins.y2milestone( - "There are %1 files in /var/lib/hardware/", - files_count - ) - end - end - - # first find a list of values for translation - old_names = [] - Builtins.foreach(translate) do |m| - old_names = Builtins.add( - old_names, - Ops.get_string(m, key_to_translate, "") - ) - end - - # translate them - # storage-ng - new_names = old_names -=begin - new_names = Storage.GetTranslatedDevices( - Installation.installedVersion, - Installation.updateVersion, - old_names - ) -=end - - i = 0 - - # replace old values with translated ones - while Ops.less_than(i, Builtins.size(translate)) - default_val = Ops.get_string(translate, [i, key_to_translate], "") - new_val = Ops.get(new_names, i, default_val) - - Ops.set(translate, [i, key_to_translate], new_val) - Ops.set(translate, [i, key_preserve_as], default_val) - Ops.set(@backward_translation, new_val, default_val) - - Ops.set( - translate, - [i, "mntops"], - update_mount_options(Ops.get_string(translate, [i, "mntops"], "")) - ) - - i = Ops.add(i, 1) - end - - Builtins.y2milestone( - "Current backward translations: %1", - @backward_translation - ) - - deep_copy(translate) - end - # Register a new fstab agent and read the configuration # from Installation::destdir def readFsTab(fstab) @@ -766,62 +664,6 @@ nil end - # Register a new cryptotab agent and read the configuration - # from Installation::destdir - def readCryptoTab(crtab) - crtab_file = Ops.add(Installation.destdir, "/etc/cryptotab") - - if FileUtils.Exists(crtab_file) - SCR.RegisterAgent( - path(".target.etc.cryptotab"), - term( - :ag_anyagent, - term( - :Description, - term(:File, crtab_file), - "#\n", # Comment - false, # read-only - term( - :List, - term( - :Tuple, - term(:loop, term(:String, "^\t ")), - term(:Separator, "\t "), - term(:file, term(:String, "^\t ")), - term(:Separator, "\t "), - term(:mount, term(:String, "^\t ")), - term(:Separator, "\t "), - term(:vfstype, term(:String, "^\t ")), - term(:Separator, "\t "), - term(:opt1, term(:String, "^\t ")), - term(:Separator, "\t "), - term(:opt2, term(:String, "^ \t")), - term(:Optional, term(:Whitespace)), - term(:Optional, term(:the_rest, term(:String, "^\n"))) - ), - "\n" - ) - ) - ) - ) - - crtab.value = Convert.convert( - SCR.Read(path(".target.etc.cryptotab")), - :from => "any", - :to => "list <map>" - ) - - SCR.UnregisterAgent(path(".target.etc.cryptotab")) - else - Builtins.y2milestone( - "No such file %1. Not using cryptotab.", - crtab_file - ) - end - - nil - end - def FstabHasSeparateVar(fstab) var_device_fstab = ( fstab_ref = arg_ref(fstab.value); @@ -863,135 +705,21 @@ default_scr = WFM.SCRGetDefault new_scr = nil @backward_translation = {} + # /etc/cryptotab was deprecated in favor of /etc/crypttab + # + # crypttab file is processed by storage-ng, see {#MountPartitions}. + crtab.value = [] if Stage.initial fstab_ref = arg_ref(fstab.value) readFsTab(fstab_ref) fstab.value = fstab_ref.value - crtab_ref = arg_ref(crtab.value) - readCryptoTab(crtab_ref) - crtab.value = crtab_ref.value else fstab.value = Convert.convert( SCR.Read(path(".etc.fstab")), :from => "any", :to => "list <map>" ) - crtab.value = Convert.convert( - SCR.Read(path(".etc.cryptotab")), - :from => "any", - :to => "list <map>" - ) - end - - fstab_has_separate_var = ( - fstab_ref = arg_ref(fstab.value); - _FstabHasSeparateVar_result = FstabHasSeparateVar(fstab_ref); - fstab.value = fstab_ref.value; - _FstabHasSeparateVar_result - ) - # mount /var - if fstab_has_separate_var - Builtins.y2warning("Separate /var partition!") - MountVarIfRequired(fstab.value, root_device_current, false) - else - Builtins.y2milestone("No separate /var partition found") - end - - Builtins.y2milestone("fstab: %1", fstab.value) - fstab.value = TranslateFsOrCryptoTab(fstab.value, "spec", "spec_old") - Builtins.y2milestone("fstab: (translated) %1", fstab.value) - - Builtins.y2milestone("crtab: %1", crtab.value) - crtab.value = TranslateFsOrCryptoTab(crtab.value, "file", "file_old") - Builtins.y2milestone("crtab: (translated) %1", crtab.value) - - # umount /var - if fstab_has_separate_var - SCR.Execute( - path(".target.umount"), - Ops.add(Installation.destdir, "/var") - ) - @activated = Builtins.remove(@activated, 0) - end - - true - end - - - # - def PrepareCryptoTab(crtab, fstab) - crtab = deep_copy(crtab) - crypt_nb = 0 - - Builtins.foreach(crtab) do |mounts| - vfstype = Ops.get_string(mounts, "vfstype", "") - mntops = Ops.get_string(mounts, "opt2", "") - loop = Ops.get_string(mounts, "loop", "") - fspath = Ops.get_string(mounts, "mount", "") - device = Ops.get_string(mounts, "file", "") - Builtins.y2milestone( - "vfstype:%1 mntops:%2 loop:%3 fspath:%4 device:%5", - vfstype, - mntops, - loop, - fspath, - device - ) - if !Builtins.issubstring(mntops, "noauto") - again = true - while again - crypt_ok = true - crypt_passwd = DlgUpdateCryptFs(device, fspath) - - if crypt_passwd == nil || crypt_passwd == "" - crypt_ok = false - again = false - end - - Builtins.y2milestone("crypt pwd ok:%1", crypt_ok) - - if crypt_ok - setloop = { - "encryption" => "twofish", - "passwd" => crypt_passwd, - "loop_dev" => loop, - "partitionName" => device - } - - crypt_ok = ( - setloop_ref = arg_ref(setloop); - _PerformLosetup_result = Storage.PerformLosetup( - setloop_ref, - false - ); - setloop = setloop_ref.value; - _PerformLosetup_result - ) - Builtins.y2milestone("crypt ok: %1", crypt_ok) - if crypt_ok - loop = Ops.get_string(setloop, "loop_dev", "") - else - # yes-no popup - again = Popup.YesNo(_("Incorrect password. Try again?")) - end - end - - if crypt_ok - add_fs = { - "file" => fspath, - "mntops" => mntops, - "spec" => loop, - "freq" => 0, - "passno" => 0, - "vfstype" => vfstype - } - fstab.value = Builtins.prepend(fstab.value, add_fs) - AddMountedPartition({ :type => "crypt", :device => device }) - again = false - end - end - end end true @@ -1254,32 +982,24 @@ end # Mount /var partition - # @param [String] device string device holding the /var subtree - # @return [String] nil on success, error description on fail + # + # @param device [String] name of the device holding /var + # @return [String, nil] nil on success, error description on fail def MountVarPartition(device) mount_err = FsckAndMount("/var", device, "") - err_message = nil - if mount_err != nil - Builtins.y2error(-1, "failed to mount /var") - err_message = Ops.add( - Ops.add( - Ops.add( - Ops.add( - Builtins.sformat( - # error message - _("The /var partition %1 could not be mounted.\n"), - device - ), - "\n" - ), - mount_err - ), - "\n\n" - ), - @sdb - ) - end - err_message + + return nil unless mount_err + + log.error("failed to mount /var") + + # TRANSLATORS: error message when /var partition cannot be mounted. %{device} + # is replaced by a device name (e.g., /dev/sda2) and %{error} is replaced by + # error details. + format( + _("The /var partition %{device} could not be mounted.\n\n%{error}"), + device: device, + error: mount_err + ) end # <-- BNC #448577, Cannot find /var partition automatically @@ -1440,7 +1160,7 @@ manual_mount_successful end - def MountVarIfRequired(fstab, root_device_current, manual_var_mount) + def MountVarIfRequired(fstab, manual_var_mount) fstab = deep_copy(fstab) var_device_fstab = ( fstab_ref = arg_ref(fstab); @@ -1458,40 +1178,26 @@ return nil end - # BNC #494240: all methods except kernel names should be stable enough - if !mounted_by_kernel_name?(var_device_fstab) - log.info "Device #{var_device_fstab} is not mounted by kernel name, mounting..." - return MountVarPartition(var_device_fstab) - end + filesystem = find_filesystem_by_fstab_spec(var_device_fstab) - # Mounting virtual devices by kernel name (e.g. /dev/md0 or /dev/system/swap_lv) - # is also considered to be safe - if virtual_device?(var_device_fstab) - log.info "Device #{var_device_fstab} is not a partition, mounting..." - return MountVarPartition(var_device_fstab) - end - - # At this point, var_device_fstab points either to a device that is not - # longer available or to a plain partition. - # - # In the second case the name may not be reliable since the disk may have - # changed its name (e.g. it used to be recognized as /dev/sda or /dev/hdb in - # the system to update but it became /dev/sdb in the new system). - new_name = update_var_dev_name(var_device_fstab, fstab, root_device_current) - if new_name - if new_name != var_device_fstab - log.info "Partition #{var_device_fstab} seems to have turned into #{new_name}" - end - log.info "Device #{new_name} is a partition, mounting..." - return MountVarPartition(new_name) - end + # Try to mount /var if any filesystem matches the fstab specification + return MountVarPartition(var_device_fstab) if filesystem # BNC #448577: cannot find /var partition automatically, so ask the user return nil if manual_var_mount && MountUserDefinedVarPartition() # Everything else failed, return error message log.error "Unable to mount /var partition" - _("Unable to mount /var partition with this disk configuration.\n") + @sdb + + _("Unable to mount /var partition with this disk configuration.\n") + end + + # Finds a filesystem that matches the given fstab spec + # + # @param spec [String] + # @return [Y2Storage::Filesystem, nil] + def find_filesystem_by_fstab_spec(spec) + probed.blk_filesystems.find { |f| f.match_fstab_spec?(spec) } end def has_pam_mount @@ -1603,7 +1309,7 @@ message = _("No fstab found.") success = false else - tmp_msg = MountVarIfRequired(fstab, root_device_current, true) + tmp_msg = MountVarIfRequired(fstab, true) if tmp_msg != nil Builtins.y2error("failed to mount /var!") message = tmp_msg @@ -1622,29 +1328,18 @@ check_root_device_result ) Builtins.y2error("fstab has wrong root device!") - # message part 1 - message = Ops.add( - Ops.add( - _( - "The root partition in /etc/fstab has an invalid root device.\n" - ), - # message part 2 - Builtins.sformat( - _("It is currently mounted as %1 but listed as %2.\n"), - root_device_current, - tmp - ) - ), - @sdb + + # TRANSLATORS: Error message, where %{root} and %{tmp} are replaced by + # device names (e.g., /dev/sda1 and /dev/sda2). + message = format( + _("The root partition in /etc/fstab has an invalid root device.\n" \ + "It is currently mounted as %{root} but listed as %{tmp}."), + root: root_device_current, + tmp: tmp ) + success = false else - Builtins.y2milestone("cryptotab %1", crtab) - - fstab_ref = arg_ref(fstab) - PrepareCryptoTab(crtab, fstab_ref) - fstab = fstab_ref.value - Builtins.y2milestone("fstab %1", fstab) legacy_filesystems = @@ -1792,8 +1487,7 @@ ret end - # storage-ng - # this is the closest equivalent we have in storage-ng + # This is the closest equivalent we have in storage-ng def device_type(device) if device.is?(:partition) device.id.to_human_string @@ -1846,12 +1540,6 @@ SCR.Execute(path(".target.modprobe"), mount_type, "") end - # storage-ng: not sure if we need to introduce something equivalent -=begin - log.debug("Removing #{p_dev}") - Storage.RemoveDmMapsTo(p_dev) -=end - # mount (read-only) partition to Installation::destdir log.debug("Mounting #{[p_dev, Installation.destdir, Installation.mountlog].inspect}") mount = @@ -2304,81 +1992,6 @@ device.udev_full_uuid end - # Whether the given fstab spec corresponds to a device mounted by its kernel - # device name. - # - # @param spec [String] content of the first column of an /etc/fstab entry - # @return [Boolean] - def mounted_by_kernel_name?(spec) - mount_by = Y2Storage::Filesystems::MountByType.from_fstab_spec(spec) - mount_by.is?(:device) - end - - # Whether the device referenced by the given fstab spec is a virtual device - # (basically anything that is not a partition). - # - # This is somehow the inverse of the old Storage.DeviceRealDisk - # - # @param spec [String] content of the first column of an /etc/fstab entry - # @return [Boolean] true if the device was found and is not a partition - def virtual_device?(spec) - filesystem = fs_by_devicename(probed, spec) - # If 'filesystem' is nil, either the device is not longer there or it's a - # partition that now has a new name (names of virtual devices should be stable). - return false unless filesystem - - # If this is not based on a block device (so far that means this is NFS), - # then it's virtual. - return true unless filesystem.respond_to?(:plain_blk_devices) - - # To be more faithful to the original check on Storage.DeviceRealDisk - # let's consider everything but a partition to be virtual. - filesystem.plain_blk_devices.none? { |dev| dev.is?(:partition) } - end - - # This method tries to infer the /var device name from its partition number - # and the name of the root device. - # - # @param var_name [String] spec of the /var partition in the old /etc/fstab - # @param fstab [Array<Hash>] content of the old /etc/fstab - # @param root_current_name [String] current kernel device name of the root partition - # @return [String, nil] new name of the device (best guess), nil if we know - # the current name is outdated but we cannot infer the new one - def update_var_dev_name(var_name, fstab, root_current_name) - root_entry = fstab.find { |entry| entry["file"] == "/" } - root_spec = root_entry ? root_entry["spec"] : nil - root_device = probed.find_by_name(root_current_name) - - # If /var was mounted by partition kernel name but the root device was - # not, we cannot apply the upcoming logic to make up the new /var device - # name. Let's simply use the one we already know. - if root_spec.nil? || !mounted_by_kernel_name?(root_spec) || !root_device.is?(:partition) - return var_name - end - - # Regular expresion to break a partition name. Second capture gets the - # partition number (as string). First capture gets the rest. - regexp = /(.*[^\d])(\d*)$/ - var_name_no_number, var_name_number = regexp.match(var_name).captures - root_spec_no_number = regexp.match(root_spec)[1] - - # If /var and / were partitions in the same disk... - if var_name_no_number == root_spec_no_number - root_current_no_number = regexp.match(root_current_name)[1] - return root_current_no_number + var_name_number - end - - # If both partitions were not in the same disk, we assume '/' is in one - # disk and '/var' in the other one. Of course that logic only works if - # there are exactly two disks. - return nil if probed.disk_devices.size != 2 - - root_disk = root_device.partitionable - other_disk = probed.disk_devices.find { |dev| dev != root_disk } - partition = other_disk.partitions.find { |part| part.number == var_name_number.to_i } - partition.name - end - # @see #mount_regular_fstab_entry?( ALLOWED_FS = [ "ext", diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-update-4.1.8/test/root_part_test.rb new/yast2-update-4.2.2/test/root_part_test.rb --- old/yast2-update-4.1.8/test/root_part_test.rb 2019-01-25 08:26:24.000000000 +0100 +++ new/yast2-update-4.2.2/test/root_part_test.rb 2019-04-30 15:40:22.000000000 +0200 @@ -69,10 +69,10 @@ end it "returns a string including the device and the error " do - result = subject.MountVarIfRequired(fstab, root_device, false) + result = subject.MountVarIfRequired(fstab, false) expect(result).to be_a(String) expect(result).to include("an error") - expect(result).to include(var_device) + expect(result).to include(var_spec) end end @@ -82,7 +82,7 @@ end it "returns nil" do - expect(subject.MountVarIfRequired(fstab, root_device, false)).to be_nil + expect(subject.MountVarIfRequired(fstab, false)).to be_nil end end end @@ -90,33 +90,31 @@ context "if there is no separate partition" do context "and no @/var subvolume" do let(:fstab) { fstab_sda2 } - let(:root_device) { "/dev/sda2" } let(:root_spec) { "UUID=d6e5c710-3067-48de-8363-433e54a9d0b5" } it "does not try to mount /var" do expect(subject).to_not receive(:FsckAndMount) - subject.MountVarIfRequired(fstab, root_device, false) + subject.MountVarIfRequired(fstab, false) end it "returns nil" do - expect(subject.MountVarIfRequired(fstab, root_device, false)).to be_nil + expect(subject.MountVarIfRequired(fstab, false)).to be_nil end end context "and there is a @/var subvolume" do let(:fstab) { fstab_sda1 } - let(:root_device) { "/dev/sda1" } let(:root_spec) { "UUID=0a0ebfa7-e1a8-45f2-ad53-495e192fcc8d" } # The old code did not support Btrfs properly, so it mounted the /var # subvolume as a partition, which produced big breakage. it "does not try to mount /var" do expect(subject).to_not receive(:FsckAndMount) - subject.MountVarIfRequired(fstab, root_device, false) + subject.MountVarIfRequired(fstab, false) end it "returns nil" do - expect(subject.MountVarIfRequired(fstab, root_device, false)).to be_nil + expect(subject.MountVarIfRequired(fstab, false)).to be_nil end end end @@ -131,48 +129,32 @@ ] end - context "that was mounted by UUID" do - let(:root_device) { "/dev/sda2" } + context "and the device is found in the system" do let(:root_spec) { "UUID=d6e5c710-3067-48de-8363-433e54a9d0b5" } let(:var_spec) { "UUID=c9510dc7-fb50-4f7b-bd84-886965c821f6" } - let(:var_device) { var_spec } - it "tries to mount /var by its UUID" do - expect(subject).to receive(:FsckAndMount).with("/var", var_device, "") - subject.MountVarIfRequired(fstab, root_device, false) + it "tries to mount /var" do + expect(subject).to receive(:FsckAndMount).with("/var", var_spec, "") + subject.MountVarIfRequired(fstab, false) end include_examples "mounting result" end - context "that was mounted by kernel device name" do - # Let's simulate the situation in which the disk used to have another name - let(:root_spec) { "/dev/sdb2" } - let(:root_device) { "/dev/sda2" } + context "and the device is not found in the system" do + let(:root_spec) { "/dev/sda2" } - context "and is in the same disk than /" do - let(:var_spec) { "/dev/sdb4" } - let(:var_device) { "/dev/sda4" } + let(:var_spec) { "/dev/sdc1" } - it "tries to mount /var by its adapted device name" do - expect(subject).to receive(:FsckAndMount).with("/var", var_device, "") - subject.MountVarIfRequired(fstab, root_device, false) - end - - include_examples "mounting result" + it "does not try to mount /var" do + expect(subject).to_not receive(:FsckAndMount) + subject.MountVarIfRequired(fstab, false) end - context "and is in a different disk than / (two disks in total)" do - let(:var_spec) { "/dev/sda1" } - let(:var_device) { "/dev/sdb1" } - - it "tries to mount /var by its adapted device name" do - expect(subject).to receive(:FsckAndMount).with("/var", var_device, "") - subject.MountVarIfRequired(fstab, root_device, false) - end - - include_examples "mounting result" + it "returns an error" do + expect(subject.MountVarIfRequired(fstab, false)) + .to match(/Unable to mount/) end end end @@ -189,47 +171,32 @@ ] end - context "that was mounted by UUID" do - let(:root_device) { "/dev/vg0/root" } - let(:root_spec) { "/dev/disk/by-uuid/5a0a-3387" } + context "and the LVM logical volume is found in the system" do + let(:root_spec) { "/dev/vg0/root" } let(:var_spec) { "/dev/disk/by-uuid/4b85-3de0" } - let(:var_device) { var_spec } - it "tries to mount /var by its UUID" do - expect(subject).to receive(:FsckAndMount).with("/var", var_device, "") - subject.MountVarIfRequired(fstab, root_device, false) + it "tries to mount /var" do + expect(subject).to receive(:FsckAndMount).with("/var", var_spec, "") + subject.MountVarIfRequired(fstab, false) end include_examples "mounting result" end - context "that was mounted by kernel device name" do + context "and the LVM logical volume is not found in the system" do let(:root_spec) { "/dev/vg0/root" } - let(:root_device) { "/dev/vg0/root" } - context "and the LV is not longer there" do - let(:var_spec) { "/dev/vg0/none" } - let(:var_device) { "/dev/vg0/none" } + let(:var_spec) { "/dev/disk/by-uuid/not-found" } - it "tries to mount /var by its old device name" do - expect(subject).to receive(:FsckAndMount).with("/var", var_device, "") - subject.MountVarIfRequired(fstab, root_device, false) - end - - include_examples "mounting result" + it "does not try to mount /var" do + expect(subject).to_not receive(:FsckAndMount) + subject.MountVarIfRequired(fstab, false) end - context "and the LV is still there" do - let(:var_spec) { "/dev/vg0/var" } - let(:var_device) { "/dev/vg0/var" } - - it "tries to mount /var by its device name" do - expect(subject).to receive(:FsckAndMount).with("/var", var_device, "") - subject.MountVarIfRequired(fstab, root_device, false) - end - - include_examples "mounting result" + it "returns an error" do + expect(subject.MountVarIfRequired(fstab, false)) + .to match(/Unable to mount/) end end end
participants (1)
-
root