From a34306ce876eea2e4b972bb0537c3ac71f7ec2d5 Mon Sep 17 00:00:00 2001
From: Josef Reidinger To avoid any loss of information during update,\n" \
- "create a backup prior to updating.
Warning: This will not be a complete\n" \ - "backup. Only modified files will be saved.
\n" + "backup. Only modified files will be saved.\n" ) ) @@ -110,7 +110,7 @@ def main @help_text, _( "Create a Backup of Modified Files:\n" \ - "Stores only those modified files that will be replaced during update.
\n" + "Stores only those modified files that will be replaced during update.\n" ) ) @@ -119,8 +119,8 @@ def main @help_text, _( "Create a Complete Backup of\n" \ - "/etc/sysconfig: This covers all configuration files that are part of the\n" \ - "sysconfig mechanism, even those that will not be replaced.
\n" + "/etc/sysconfig: This covers all configuration files that are part of the\n" \ + "sysconfig mechanism, even those that will not be replaced.\n" ) ) @@ -129,9 +129,9 @@ def main @help_text, _( "Remove Old Backups from the Backup\n" \ - "Directory: If your current system already is the result of an earlier\n" \ - "update, there may be old configuration file backups. Select this option to\n" \ - "remove them.
\n" + "Directory: If your current system already is the result of an earlier\n" \ + "update, there may be old configuration file backups. Select this option to\n" \ + "remove them.\n" ) ) diff --git a/src/clients/packages_proposal.rb b/src/clients/packages_proposal.rb index 0132c574..f0cd899e 100644 --- a/src/clients/packages_proposal.rb +++ b/src/clients/packages_proposal.rb @@ -288,7 +288,7 @@ def orphaned_packages_summary(packages) if packages.size > ORPHANED_MAX_SIZE # TRANSLATORS: %s is replaced by a number of remaining items - summary << _("... and %s more") % (packages.size - ORPHANED_MAX_SIZE) + summary << (_("... and %s more") % (packages.size - ORPHANED_MAX_SIZE)) end summary diff --git a/src/clients/update_proposal.rb b/src/clients/update_proposal.rb index 1f6570c7..b0ca7268 100644 --- a/src/clients/update_proposal.rb +++ b/src/clients/update_proposal.rb @@ -147,9 +147,9 @@ def main # %2 is the version being installed _( "Updating system to another version (%1 -> %2) is not supported on " \ - "the running system.Update Options Select how your system will be updated.\n" \ - "Choose if only installed packages should be updated or new ones should be\n" \ - "installed as well (default). Decide whether unmaintained packages should be\n" \ - "deleted.
\n" + "Choose if only installed packages should be updated or new ones should be\n" \ + "installed as well (default). Decide whether unmaintained packages should be\n" \ + "deleted.\n" ) @ret = { @@ -474,9 +474,9 @@ def init_stuff Update.solve_errors = Pkg.PkgSolve(false) ? 0 : Pkg.PkgSolveErrors log.info "Update compatibility: " \ - "Update.ProductsCompatible: #{Update.ProductsCompatible}, " \ - "Update.products_incompatible: #{Update.products_incompatible}, " \ - "update_not_possible: #{update_not_possible}" + "Update.ProductsCompatible: #{Update.ProductsCompatible}, " \ + "Update.products_incompatible: #{Update.products_incompatible}, " \ + "update_not_possible: #{update_not_possible}" # check product compatibility if !(Update.ProductsCompatible || Update.products_incompatible) || update_not_possible @@ -484,9 +484,9 @@ def init_stuff # TRANSLATORS: continue-cancel popup _( "The installed product is not compatible with the product\n" \ - "on the installation media. If you try to update using the\n" \ - "current installation media, the system may not start or\n" \ - "some applications may not run properly." + "on the installation media. If you try to update using the\n" \ + "current installation media, the system may not start or\n" \ + "some applications may not run properly." ) ) Update.IgnoreProductCompatibility diff --git a/src/include/update/rootpart.rb b/src/include/update/rootpart.rb index 7a9ce65a..c6890a4c 100644 --- a/src/include/update/rootpart.rb +++ b/src/include/update/rootpart.rb @@ -107,7 +107,7 @@ def make_partition_list(withall, flavor) # see bugzilla #288201 # architecture needs to be valid when updating, not booting arch_is_valid = flavor == :boot || Ops.get_boolean(i, :arch_valid, false) - if withall || Ops.get_boolean(i, :valid, false) && arch_is_valid + if withall || (Ops.get_boolean(i, :valid, false) && arch_is_valid) # `ext2, `jfs, ... part_fs = Ops.get_symbol(i, :fs) part_fs_name = Builtins.tostring(part_fs) @@ -211,8 +211,8 @@ def RootPartitionDialog(flavor) # TRANSLATORS: help text for root partition dialog (for boot) help_text = _( "\n" \ - "Select the partition or system to boot.\n" \ - "
\n" + "Select the partition or system to boot.\n" \ + "\n" ) else # TRANSLATORS: label for selection of root partition (for update) @@ -221,8 +221,8 @@ def RootPartitionDialog(flavor) # TRANSLATORS: help text for root partition dialog (for update) help_text = _( "\n" \ - "Select the partition or system to update.\n" \ - "
\n" + "Select the partition or system to update.\n" \ + "\n" ) if flavor == :update_dialog || flavor == :update_dialog_proposal @@ -236,9 +236,9 @@ def RootPartitionDialog(flavor) help_text, _( "\n" \ - "Show All Partitions expands the list to a\n" \ - "general overview of your system's partitions.\n" \ - "
\n" + "Show All Partitions expands the list to a\n" \ + "general overview of your system's partitions.\n" \ + "\n" ) ) @@ -374,15 +374,15 @@ def RootPartitionDialog(flavor) cont = false # TRANSLATORS: error message Report.Error(_("ReiserFS is not supported anymore.\n" \ - "Please migrate your data to another " \ - "filesystem before performing the upgrade.\n\n")) + "Please migrate your data to another " \ + "filesystem before performing the upgrade.\n\n")) elsif (freshman[:name] || "unknown") == "unknown" cont = false Popup.Error( # TRANSLATORS: error popup _( "No installed system that can be upgraded with this product was found\n" \ - "on the selected partition." + "on the selected partition." ) ) elsif !DoArchitecturesMatch( @@ -393,7 +393,7 @@ def RootPartitionDialog(flavor) # TRANSLATORS: continue-cancel popup _( "The architecture of the system installed in the selected partition\n " \ - "is different from the one of this product.\n" + "is different from the one of this product.\n" ) ) end @@ -424,7 +424,7 @@ def RootPartitionDialog(flavor) # TRANSLATORS: pop-up question _( "A possibly incomplete installation has been detected on the selected " \ - "partition.\nAre sure you want to use it anyway?" + "partition.\nAre sure you want to use it anyway?" ), # TRANSLATORS: button label _("&Yes, Use It"), @@ -475,9 +475,9 @@ def RootPartitionDialog(flavor) # TRANSLATORS: error message _( "Initializing the system for upgrade has failed for unknown reason.\n" \ - "It is highly recommended not to continue the upgrade process.\n" \ - "\n" \ - "Are you sure you want to continue?" + "It is highly recommended not to continue the upgrade process.\n" \ + "\n" \ + "Are you sure you want to continue?" ), # TRANSLATORS: button label _("&Yes, Continue"), @@ -493,30 +493,27 @@ def RootPartitionDialog(flavor) end # not aborted - if ret != :back - # Target load failed, #466803 - if Pkg.TargetLoad != true - Builtins.y2error("Pkg::TargetLoad failed") - if Popup.AnyQuestion( - Label.ErrorMsg, - # TRANSLATORS: error message - _( - "Initializing the system for upgrade has failed for unknown reason.\n" \ - "It is highly recommended not to continue the upgrade process.\n" \ - "\n" \ - "Are you sure you want to continue?" - ), - # TRANSLATORS: button label - _("&Yes, Continue"), - Label.CancelButton, - :focus_no + if ret != :back && (Pkg.TargetLoad != true) + Builtins.y2error("Pkg::TargetLoad failed") + if Popup.AnyQuestion( + Label.ErrorMsg, + # TRANSLATORS: error message + _( + "Initializing the system for upgrade has failed for unknown reason.\n" \ + "It is highly recommended not to continue the upgrade process.\n" \ + "\n" \ + "Are you sure you want to continue?" + ), + # TRANSLATORS: button label + _("&Yes, Continue"), + Label.CancelButton, + :focus_no + ) + ret = :back + else + Builtins.y2warning( + "User decided to continue despite the error above (Pkg::TargetLoad() failed)" ) - ret = :back - else - Builtins.y2warning( - "User decided to continue despite the error above (Pkg::TargetLoad() failed)" - ) - end end end diff --git a/src/modules/RootPart.rb b/src/modules/RootPart.rb index b82e1d7c..355f1c6a 100644 --- a/src/modules/RootPart.rb +++ b/src/modules/RootPart.rb @@ -197,10 +197,10 @@ def UnmountPartitions(keep_in_target) Builtins.sformat( _( "Cannot unmount partition %1.\n" \ - "\n" \ - "It is currently in use. If the partition stays mounted,\n" \ - "the data may be lost. Unmount the partition manually\n" \ - "or restart your computer.\n" + "\n" \ + "It is currently in use. If the partition stays mounted,\n" \ + "the data may be lost. Unmount the partition manually\n" \ + "or restart your computer.\n" ), file ) @@ -395,7 +395,15 @@ def RunFSCKonJFS(mount_type, device, error_message) UI.CloseDialog # failed - if Ops.get(cmd, "exit") != 0 + if Ops.get(cmd, "exit") == 0 + # add device into the list of already checked partitions (with exit status 0); + @already_checked_jfs_partitions = Builtins.add( + @already_checked_jfs_partitions, + device + ) + Builtins.y2milestone("Result: %1", cmd) + return true + else Builtins.y2error("Result: %1", cmd) error_message.value = Builtins.tostring(Ops.get(cmd, "stderr")) @@ -418,8 +426,8 @@ def RunFSCKonJFS(mount_type, device, error_message) # %1 is a device name such as /dev/hda5 _( "The file system check of device %1 has failed.\n" \ - "\n" \ - "Do you want to continue mounting the device?\n" + "\n" \ + "Do you want to continue mounting the device?\n" ), device ), @@ -429,14 +437,6 @@ def RunFSCKonJFS(mount_type, device, error_message) details ) # succeeded - else - # add device into the list of already checked partitions (with exit status 0); - @already_checked_jfs_partitions = Builtins.add( - @already_checked_jfs_partitions, - device - ) - Builtins.y2milestone("Result: %1", cmd) - return true end end @@ -595,7 +595,7 @@ def readFsTab(fstab) fstab_file = Ops.add(Installation.destdir, "/etc/fstab") if FileUtils.Exists(fstab_file) - # Note: this is a copy from etc_fstab.scr file (yast2.rpm), + # NOTE: this is a copy from etc_fstab.scr file (yast2.rpm), # keep the files in sync! SCR.RegisterAgent( path(".target.etc.fstab"), @@ -705,15 +705,15 @@ def CheckBootSize(_bootpart) SCR.Execute(path(".target.bash_output"), cmd) ) - if Ops.get_integer(bootsizeout, "exit", -1) != 0 - Builtins.y2error("Error: '%1' -> %2", cmd, bootsizeout) - else + if Ops.get_integer(bootsizeout, "exit", -1) == 0 scriptout = Builtins.splitstring( Ops.get_string(bootsizeout, "stdout", ""), " " ) Builtins.y2milestone("Scriptout: %1", scriptout) bootsize = Builtins.tointeger(Ops.get(scriptout, 1, "0")) + else + Builtins.y2error("Error: '%1' -> %2", cmd, bootsizeout) end if bootsize.nil? || bootsize == 0 @@ -745,11 +745,11 @@ def CheckBootSize(_bootpart) Builtins.sformat( _( "Your /boot partition is too small (%1 MB).\n" \ - "We recommend a size of no less than %2 MB or else the new Kernel may not fit.\n" \ - "It is safer to either enlarge the partition\n" \ - "or not use a /boot partition at all.\n" \ - "\n" \ - "Do you want to continue updating the current system?\n" + "We recommend a size of no less than %2 MB or else the new Kernel may not fit.\n" \ + "It is safer to either enlarge the partition\n" \ + "or not use a /boot partition at all.\n" \ + "\n" \ + "Do you want to continue updating the current system?\n" ), current_bs, suggested_bs @@ -760,12 +760,12 @@ def CheckBootSize(_bootpart) Builtins.y2warning( "User decided to continue despite small a /boot partition" ) - return true + true else Builtins.y2milestone( "User decided not to continue with small /boot partition" ) - return false + false end end @@ -858,9 +858,7 @@ def MountFSTab(fstab, _message) end end - if fspath == "/boot" || fspath == "/boot/" - success = false unless CheckBootSize(spec) - end + success = false if (fspath == "/boot" || fspath == "/boot/") && !CheckBootSize(spec) elsif vfstype == "swap" && fspath == "swap" log.info("mounting #{spec} to #{fspath}") @@ -873,10 +871,10 @@ def MountFSTab(fstab, _message) ret_from_shell = Convert.to_integer( SCR.Execute(path(".target.bash"), command) ) - if ret_from_shell != 0 - log.error("swapon failed: #{command}") - else + if ret_from_shell == 0 AddMountedPartition(type: "swap", device: spec) + else + log.error("swapon failed: #{command}") end end end @@ -909,13 +907,13 @@ def mount_failed_action(spec, error) # %2 is output of the 'mount' command _( "The partition %1 could not be mounted.\n" \ - "\n" \ - "%2\n" \ - "\n" \ - "If you are sure that the partition is not necessary for the\n" \ - "update (not a system partition), click Continue.\n" \ - "To check or fix the mount options, click Specify Mount Options.\n" \ - "To abort the update, click Cancel.\n" + "\n" \ + "%2\n" \ + "\n" \ + "If you are sure that the partition is not necessary for the\n" \ + "update (not a system partition), click Continue.\n" \ + "To check or fix the mount options, click Specify Mount Options.\n" \ + "To abort the update, click Cancel.\n" ), spec, error @@ -1012,8 +1010,8 @@ def MountPartitions(root_device_current) message = Builtins.sformat( _( "Partitions could not be mounted.\n" \ - "\n" \ - "Check the log file %1." + "\n" \ + "Check the log file %1." ), Ops.add(Directory.logdir, "/y2log") ) @@ -1063,9 +1061,9 @@ def MountPartitions(root_device_current) # TRANSLATORS: warning popup _( "Some partitions in the system on %1 are mounted by kernel-device name. This is\n" \ - "not reliable for the update since kernel-device names are unfortunately not\n" \ - "persistent. It is strongly recommended to start the old system and change the\n" \ - "mount-by method to any other method for all partitions." + "not reliable for the update since kernel-device names are unfortunately not\n" \ + "persistent. It is strongly recommended to start the old system and change the\n" \ + "mount-by method to any other method for all partitions." ), root_device_current ) @@ -1081,12 +1079,12 @@ def MountPartitions(root_device_current) # TRANSLATORS: warning popup _( "Some home directories in the system on %1 are encrypted. This release does not\n" \ - "support cryptconfig any longer and those home directories " \ - "will not be accessible\n" \ - "after upgrade. In order to access these home directories, " \ - "they need to be decrypted\n" \ - "before performing upgrade.\n" \ - "You can consider encrypting whole volume via LUKS." + "support cryptconfig any longer and those home directories " \ + "will not be accessible\n" \ + "after upgrade. In order to access these home directories, " \ + "they need to be decrypted\n" \ + "before performing upgrade.\n" \ + "You can consider encrypting whole volume via LUKS." ), root_device_current ) @@ -1101,29 +1099,15 @@ def MountPartitions(root_device_current) else tmp = "" - if !( - tmp_ref = arg_ref(tmp) - check_root_device_result = check_root_device( - root_device_current, - fstab, - tmp_ref - ) - tmp = tmp_ref.value - check_root_device_result - ) - Builtins.y2error("fstab has wrong root device!") - - # 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 + if tmp_ref = arg_ref(tmp) + check_root_device_result = check_root_device( + root_device_current, + fstab, + tmp_ref ) + tmp = tmp_ref.value + check_root_device_result - success = false - else Builtins.y2milestone("fstab %1", fstab) legacy_filesystems = @@ -1152,6 +1136,19 @@ def MountPartitions(root_device_current) ) success = false end + else + Builtins.y2error("fstab has wrong root device!") + + # 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 end end else @@ -1170,19 +1167,19 @@ def MountPartitions(root_device_current) ) Builtins.y2milestone("activated %1", @activated) - if !success - Popup.Message(message) - - # some mount failed, unmount all mounted fs - UnmountPartitions(false) - @did_try_mount_partitions = true - else + if success # enter the mount points of the newly mounted partitions update_staging! create_pre_snapshot Update.clean_backup create_backup inject_intsys_files + else + Popup.Message(message) + + # some mount failed, unmount all mounted fs + UnmountPartitions(false) + @did_try_mount_partitions = true end success @@ -1479,7 +1476,7 @@ def FindRootPartitions filesystems.each_with_index do |fs, counter| if UI.WidgetExists(Id("search_progress")) - percent = 100 * (counter + 1 / filesystems.size) + percent = 100 * (counter + (1 / filesystems.size)) UI.ChangeWidget(Id("search_pb"), :Value, percent) end @@ -1578,7 +1575,7 @@ def load_saved(data) publish function: :SetSelectedToValid, type: "void ()" publish function: :UnmountPartitions, type: "void (boolean)" publish function: :AnyQuestionAnyButtonsDetails, - type: "boolean (string, string, string, string, string)" + type: "boolean (string, string, string, string, string)" publish function: :MountPartitions, type: "boolean (string)" publish function: :IncompleteInstallationDetected, type: "boolean (string)" publish function: :FindRootPartitions, type: "void ()" @@ -1717,8 +1714,8 @@ def fs_by_devicename(devicegraph, device_spec) # log which devicegraph we operate on graph = "?" - graph = "probed" if devicegraph.object_id == probed.object_id - if devicegraph.object_id == staging.object_id + graph = "probed" if devicegraph.equal?(probed) + if devicegraph.equal?(staging) graph = "staging#" + Y2Storage::StorageManager.instance.staging_revision.to_s end log.info("fs_by_devicename(#{graph}, #{device_spec}) = #{"sid#" + fs.sid.to_s if fs}") diff --git a/src/modules/SUSERelease.rb b/src/modules/SUSERelease.rb index f92613a2..5012aa6b 100644 --- a/src/modules/SUSERelease.rb +++ b/src/modules/SUSERelease.rb @@ -80,7 +80,7 @@ def ReleaseInformation(base_dir = "/") # Removes all unneeded stuff such as architecture or product nickname def shorten(long_name) - long_name.gsub(/[ ]*\(.*/, "") + long_name.gsub(/ *\(.*/, "") end publish function: :ReleaseInformation, type: "string (string)" diff --git a/src/modules/Update.rb b/src/modules/Update.rb index 389ea3ac..70adf191 100644 --- a/src/modules/Update.rb +++ b/src/modules/Update.rb @@ -947,7 +947,7 @@ def create_tarball(tarball_path, root, paths) command = "tar cv -C '#{root}'" # no shell escaping here, but we backup reasonable files and want to allow globs - command << " " + paths_without_prefix.join(" ") + command << (" " + paths_without_prefix.join(" ")) # use parallel gzip for faster compression (uses all available CPU cores) command << " | pigz - > '#{tarball_path}'" res = SCR.Execute(path(".target.bash_output"), command) @@ -997,7 +997,7 @@ def installed_desktop if !FileUtils.Exists(windowmanager_sysconfig) log.warn "Sysconfig file #{windowmanager_sysconfig} does not exist, " \ - "desktop upgrade will not be handled" + "desktop upgrade will not be handled" return nil end diff --git a/test/update_test.rb b/test/update_test.rb index 608b6541..9d0bc74e 100755 --- a/test/update_test.rb +++ b/test/update_test.rb @@ -53,7 +53,7 @@ def default_SetDesktopPattern_stubs end it "returns product name from SUSE-release if os-release is missing and " \ - "SUSE-release exists in Installation.destdir" do + "SUSE-release exists in Installation.destdir" do allow(Yast::Installation).to receive(:destdir) .and_return(File.join(DATA_DIR, "update-test-2")) expect(Yast::Update.installed_product).to eq("SUSE Linux Enterprise Server 11") @@ -251,7 +251,7 @@ def default_SetDesktopPattern_stubs it "logs info and error" do expect(Yast::Update.log).to receive(:info) .with("Version expected: opensuse-leap-15.0. " \ - "Backup version: opensuse-tumbleweed-20180911") + "Backup version: opensuse-tumbleweed-20180911") .and_call_original expect(Yast::Update.log).to receive(:error).with(/not restored/).and_call_original @@ -284,7 +284,7 @@ def default_SetDesktopPattern_stubs end context "if there is no windowmanager sysconfig file present " \ - "on the system selected for upgrade" do + "on the system selected for upgrade" do it "returns true as there is nothing to do" do default_product_control_desktop allow(Yast::FileUtils).to receive(:Exists).with(/windowmanager/).and_return(false) @@ -425,10 +425,10 @@ def default_SetDesktopPattern_stubs allow(Yast::ProductFeatures).to receive(:GetFeature) .with("software", "upgrade") .and_return("product_upgrades" => [{ - "from" => "openSUSE", - "to" => "SLES", - "compatible_vendors" => ["openSUSE", "SLES LCC"] - }]) + "from" => "openSUSE", + "to" => "SLES", + "compatible_vendors" => ["openSUSE", "SLES LCC"] + }]) end it "does not set compatible vendors at all" do @@ -443,9 +443,9 @@ def default_SetDesktopPattern_stubs allow(Yast::ProductFeatures).to receive(:GetFeature) .with("software", "upgrade") .and_return("product_upgrades" => [{ - "from" => "openSUSE Leap", - "to" => "openSUSE Jump" - }]) + "from" => "openSUSE Leap", + "to" => "openSUSE Jump" + }]) end it "does not set compatible vendors at all" do @@ -459,10 +459,10 @@ def default_SetDesktopPattern_stubs allow(Yast::ProductFeatures).to receive(:GetFeature) .with("software", "upgrade") .and_return("product_upgrades" => [{ - "from" => "openSUSE Leap", - "to" => "openSUSE Jump", - "compatible_vendors" => ["openSUSE", "SLES LCC"] - }]) + "from" => "openSUSE Leap", + "to" => "openSUSE Jump", + "compatible_vendors" => ["openSUSE", "SLES LCC"] + }]) end it "set it in the solver" do From 6a28d3205df014f515bba583ebaf078269d149b8 Mon Sep 17 00:00:00 2001 From: Josef Reidinger