Skip to content

Commit

Permalink
Merge 2d048de into a3a00a9
Browse files Browse the repository at this point in the history
  • Loading branch information
lslezak committed Nov 7, 2019
2 parents a3a00a9 + 2d048de commit 304fabf
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 5 deletions.
6 changes: 6 additions & 0 deletions package/yast2-registration.changes
@@ -1,3 +1,9 @@
-------------------------------------------------------------------
Thu Nov 7 12:18:04 UTC 2019 - Ladislav Slezák <lslezak@suse.cz>

- Implement upgrade for Full medium (jsc#SLE-7101)
- 4.2.16

-------------------------------------------------------------------
Wed Oct 30 16:31:12 UTC 2019 - Josef Reidinger <jreidinger@suse.com>

Expand Down
2 changes: 1 addition & 1 deletion package/yast2-registration.spec
Expand Up @@ -17,7 +17,7 @@


Name: yast2-registration
Version: 4.2.15
Version: 4.2.16
Release: 0
Summary: YaST2 - Registration Module
License: GPL-2.0-only
Expand Down
63 changes: 59 additions & 4 deletions src/lib/registration/ui/migration_repos_workflow.rb
Expand Up @@ -12,9 +12,14 @@
# ------------------------------------------------------------------------------
#

require "pp"

require "yast"
require "yast2/popup"
require "y2packager/medium_type"
require "y2packager/product_location"
require "y2packager/product_upgrade"
require "y2packager/resolvable"

require "registration/registration"
require "registration/registration_ui"
Expand All @@ -41,6 +46,12 @@ class MigrationReposWorkflow < WizardClient
Yast.import "SourceDialogs"
Yast.import "Linuxrc"
Yast.import "Installation"
Yast.import "AddOnProduct"
Yast.import "InstURL"
Yast.import "Packages"
Yast.import "Pkg"
Yast.import "URL"
Yast.import "WorkflowManager"

# the constructor
def initialize
Expand Down Expand Up @@ -586,10 +597,17 @@ def explicit_media_upgrade
# implicit media upgrade for an unregistered system
def unregistered_media_upgrade
log.info "The system is NOT registered, activating the media based upgrade"
# we do not support registering the old system at upgrade, that must
# be done before the upgrade, skip registration in that case
Yast::Popup.LongMessage(unregistered_message)
prepare_media_upgrade

if Y2Packager::MediumType.offline?
# Add the Full medium base product repository
# TODO: move somewhere else?
add_offline_base_product
else
# we do not support registering the old system at upgrade, that must
# be done before the upgrade, skip registration in that case
Yast::Popup.LongMessage(unregistered_message)
prepare_media_upgrade
end
end

def prepare_media_upgrade
Expand All @@ -600,6 +618,43 @@ def prepare_media_upgrade
Yast::SourceDialogs.SetURL("dvd://")
end

def add_offline_base_product
# in offline upgrade add the repository with the selected base product
# FIXME: similar to clients/inst_complex_welcome.rb and widgets/product_selector.rb
url = Yast::InstURL.installInf2Url("")
base_products = Y2Packager::ProductLocation
.scan(url)
.select { |p| p.details && p.details.base }
log.info "Found base products on the offline medium: #{base_products.pretty_inspect}"

# find the installed base product
installed_base = Y2Packager::Resolvable.find(
kind: :product, status: :installed, type: "base"
).first
if !installed_base
log.error("Installed base product not found")
return
end

# FIXME: handle also the product renames
new_base = base_products.find { |p| p.details && p.details.product == installed_base.name }
if !new_base
log.error("New base product not found")
return
end

# FIXME: this is the same as in installation/widgets/product_selector.rb and other places
show_popup = true
log_url = Yast::URL.HidePassword(url)
Yast::Packages.Initialize_StageInitial(show_popup, url, log_url, new_base.dir)

# select the product to install
Yast::Pkg.ResolvableInstall(new_base.details && new_base.details.product, :product, "")
# initialize addons and the workflow manager
Yast::AddOnProduct.SetBaseProductURL(url)
Yast::WorkflowManager.SetBaseWorkflow(false)
end

# Informative message
# @return [String] translated message
def unregistered_message
Expand Down
1 change: 1 addition & 0 deletions test/migration_repos_workflow_spec.rb
Expand Up @@ -18,6 +18,7 @@
allow(Yast::Stage).to receive(:initial).and_return(false)
allow(Yast::Mode).to receive(:update).and_return(false)
allow(Yast::Linuxrc).to receive(:InstallInf)
allow(Y2Packager::MediumType).to receive(:offline?).and_return(false)
end

shared_examples "media based upgrade" do |popup_method|
Expand Down

0 comments on commit 304fabf

Please sign in to comment.