Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/SLE-15-SP5' into hpc_sp6
Browse files Browse the repository at this point in the history
  • Loading branch information
lslezak committed Mar 12, 2024
2 parents 33f13c0 + 512a07f commit d02e2a6
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 6 additions & 0 deletions package/yast2-registration.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
-------------------------------------------------------------------
Tue Mar 12 14:57:15 UTC 2024 - Ladislav Slezák <lslezak@suse.com>

- Use the new product mapping API (related to bsc#1220567)
- 4.6.1

-------------------------------------------------------------------
Fri Sep 01 19:57:03 UTC 2023 - Josef Reidinger <jreidinger@suse.com>

Expand Down
10 changes: 5 additions & 5 deletions package/yast2-registration.spec
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@


Name: yast2-registration
Version: 4.6.0
Version: 4.6.1
Release: 0
Summary: YaST2 - Registration Module
License: GPL-2.0-only
Expand All @@ -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
# new product mapping API
BuildRequires: yast2-packager >= 4.6.9
BuildRequires: yast2-update >= 3.1.36
# log.group call
BuildRequires: yast2-ruby-bindings >= 4.5.4
Expand All @@ -51,8 +51,8 @@ Requires: yast2-ruby-bindings >= 4.5.4
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
# new product mapping API
Requires: yast2-packager >= 4.6.9
Requires: yast2-update >= 3.1.36

# new calls in AutoinstGeneral
Expand Down
18 changes: 17 additions & 1 deletion src/lib/registration/ui/migration_repos_workflow.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down
21 changes: 21 additions & 0 deletions src/lib/registration/ui/migration_selection_dialog.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
require "registration/addon_sorter"
require "registration/sw_mgmt"
require "registration/url_helpers"
require "y2packager/product_upgrade"

module Registration
module UI
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions test/migration_selection_dialog_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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
Expand Down

0 comments on commit d02e2a6

Please sign in to comment.