Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SLE15-SP4] Set the upgrade product mapping depending on the target version (bsc#1220567) #596

Merged
merged 1 commit into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
8 changes: 8 additions & 0 deletions package/yast2-registration.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
-------------------------------------------------------------------
Mon Mar 11 08:09:33 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.4.24

-------------------------------------------------------------------
Wed Oct 19 08:13:54 UTC 2022 - José Iván López González <jlopez@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.4.23
Version: 4.4.24
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
# 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
Expand All @@ -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
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
Loading