From 2d048dec709c31dd27088136351023f9a5a2f3ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ladislav=20Slez=C3=A1k?= Date: Wed, 6 Nov 2019 18:09:16 +0100 Subject: [PATCH] Implement upgrade for Full medium (jsc#SLE-7101) - 4.2.16 --- package/yast2-registration.changes | 6 ++ package/yast2-registration.spec | 2 +- .../ui/migration_repos_workflow.rb | 63 +++++++++++++++++-- test/migration_repos_workflow_spec.rb | 1 + 4 files changed, 67 insertions(+), 5 deletions(-) diff --git a/package/yast2-registration.changes b/package/yast2-registration.changes index 18659699f..4f34648ff 100644 --- a/package/yast2-registration.changes +++ b/package/yast2-registration.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Thu Nov 7 12:18:04 UTC 2019 - Ladislav Slezák + +- Implement upgrade for Full medium (jsc#SLE-7101) +- 4.2.16 + ------------------------------------------------------------------- Wed Oct 30 16:31:12 UTC 2019 - Josef Reidinger diff --git a/package/yast2-registration.spec b/package/yast2-registration.spec index 1524be668..4746e1970 100644 --- a/package/yast2-registration.spec +++ b/package/yast2-registration.spec @@ -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 diff --git a/src/lib/registration/ui/migration_repos_workflow.rb b/src/lib/registration/ui/migration_repos_workflow.rb index fc061f8b1..53c1c689a 100644 --- a/src/lib/registration/ui/migration_repos_workflow.rb +++ b/src/lib/registration/ui/migration_repos_workflow.rb @@ -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" @@ -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 @@ -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 @@ -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 diff --git a/test/migration_repos_workflow_spec.rb b/test/migration_repos_workflow_spec.rb index 2671fd4ba..1324e538d 100644 --- a/test/migration_repos_workflow_spec.rb +++ b/test/migration_repos_workflow_spec.rb @@ -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|