diff --git a/.rubocop.yml b/.rubocop.yml index 8e2cc674..8c1b9c81 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -18,7 +18,7 @@ Metrics/BlockNesting: # TODO: this need some non-trivial refactoring... Metrics/ClassLength: - Max: 480 + Max: 490 # TODO: this need some non-trivial refactoring... Metrics/CyclomaticComplexity: diff --git a/package/yast2-registration.changes b/package/yast2-registration.changes index 388af2a1..0f1d911e 100644 --- a/package/yast2-registration.changes +++ b/package/yast2-registration.changes @@ -1,3 +1,11 @@ +------------------------------------------------------------------- +Mon Mar 11 08:09:33 UTC 2024 - Ladislav Slezák + +- Set the new product mapping when upgrading SLE_HPC to SLES SP6+ + (with the HPC module), use the old product mapping when upgrading + from SLE_HPC-SP3 to SLE_HPC-SP4 (bsc#1220567) +- 4.4.24 + ------------------------------------------------------------------- Wed Oct 19 08:13:54 UTC 2022 - José Iván López González diff --git a/package/yast2-registration.spec b/package/yast2-registration.spec index 9eae6291..9b152896 100644 --- a/package/yast2-registration.spec +++ b/package/yast2-registration.spec @@ -17,7 +17,7 @@ Name: yast2-registration -Version: 4.4.23 +Version: 4.4.24 Release: 0 Summary: YaST2 - Registration Module License: GPL-2.0-only @@ -35,8 +35,8 @@ BuildRequires: rubygem(%{rb_default_ruby_abi}:rspec) BuildRequires: rubygem(%{rb_default_ruby_abi}:yast-rake) >= 0.2.5 # uses Fiddle instead of FFI BuildRequires: suseconnect-ruby-bindings > 0.0.4 -# ProductSpec API -BuildRequires: yast2-packager >= 4.4.13 +# support upgrade from SLEHPC to SLES + HPC in SP6+ +BuildRequires: yast2-packager >= 4.4.35 BuildRequires: yast2-update >= 3.1.36 # yast/rspec/helpers.rb BuildRequires: yast2-ruby-bindings >= 4.4.7 @@ -51,8 +51,8 @@ Requires: yast2-ruby-bindings >= 3.1.12 Requires: suseconnect-ruby-bindings > 0.0.4 Requires: yast2-add-on >= 3.1.8 Requires: yast2-slp >= 3.1.9 -# ProductSpec API -Requires: yast2-packager >= 4.4.13 +# support upgrade from SLEHPC to SLES + HPC in SP6+ +Requires: yast2-packager >= 4.4.35 Requires: yast2-update >= 3.1.36 # new calls in AutoinstGeneral diff --git a/src/lib/registration/ui/migration_repos_workflow.rb b/src/lib/registration/ui/migration_repos_workflow.rb index 3d611f92..2b83d5df 100644 --- a/src/lib/registration/ui/migration_repos_workflow.rb +++ b/src/lib/registration/ui/migration_repos_workflow.rb @@ -688,6 +688,22 @@ def full_medium_products products = Y2Packager::ProductSpec.base_products .select { |p| p.is_a?(Y2Packager::RepoProductSpec) } log.info("Found base products on the offline medium: #{products.pretty_inspect}") + + new_migration = products.any? do |p| + next false unless p.name == "SLES" || p.name == "SLE_HPC" + + version = p.version.split(".") + major = version[0].to_i + minor = version[1].to_i + + # SLE15-SP6 or newer + major > 15 || (major == 15 && minor >= 6) + end + + log.info "Using SP6+ product upgrade mapping: #{new_migration}" + Y2Packager::ProductUpgrade.new_renames = new_migration + Yast::AddOnProduct.new_renames = new_migration + products end @@ -706,7 +722,7 @@ def full_medium_upgrade_product(installed_base) # first check if there is a product rename defined for the installed products # and the new renamed base product is available # key in the mapping: list of installed products, value: the new base product - Y2Packager::ProductUpgrade::MAPPING.each do |k, v| + Y2Packager::ProductUpgrade.mapping.each do |k, v| if (k - installed_names).empty? new_base = base_products.find { |p| p.name == v } end diff --git a/src/lib/registration/ui/migration_selection_dialog.rb b/src/lib/registration/ui/migration_selection_dialog.rb index 027ea87b..468249cc 100644 --- a/src/lib/registration/ui/migration_selection_dialog.rb +++ b/src/lib/registration/ui/migration_selection_dialog.rb @@ -18,6 +18,7 @@ require "registration/addon_sorter" require "registration/sw_mgmt" require "registration/url_helpers" +require "y2packager/product_upgrade" module Registration module UI @@ -212,9 +213,28 @@ def update_details selected = Yast::UI.QueryWidget(:migration_targets, :CurrentItem) return unless selected + update_product_mapping Yast::UI.ChangeWidget(Id(:details), :Value, migration_details(selected)) end + # helper method to update the product mapping in Y2Packager::ProductUpgrade + def update_product_mapping + new_migration = current_migration.any? do |p| + next false unless p.identifier == "SLES" || p.identifier == "SLE_HPC" + + version = p.version.split(".") + major = version[0].to_i + minor = version[1].to_i + + # SLE15-SP6 or newer + major > 15 || (major == 15 && minor >= 6) + end + + log.info "Using SP6+ product upgrade mapping: #{new_migration}" + Y2Packager::ProductUpgrade.new_renames = new_migration + Yast::AddOnProduct.new_renames = new_migration + end + # get migration details # @param [Integer] idx migration index # @return [String] user friendly description (in RichText format) @@ -339,6 +359,7 @@ def product_change_summary(old_product, new_product) # store the current UI values def store_values + update_product_mapping self.selected_migration = current_migration self.manual_repo_selection = Yast::UI.QueryWidget(:manual_repos, :Value) end diff --git a/test/migration_selection_dialog_test.rb b/test/migration_selection_dialog_test.rb index 30529465..0b1de788 100644 --- a/test/migration_selection_dialog_test.rb +++ b/test/migration_selection_dialog_test.rb @@ -33,7 +33,8 @@ allow(Yast::UI).to receive(:UserInput).and_return(:abort) allow(Yast::Wizard).to receive(:SetContents) # the first migration is selected - expect(Yast::UI).to receive(:QueryWidget).with(:migration_targets, :CurrentItem).and_return(0) + expect(Yast::UI).to receive(:QueryWidget).with(:migration_targets, :CurrentItem) + .and_return(0).twice # check the correct summary expect(Yast::UI).to receive(:ChangeWidget) do |_id, _attr, text| # SLES11 uses "SUSE_SLES" product identifier while SLES15 uses just "SLES", @@ -53,7 +54,8 @@ allow(Yast::UI).to receive(:UserInput).and_return(:abort) allow(Yast::Wizard).to receive(:SetContents) # the first migration is selected - expect(Yast::UI).to receive(:QueryWidget).with(:migration_targets, :CurrentItem).and_return(0) + expect(Yast::UI).to receive(:QueryWidget).with(:migration_targets, :CurrentItem) + .and_return(0).twice # check the correct summary expect(Yast::UI).to receive(:ChangeWidget) do |_id, _attr, text| # For SLE15 there are two products (SDK and Toolchain Module) replaced