Skip to content

Commit

Permalink
Set the upgrade product mapping depending on the target version (bsc#…
Browse files Browse the repository at this point in the history
…1220567)

- use 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
- 4.3.28
  • Loading branch information
lslezak committed Mar 12, 2024
1 parent d7b7d2f commit a3232c4
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .rubocop.yml
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
8 changes: 8 additions & 0 deletions package/yast2-registration.changes
@@ -1,3 +1,11 @@
-------------------------------------------------------------------
Mon Mar 11 16:14:22 UTC 2024 - Ladislav Slezák <lslezak@suse.com>

- 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.3.29

-------------------------------------------------------------------
Wed Nov 22 12:41:01 UTC 2023 - Stefan Hundhammer <shundhammer@suse.com>

Expand Down
18 changes: 9 additions & 9 deletions package/yast2-registration.spec
Expand Up @@ -17,7 +17,7 @@


Name: yast2-registration
Version: 4.3.28
Version: 4.3.29
Release: 0
Summary: YaST2 - Registration Module
License: GPL-2.0-only
Expand All @@ -27,20 +27,20 @@ Url: https://github.com/yast/yast-registration
Source0: %{name}-%{version}.tar.bz2

BuildRequires: update-desktop-files
# Popup::SuppressFeedback
BuildRequires: yast2 >= 4.2.76
# support upgrade from SLEHPC to SLES + HPC in SP6+
BuildRequires: yast2 >= 4.3.70
BuildRequires: yast2-devtools >= 4.2.2
BuildRequires: yast2-slp >= 3.1.9
BuildRequires: rubygem(%{rb_default_ruby_abi}:rspec)
BuildRequires: rubygem(%{rb_default_ruby_abi}:yast-rake) >= 0.2.5
# new suseconnect-ng
BuildRequires: suseconnect-ruby-bindings >= 1.2.0
# Y2Packager::MediumType.type=
BuildRequires: yast2-packager >= 4.2.37
# support upgrade from SLEHPC to SLES + HPC in SP6+
BuildRequires: yast2-packager >= 4.3.27
BuildRequires: yast2-update >= 3.1.36

# Popup::SuppressFeedback
Requires: yast2 >= 4.2.76
# support upgrade from SLEHPC to SLES + HPC in SP6+
Requires: yast2 >= 4.3.70
# "dupAllowVendorChange" option in Pkg.SetSolverFlags()
Requires: yast2-pkg-bindings >= 3.1.34
# N_() method
Expand All @@ -49,8 +49,8 @@ Requires: yast2-ruby-bindings >= 3.1.12
Requires: suseconnect-ruby-bindings >= 1.2.0
Requires: yast2-add-on >= 3.1.8
Requires: yast2-slp >= 3.1.9
# Y2Packager::MediumType
Requires: yast2-packager >= 4.2.27
# support upgrade from SLEHPC to SLES + HPC in SP6+
Requires: yast2-packager >= 4.3.27
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
Expand Up @@ -689,6 +689,22 @@ def full_medium_products
.scan(url)
.select { |p| p.details && p.details.base }
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 @@ -707,7 +723,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.details && p.details.product == v }
end
Expand Down
21 changes: 21 additions & 0 deletions src/lib/registration/ui/migration_selection_dialog.rb
Expand Up @@ -15,6 +15,7 @@
require "cgi/util"

require "yast"
require "y2packager/product_upgrade"
require "registration/addon_sorter"
require "registration/sw_mgmt"
require "registration/url_helpers"
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
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 a3232c4

Please sign in to comment.