Hello community,
here is the log from the commit of package yast2-registration for
openSUSE:Leap:15.2 checked in at 2020-01-17 11:59:04
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Leap:15.2/yast2-registration (Old)
and /work/SRC/openSUSE:Leap:15.2/.yast2-registration.new.26092 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "yast2-registration"
Fri Jan 17 11:59:04 2020 rev:146 rq:764560 version:4.2.25
Changes:
--------
--- /work/SRC/openSUSE:Leap:15.2/yast2-registration/yast2-registration.changes
2020-01-15 16:32:19.960882708 +0100
+++
/work/SRC/openSUSE:Leap:15.2/.yast2-registration.new.26092/yast2-registration.changes
2020-01-17 11:59:07.292442798 +0100
@@ -1,0 +2,14 @@
+Tue Jan 14 15:04:15 UTC 2020 - Josef Reidinger <[email protected]>
+
+- fix crash in autoyast registration (bsc#1160909)
+- 4.2.25
+
+-------------------------------------------------------------------
+Fri Jan 10 14:16:55 UTC 2020 - Ladislav Slezák <[email protected]>
+
+- Load the old repositories before running the migration
+ so the code can properly detect the old and the new repositories
+ and remove the obsoleted services from the system (bsc#1159433)
+- 4.2.24
+
+-------------------------------------------------------------------
Old:
----
yast2-registration-4.2.23.tar.bz2
New:
----
yast2-registration-4.2.25.tar.bz2
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ yast2-registration.spec ++++++
--- /var/tmp/diff_new_pack.WMYnec/_old 2020-01-17 11:59:07.804443024 +0100
+++ /var/tmp/diff_new_pack.WMYnec/_new 2020-01-17 11:59:07.808443025 +0100
@@ -1,7 +1,7 @@
#
# spec file for package yast2-registration
#
-# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2020 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -17,7 +17,7 @@
Name: yast2-registration
-Version: 4.2.23
+Version: 4.2.25
Release: 0
Summary: YaST2 - Registration Module
License: GPL-2.0-only
++++++ yast2-registration-4.2.23.tar.bz2 -> yast2-registration-4.2.25.tar.bz2
++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/yast2-registration-4.2.23/package/yast2-registration.changes
new/yast2-registration-4.2.25/package/yast2-registration.changes
--- old/yast2-registration-4.2.23/package/yast2-registration.changes
2019-12-06 14:44:13.000000000 +0100
+++ new/yast2-registration-4.2.25/package/yast2-registration.changes
2020-01-14 17:23:55.000000000 +0100
@@ -1,4 +1,18 @@
-------------------------------------------------------------------
+Tue Jan 14 15:04:15 UTC 2020 - Josef Reidinger <[email protected]>
+
+- fix crash in autoyast registration (bsc#1160909)
+- 4.2.25
+
+-------------------------------------------------------------------
+Fri Jan 10 14:16:55 UTC 2020 - Ladislav Slezák <[email protected]>
+
+- Load the old repositories before running the migration
+ so the code can properly detect the old and the new repositories
+ and remove the obsoleted services from the system (bsc#1159433)
+- 4.2.24
+
+-------------------------------------------------------------------
Fri Dec 6 13:12:59 UTC 2019 - Josef Reidinger <[email protected]>
- Improve messages when auto upgrading unregistered system with
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/yast2-registration-4.2.23/package/yast2-registration.spec
new/yast2-registration-4.2.25/package/yast2-registration.spec
--- old/yast2-registration-4.2.23/package/yast2-registration.spec
2019-12-06 14:44:13.000000000 +0100
+++ new/yast2-registration-4.2.25/package/yast2-registration.spec
2020-01-14 17:23:55.000000000 +0100
@@ -17,7 +17,7 @@
Name: yast2-registration
-Version: 4.2.23
+Version: 4.2.25
Release: 0
Summary: YaST2 - Registration Module
License: GPL-2.0-only
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yast2-registration-4.2.23/src/clients/scc_auto.rb
new/yast2-registration-4.2.25/src/clients/scc_auto.rb
--- old/yast2-registration-4.2.23/src/clients/scc_auto.rb 2019-12-06
14:44:13.000000000 +0100
+++ new/yast2-registration-4.2.25/src/clients/scc_auto.rb 2020-01-14
17:23:55.000000000 +0100
@@ -26,409 +26,6 @@
#
#
-require "fileutils"
-require "yast/suse_connect"
+require "registration/clients/scc_auto"
-require "registration/storage"
-require "registration/sw_mgmt"
-require "registration/autoyast_addons"
-require "registration/registration"
-require "registration/registration_ui"
-require "registration/helpers"
-require "registration/connect_helpers"
-require "registration/ssl_certificate"
-require "registration/url_helpers"
-require "registration/ui/autoyast_config_workflow"
-require "registration/ui/offline_migration_workflow"
-require "registration/erb_renderer.rb"
-require "y2packager/product_control_product"
-require "y2packager/medium_type"
-
-module Yast
- class SccAutoClient < Client
- include Yast::Logger
- extend Yast::I18n
-
- # popup message
- CONTACTING_MESSAGE = N_("Contacting the Registration Server")
-
- def main
- textdomain "registration"
- import_modules
-
- log.info "scc_auto started"
-
- @config = ::Registration::Storage::Config.instance
- func = WFM.Args[0]
- param = WFM.Args[1] || {}
- log.info "func: #{func}, param:
#{::Registration::Helpers.hide_reg_codes(param)}"
-
- ret = handle_autoyast(func, param)
-
- log.info "scc_auto finished"
- ret
- end
-
- private
-
- def import_modules
- Yast.import "UI"
- Yast.import "Pkg"
- Yast.import "Wizard"
- Yast.import "Label"
- Yast.import "Report"
- Yast.import "Popup"
- Yast.import "Profile"
- Yast.import "Packages"
- Yast.import "Report"
- Yast.import "Installation"
- end
-
- def handle_autoyast(func, param)
- ret = case func
- when "Summary"
- # Create a summary
- summary
- when "Reset"
- # Reset configuration
- @config.reset
- {}
- when "Change"
- # Change configuration
- start_workflow
- when "Import"
- # import configuration
- import(param)
- when "Export"
- # Return the current config
- export
- when "Packages"
- # Return needed packages
- auto_packages
- when "Read"
- log.error "Cloning is not supported by this YaST module"
- false
- when "Write"
- # Write given settings
- write
- when "GetModified"
- @config.modified
- when "SetModified"
- @config.modified = true
- true
- else
- log.error "Unknown function: #{func}"
- raise "Unknown function parameter: #{func}"
- end
-
- log.info "ret: #{::Registration::Helpers.hide_reg_codes(ret)}"
-
- ret
- end
-
- # Get all settings from the first parameter
- # (For use by autoinstallation.)
- # param [Hash] settings The structure to be imported.
- def import(settings)
- Yast.import "AutoinstFunctions"
-
- # merge reg code if not defined in the profile but
- # available from other sources
- product = Yast::AutoinstFunctions.selected_product
- if product && !settings["reg_code"]
- reg_codes_loader = Registration::Storage::RegCodes.instance
- settings["reg_code"] = reg_codes_loader.reg_codes[product.short_name]
|| ""
- end
-
- log.debug "Importing config: #{settings}"
- @config.import(settings)
- end
-
- # Export the settings to a single Hash
- # (For use by autoinstallation.)
- # @return [Hash] AutoYast configuration
- def export
- ret = @config.export
- log.debug "Exported config: #{ret}"
- ret
- end
-
- # Create a textual summary
- # @return [String] summary of the current configuration
- def summary
-
Registration::ErbRenderer.new(@config).render_erb_template("autoyast_summary.erb")
- end
-
- # set the registration URL from the profile or use the default
- # @return [Boolean] true on success
- def set_registration_url
- # set the registration URL
- url = @config.reg_server if @config.reg_server &&
[email protected]_server.empty?
-
- # use SLP discovery
- if !url && @config.slp_discovery
- url = find_slp_server
- return false unless url
- end
-
- url ||= ::Registration::UrlHelpers.registration_url
- log.info "Registration URL: #{url}"
-
- # nil = use the default URL
- switch_registration(url)
-
- true
- end
-
- # register the system, base product and optional addons
- # return true on success
- def write
- # registration disabled, nothing to do
- return true unless @config.do_registration
-
- # initialize libzypp if applying settings in installed system or
- # in AutoYast configuration mode ("Apply to System")
- ::Registration::SwMgmt.init if Mode.normal || Mode.config
-
- return false unless set_registration_url
-
- # update the registration in AutoUpgrade mode if the old system was
registered
- if Mode.update
- if old_system_registered?
- # drop all obsolete repositories and services (manual upgrade
contains a dialog
- # where the old repositories are deleted, in AY we need to do it
automatically here)
- # Note: the Update module creates automatically a backup which is
restored
- # when upgrade is aborted or crashes.
- repo_cleanup
-
- ret = ::Registration::UI::OfflineMigrationWorkflow.new.main
- log.info "Migration result: #{ret}"
- return ret == :next
- else
- # Intentionally use blocking popup as it is fatal error that stops
installation.
- Popup.Error(
- # TRANSLATORS: profile wants to do registration, but old system is
not registered.
- _("Old system is not registered and autoyast profile require
registration." \
- "Either register the old system before running the upgrade or " \
- "remove the registration section from the AutoYaST profile " \
- "and use full medium.")
- )
- return false
- end
- end
-
- # special handling for the online installation medium,
- # we need to evaluate the base products defined in the control.xml
- if Y2Packager::MediumType.online?
- return false unless online_medium_config
- end
-
- ret = ::Registration::ConnectHelpers.catch_registration_errors do
- import_certificate(@config.reg_server_cert)
- register_base_product && register_addons
- end
-
- return false unless ret
-
- finish_registration
-
- true
- end
-
- # Select the product from the control.xml (for the online installation
medium)
- # @return [Boolean] true on success, false on failure
- def online_medium_config
- # import the GPG keys before refreshing the repositories
- Yast::Packages.ImportGPGKeys
-
- products = Y2Packager::ProductControlProduct.products
- ay_product = Profile.current.fetch("software", {}).fetch("products",
[]).first
-
- if !ay_product
- # TRANSLATORS: error message, %s is the XML path, e.g.
"software/products"
- Report.Error(_("Missing product specification in the %s section") %
"software/products")
- return false
- end
-
- control_product = products.find { |p| p.name == ay_product }
-
- if !control_product
- # TRANSLATORS: error message, %s is a product ID, e.g. "SLES"
- Report.Error(_("Product %s not found") % ay_product)
- return false
- end
-
- # mark the control file product as selected
- Y2Packager::ProductControlProduct.selected = control_product
-
- true
- end
-
- # delete all previous services and repositories
- def repo_cleanup
- # we cannot use pkg-bindings here because loading services would trigger
- # service and repository refresh which we want to avoid (it might easily
fail)
- old = Dir[File.join(Installation.destdir, "/etc/zypp/repos.d/*")] +
- Dir[File.join(Installation.destdir, "/etc/zypp/services.d/*")] +
- Dir[File.join(Installation.destdir, "/var/cache/zypp/*")]
-
- log.info "Removing #{old}"
- ::FileUtils.rm_rf(old)
- end
-
- # finish the registration process
- def finish_registration
- # save the registered repositories
- Pkg.SourceSaveAll
-
- if Mode.normal || Mode.config
- # popup message: registration finished properly
- Popup.Message(_("Registration was successfull."))
- elsif Stage.initial
- # copy the SSL certificate to the target system
- ::Registration::Helpers.copy_certificate_to_target
- end
- end
-
- # return extra packages needed by this module (none so far)
- # @return [Hash] required packages
- def auto_packages
- ret = { "install" => [], "remove" => [] }
- log.info "Registration needs these packages: #{ret}"
- ret
- end
-
- # find registration server via SLP
- # @return [String,nil] URL of the server, nil on error
- def find_slp_server
- # do SLP query
- slp_services = ::Registration::UrlHelpers.slp_discovery_feedback
- slp_urls = slp_services.map(&:slp_url)
-
- # remove possible duplicates
- slp_urls.uniq!
- log.info "Found #{slp_urls.size} SLP servers"
-
- case slp_urls.size
- when 0
- Report.Error(_("SLP discovery failed, no server found"))
- return nil
- when 1
- return slp_urls.first
- else
- # more than one server found: let the user select, we cannot
automatically
- # decide which one to use, asking user in AutoYast mode is not nice
- # but better than aborting the installation...
- return ::Registration::UrlHelpers.slp_service_url
- end
- end
-
- # download and install the specified SSL certificate to the system
- # @param url [String] URL of the certificate
- def import_certificate(url)
- return unless url && !url.empty?
- log.info "Importing certificate from #{url}..."
-
- cert = Popup.Feedback(_("Downloading SSL Certificate"), url) do
- ::Registration::SslCertificate.download(url)
- end
-
- Popup.Feedback(_("Importing SSL Certificate"), cert.subject_name) do
- cert.import
- end
- end
-
- # UI workflow definition
- def start_workflow
- ::Registration::UI::AutoyastConfigWorkflow.run(@config)
- end
-
- # update the internal Registration object after changing the registration
URL
- def switch_registration(url = nil)
- @registration = ::Registration::Registration.new(url)
- # reset registration ui as it depends on registration
- @registration_ui = nil
- @registration
- end
-
- # returns the internal Registration object
- def registration
- if !@registration
- url = ::Registration::UrlHelpers.registration_url
- log.info "Updating registration using URL: #{url}"
- @registration = switch_registration(url)
- end
-
- @registration
- end
-
- # returns the internal RegistrationUI object
- def registration_ui
- @registration_ui ||= ::Registration::RegistrationUI.new(registration)
- end
-
- # update the registration (system, the base product, the installed
extensions)
- def update_registration
- return false unless update_system_registration
-
- # register additional addons (e.g. originally not present in SLE11/SLE12)
- register_addons
- end
-
- # FIXME: share these methods with inst_scc.rb
-
- def register_base_product
- handle_product_service do
- options = ::Registration::Storage::InstallationOptions.instance
- options.email = @config.email
- options.reg_code = @config.reg_code
-
- registration_ui.register_system_and_base_product
- end
- end
-
- # register the addons specified in the profile
- def register_addons
- # set the option for installing the updates for addons
- options = Registration::Storage::InstallationOptions.instance
- options.install_updates = @config.install_updates
-
- ay_addons_handler = Registration::AutoyastAddons.new(@config.addons,
registration)
- ay_addons_handler.select
- ay_addons_handler.register
-
- # select the new products to install
- ::Registration::SwMgmt.select_addon_products
- end
-
- # was the system already registered?
- # @return [Boolean] true if the system was alreay registered
- def old_system_registered?
- ::Registration::SwMgmt.copy_old_credentials(Installation.destdir)
-
- # update the registration using the old credentials
- File.exist?(SUSE::Connect::YaST::GLOBAL_CREDENTIALS_FILE)
- end
-
- # update the system registration
- # @return [Boolean] true on success
- def update_system_registration
- registration_ui.update_system
- end
-
- # @yieldreturn [Boolean, SUSE::Connect::Remote::Product] success flag and
- # remote product pair
- # @return [Boolean] true on success
- def handle_product_service(&block)
- success, product_service = block.call
- return false unless success
-
- # keep updates enabled?
- return true if @config.install_updates || !product_service
-
- registration_ui.disable_update_repos(product_service)
- end
- end unless defined?(SccAutoClient)
-end
-
-Yast::SccAutoClient.new.main
+::Registration::Clients::SCCAuto.run
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/yast2-registration-4.2.23/src/lib/registration/clients/scc_auto.rb
new/yast2-registration-4.2.25/src/lib/registration/clients/scc_auto.rb
--- old/yast2-registration-4.2.23/src/lib/registration/clients/scc_auto.rb
1970-01-01 01:00:00.000000000 +0100
+++ new/yast2-registration-4.2.25/src/lib/registration/clients/scc_auto.rb
2020-01-14 17:23:55.000000000 +0100
@@ -0,0 +1,409 @@
+# encoding: utf-8
+
+# ***************************************************************************
+#
+# Copyright (c) 2019 SUSE LLC
+# All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of version 2 of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, contact Novell, Inc.
+#
+# To contact Novell about this file by physical or electronic mail,
+# you may find current contact information at www.novell.com
+#
+# ***************************************************************************
+
+require "fileutils"
+require "yast/suse_connect"
+
+require "installation/auto_client"
+require "registration/storage"
+require "registration/sw_mgmt"
+require "registration/autoyast_addons"
+require "registration/registration"
+require "registration/registration_ui"
+require "registration/helpers"
+require "registration/connect_helpers"
+require "registration/ssl_certificate"
+require "registration/url_helpers"
+require "registration/ui/autoyast_config_workflow"
+require "registration/ui/offline_migration_workflow"
+require "registration/erb_renderer.rb"
+require "y2packager/product_control_product"
+require "y2packager/medium_type"
+
+Yast.import "UI"
+Yast.import "Pkg"
+Yast.import "Wizard"
+Yast.import "Label"
+Yast.import "Report"
+Yast.import "Popup"
+Yast.import "Profile"
+Yast.import "Packages"
+Yast.import "Report"
+Yast.import "Installation"
+
+module Registration
+ module Clients
+ class SCCAuto < ::Installation::AutoClient
+ include Yast::Logger
+ extend Yast::I18n
+
+ # popup message
+ CONTACTING_MESSAGE = N_("Contacting the Registration Server")
+
+ def initialize
+ textdomain "registration"
+
+ @config = ::Registration::Storage::Config.instance
+ end
+
+ # Create a textual summary
+ # @return [String] summary of the current configuration
+ def summary
+
::Registration::ErbRenderer.new(@config).render_erb_template("autoyast_summary.erb")
+ end
+
+ def reset
+ @config.reset
+ {}
+ end
+
+ # UI workflow definition
+ def change
+ ::Registration::UI::AutoyastConfigWorkflow.run(@config)
+ end
+
+ # Get all settings from the first parameter
+ # (For use by autoinstallation.)
+ # param [Hash] settings The structure to be imported.
+ def import(settings)
+ # if there is no registration section like can happen during auto
upgrade
+ return unless settings
+
+ Yast.import "AutoinstFunctions"
+
+ # merge reg code if not defined in the profile but
+ # available from other sources
+ product = Yast::AutoinstFunctions.selected_product
+ if product && !settings["reg_code"]
+ reg_codes_loader = ::Registration::Storage::RegCodes.instance
+ settings["reg_code"] =
reg_codes_loader.reg_codes[product.short_name] || ""
+ end
+
+ log.debug "Importing config: #{settings}"
+ @config.import(settings)
+ end
+
+ # Export the settings to a single Hash
+ # (For use by autoinstallation.)
+ # @return [Hash] AutoYast configuration
+ def export
+ ret = @config.export
+ log.debug "Exported config: #{ret}"
+ ret
+ end
+
+ # register the system, base product and optional addons
+ # return true on success
+ def write
+ # registration disabled, nothing to do
+ return true if [email protected]_registration && !Yast::Mode.update
+
+ # initialize libzypp if applying settings in installed system or
+ # in AutoYast configuration mode ("Apply to System")
+ ::Registration::SwMgmt.init if Yast::Mode.normal || Yast::Mode.config
+
+ return false unless set_registration_url
+
+ # update the registration in AutoUpgrade mode if the old system was
registered
+ return migrate_reg if Yast::Mode.update
+
+ # special handling for the online installation medium,
+ # we need to evaluate the base products defined in the control.xml
+ if Yast::Stage.initial && Y2Packager::MediumType.online?
+ return false unless online_medium_config
+ end
+
+ ret = ::Registration::ConnectHelpers.catch_registration_errors do
+ import_certificate(@config.reg_server_cert)
+ register_base_product && register_addons
+ end
+
+ return false unless ret
+
+ finish_registration
+
+ true
+ end
+
+ def read
+ log.error "Cloning is not supported by this YaST module"
+ false
+ end
+
+ # return extra packages needed by this module (none so far)
+ # @return [Hash] required packages
+ def packages
+ ret = { "install" => [], "remove" => [] }
+ log.info "Registration needs these packages: #{ret}"
+ ret
+ end
+
+ def modified?
+ @config.modified
+ end
+
+ def modified
+ @config.modified = true
+ true
+ end
+
+ private
+
+ # set the registration URL from the profile or use the default
+ # @return [Boolean] true on success
+ def set_registration_url
+ # set the registration URL
+ url = @config.reg_server if @config.reg_server &&
[email protected]_server.empty?
+
+ # use SLP discovery
+ if !url && @config.slp_discovery
+ url = find_slp_server
+ return false unless url
+ end
+
+ url ||= ::Registration::UrlHelpers.registration_url
+ log.info "Registration URL: #{url}"
+
+ # nil = use the default URL
+ switch_registration(url)
+
+ true
+ end
+
+ # Select the product from the control.xml (for the online installation
medium)
+ # @return [Boolean] true on success, false on failure
+ def online_medium_config
+ # import the GPG keys before refreshing the repositories
+ Yast::Packages.ImportGPGKeys
+
+ products = Y2Packager::ProductControlProduct.products
+ ay_product = Yast::Profile.current.fetch("software",
{}).fetch("products", []).first
+
+ if !ay_product
+ # TRANSLATORS: error message, %s is the XML path, e.g.
"software/products"
+ Yast::Report.Error(
+ _("Missing product specification in the %s section") %
"software/products"
+ )
+ return false
+ end
+
+ control_product = products.find { |p| p.name == ay_product }
+
+ if !control_product
+ # TRANSLATORS: error message, %s is a product ID, e.g. "SLES"
+ Yast::Report.Error(_("Product %s not found") % ay_product)
+ return false
+ end
+
+ # mark the control file product as selected
+ Y2Packager::ProductControlProduct.selected = control_product
+
+ true
+ end
+
+ # delete all previous services and repositories
+ def repo_cleanup
+ # we cannot use pkg-bindings here because loading services would
trigger
+ # service and repository refresh which we want to avoid (it might
easily fail)
+ old = Dir[File.join(Installation.destdir, "/etc/zypp/repos.d/*")] +
+ Dir[File.join(Installation.destdir, "/etc/zypp/services.d/*")] +
+ Dir[File.join(Installation.destdir, "/var/cache/zypp/*")]
+
+ log.info "Removing #{old}"
+ ::FileUtils.rm_rf(old)
+ end
+
+ # finish the registration process
+ def finish_registration
+ # save the registered repositories
+ Yast::Pkg.SourceSaveAll
+
+ if Yast::Mode.normal || Yast::Mode.config
+ # popup message: registration finished properly
+ Yast::Popup.Message(_("Registration was successfull."))
+ elsif Yast::Stage.initial
+ # copy the SSL certificate to the target system
+ ::Registration::Helpers.copy_certificate_to_target
+ end
+ end
+
+ # find registration server via SLP
+ # @return [String,nil] URL of the server, nil on error
+ def find_slp_server
+ # do SLP query
+ slp_services = ::Registration::UrlHelpers.slp_discovery_feedback
+ slp_urls = slp_services.map(&:slp_url)
+
+ # remove possible duplicates
+ slp_urls.uniq!
+ log.info "Found #{slp_urls.size} SLP servers"
+
+ case slp_urls.size
+ when 0
+ Yast::Report.Error(_("SLP discovery failed, no server found"))
+ return nil
+ when 1
+ return slp_urls.first
+ else
+ # more than one server found: let the user select, we cannot
automatically
+ # decide which one to use, asking user in AutoYast mode is not nice
+ # but better than aborting the installation...
+ return ::Registration::UrlHelpers.slp_service_url
+ end
+ end
+
+ # download and install the specified SSL certificate to the system
+ # @param url [String] URL of the certificate
+ def import_certificate(url)
+ return unless url && !url.empty?
+ log.info "Importing certificate from #{url}..."
+
+ cert = Yast::Popup.Feedback(_("Downloading SSL Certificate"), url) do
+ ::Registration::SslCertificate.download(url)
+ end
+
+ Yast::Popup.Feedback(_("Importing SSL Certificate"),
cert.subject_name) do
+ cert.import
+ end
+ end
+
+ # update the internal Registration object after changing the
registration URL
+ def switch_registration(url = nil)
+ @registration = ::Registration::Registration.new(url)
+ # reset registration ui as it depends on registration
+ @registration_ui = nil
+ @registration
+ end
+
+ # returns the internal Registration object
+ def registration
+ if !@registration
+ url = ::Registration::UrlHelpers.registration_url
+ log.info "Updating registration using URL: #{url}"
+ @registration = switch_registration(url)
+ end
+
+ @registration
+ end
+
+ # returns the internal RegistrationUI object
+ def registration_ui
+ @registration_ui ||= ::Registration::RegistrationUI.new(registration)
+ end
+
+ # update the registration (system, the base product, the installed
extensions)
+ def update_registration
+ return false unless update_system_registration
+
+ # register additional addons (e.g. originally not present in
SLE11/SLE12)
+ register_addons
+ end
+
+ # FIXME: share these methods with inst_scc.rb
+
+ def register_base_product
+ handle_product_service do
+ options = ::Registration::Storage::InstallationOptions.instance
+ options.email = @config.email
+ options.reg_code = @config.reg_code
+
+ registration_ui.register_system_and_base_product
+ end
+ end
+
+ # register the addons specified in the profile
+ def register_addons
+ # set the option for installing the updates for addons
+ options = ::Registration::Storage::InstallationOptions.instance
+ options.install_updates = @config.install_updates
+
+ ay_addons_handler = ::Registration::AutoyastAddons.new(@config.addons,
registration)
+ ay_addons_handler.select
+ ay_addons_handler.register
+
+ # select the new products to install
+ ::Registration::SwMgmt.select_addon_products
+ end
+
+ # was the system already registered?
+ # @return [Boolean] true if the system was alreay registered
+ def old_system_registered?
+ ::Registration::SwMgmt.copy_old_credentials(Yast::Installation.destdir)
+
+ # update the registration using the old credentials
+ ::File.exist?(SUSE::Connect::YaST::GLOBAL_CREDENTIALS_FILE)
+ end
+
+ # update the system registration
+ # @return [Boolean] true on success
+ def update_system_registration
+ registration_ui.update_system
+ end
+
+ # @yieldreturn [Boolean, SUSE::Connect::Remote::Product] success flag and
+ # remote product pair
+ # @return [Boolean] true on success
+ def handle_product_service(&block)
+ success, product_service = block.call
+ return false unless success
+
+ # keep updates enabled?
+ return true if @config.install_updates || !product_service
+
+ registration_ui.disable_update_repos(product_service)
+ end
+
+ # migrate registration if applicable or skip or report issue.
+ def migrate_reg
+ if old_system_registered?
+ # act always like we have online only repo for registered system
+ Y2Packager::MediumType.type = :online
+
+ # drop all obsolete repositories and services (manual upgrade
contains a dialog
+ # where the old repositories are deleted, in AY we need to do it
automatically here)
+ # Note: the Update module creates automatically a backup which is
restored
+ # when upgrade is aborted or crashes.
+ repo_cleanup
+
+ ret = ::Registration::UI::OfflineMigrationWorkflow.new.main
+ log.info "Migration result: #{ret}"
+ ret == :next
+ # Full medium we can upgrade without registration
+ elsif Y2Packager::MediumType.offline?
+ true
+ else
+ # Intentionally use blocking popup as it is fatal error that stops
installation.
+ Yast::Popup.Error(
+ # TRANSLATORS: profile wants to do registration, but old system is
not registered.
+ _("The old system is not registered and the AutoYaST profile
requires registration.\n" \
+ "Either register the old system before running the upgrade or
\n" \
+ "remove the registration section from the AutoYaST profile \n" \
+ "and use full medium.")
+ )
+ false
+ end
+ end
+ end
+ end
+end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/yast2-registration-4.2.23/src/lib/registration/ui/offline_migration_workflow.rb
new/yast2-registration-4.2.25/src/lib/registration/ui/offline_migration_workflow.rb
---
old/yast2-registration-4.2.23/src/lib/registration/ui/offline_migration_workflow.rb
2019-12-06 14:44:13.000000000 +0100
+++
new/yast2-registration-4.2.25/src/lib/registration/ui/offline_migration_workflow.rb
2020-01-14 17:23:55.000000000 +0100
@@ -53,6 +53,8 @@
return :back
end
+ reinit_repos
+
# run the main registration migration
ui = migration_repos
@@ -74,6 +76,13 @@
private
+ # force reloading of the old repositories so we can detect and remove
the obsoleted
+ # services during migration (bsc#1159433)
+ def reinit_repos
+ Yast::Pkg.SourceFinishAll
+ Yast::Pkg.SourceRestore
+ end
+
def going_back
log.info("Going back")
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/yast2-registration-4.2.23/test/offline_migration_workflow_test.rb
new/yast2-registration-4.2.25/test/offline_migration_workflow_test.rb
--- old/yast2-registration-4.2.23/test/offline_migration_workflow_test.rb
2019-12-06 14:44:13.000000000 +0100
+++ new/yast2-registration-4.2.25/test/offline_migration_workflow_test.rb
2020-01-14 17:23:55.000000000 +0100
@@ -13,6 +13,8 @@
allow(File).to receive(:exist?)
allow(Yast::WFM).to receive(:CallFunction)
allow(Yast::Stage).to receive(:initial).and_return(true)
+ allow(Yast::Pkg).to receive(:SourceFinishAll)
+ allow(Yast::Pkg).to receive(:SourceRestore)
end
shared_examples "certificate cleanup" do
@@ -83,6 +85,13 @@
subject.main
end
+ it "loads the libzypp repositories" do
+ expect(Yast::Pkg).to receive(:SourceFinishAll)
+ expect(Yast::Pkg).to receive(:SourceRestore)
+
+ subject.main
+ end
+
it "returns the 'inst_migration_repos' result" do
expect(Yast::WFM).to receive(:CallFunction).with("inst_migration_repos",
anything)
.and_return(:foo)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/yast2-registration-4.2.23/test/registration/clients/scc_auto_test.rb
new/yast2-registration-4.2.25/test/registration/clients/scc_auto_test.rb
--- old/yast2-registration-4.2.23/test/registration/clients/scc_auto_test.rb
1970-01-01 01:00:00.000000000 +0100
+++ new/yast2-registration-4.2.25/test/registration/clients/scc_auto_test.rb
2020-01-14 17:23:55.000000000 +0100
@@ -0,0 +1,156 @@
+#! /usr/bin/env rspec
+
+require_relative "../../spec_helper"
+
+# we have enabled strict method checking in rspec, so we need to define
profile method
+# by opening class. Profile is stubbed, so it is just fake class
+
+module Yast
+ class Profile
+ def self.current
+ {}
+ end
+ end
+end
+
+describe Registration::Clients::SCCAuto do
+ let(:config) { ::Registration::Storage::Config.instance }
+
+ describe "#summary" do
+ it "returns string with config description" do
+ expect(subject.summary).to be_a(::String)
+ end
+ end
+
+ describe "#reset" do
+ it "resets config to initial state" do
+ expect(config).to receive(:reset)
+
+ subject.reset
+ end
+ end
+
+ describe "#change" do
+ it "runs registration workflow" do
+ expect(::Registration::UI::AutoyastConfigWorkflow).to receive(:run)
+
+ subject.change
+ end
+ end
+
+ describe "#import" do
+ it "imports given hash" do
+ expect { subject.import({}) }.to_not raise_error
+ end
+ end
+
+ describe "#export" do
+ it "returns hash" do
+ expect(subject.export).to be_a(::Hash)
+ end
+ end
+
+ describe "#read" do
+ it "returns false" do
+ expect(subject.read).to eq false
+ end
+ end
+
+ describe "#packages" do
+ it "returns hash to not install neither remove anything" do
+ packages = subject.packages
+ expect(packages["install"]).to eq []
+ expect(packages["remove"]).to eq []
+ end
+ end
+
+ describe "#modified" do
+ it "sets modified flag in config" do
+ config.modified = false
+ subject.modified
+
+ expect(config.modified).to eq true
+ end
+ end
+
+ describe "#modified?" do
+ it "returns if modified flag is set in config" do
+ config.modified = true
+ expect(subject.modified?).to eq true
+ end
+ end
+
+ describe "#write" do
+ before do
+ Y2Packager::MediumType.type = :online
+ allow(Y2Packager::ProductControlProduct).to
receive(:products).and_return("SLES")
+ end
+
+ it "just returns true if config is not set to register and mode is not
update" do
+ config.do_registration = false
+ allow(Yast::Mode).to receive(:update).and_return(false)
+
+ expect(subject.write).to eq true
+ end
+
+ it "initializes software managent in normal mode" do
+ config.do_registration = true
+ allow(Yast::Mode).to receive(:normal).and_return(true)
+ expect(::Registration::SwMgmt).to receive(:init)
+
+ subject.write
+ end
+
+ it "registers previously registered base system and addons" do
+ allow(Yast::Mode).to receive(:update).and_return(false)
+ subject.import(
+ "do_registration" => true,
+ "addons" => [{
+ "name" => "sle-module-basesystem",
+ "version" => "15.2",
+ "arch" => "x86_64"
+ }]
+ )
+
+ allow(subject).to receive(:registration_ui).and_return(
+ double(register_system_and_base_product: true, disable_update_repos:
true)
+ )
+
+ addon = double.as_null_object
+ expect(Registration::AutoyastAddons).to receive(:new).and_return(addon)
+ expect(addon).to receive(:register)
+
+ subject.write
+ end
+
+ context "in autoupgrade mode" do
+ before do
+ allow(Yast::Mode).to receive(:update).and_return(true)
+ end
+
+ it "runs offline migration workflow if system is registered" do
+ expect(::Registration::UI::OfflineMigrationWorkflow).to receive(:new)
+ .and_return(double(main: :next))
+ allow(subject).to receive(:old_system_registered?).and_return(true)
+
+ subject.write
+ end
+
+ it "skips registration and returns true for unregistered system and
offline medium" do
+ allow(subject).to receive(:old_system_registered?).and_return(false)
+ Y2Packager::MediumType.type = :offline
+
+ expect(subject.write).to eq true
+ end
+
+ it "reports error and return false for unregistered system and online
medium" do
+ allow(subject).to receive(:old_system_registered?).and_return(false)
+ Y2Packager::MediumType.type = :online
+
+ expect(Yast::Popup).to receive(:Error)
+
+ expect(subject.write).to eq false
+ end
+ end
+ end
+end