Skip to content

Commit

Permalink
Full medium upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
lslezak committed Nov 7, 2019
1 parent a3a00a9 commit 8846459
Showing 1 changed file with 53 additions and 1 deletion.
54 changes: 53 additions & 1 deletion 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 @@ -588,8 +599,11 @@ 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)
# do not display that when using the Full medium, not registered system
# is expected there
Yast::Popup.LongMessage(unregistered_message) unless Y2Packager::MediumType.offline?
prepare_media_upgrade
add_offline_base_product
end

def prepare_media_upgrade
Expand All @@ -600,6 +614,44 @@ 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

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

0 comments on commit 8846459

Please sign in to comment.