Hello community,

here is the log from the commit of package yast2-registration for 
openSUSE:Factory checked in at 2018-05-17 19:31:54
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/yast2-registration (Old)
 and      /work/SRC/openSUSE:Factory/.yast2-registration.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "yast2-registration"

Thu May 17 19:31:54 2018 rev:18 rq:607406 version:4.0.36

Changes:
--------
--- /work/SRC/openSUSE:Factory/yast2-registration/yast2-registration.changes    
2018-04-26 13:29:14.443405229 +0200
+++ 
/work/SRC/openSUSE:Factory/.yast2-registration.new/yast2-registration.changes   
    2018-05-17 19:31:58.322215131 +0200
@@ -1,0 +2,15 @@
+Tue May  8 17:27:36 CEST 2018 - [email protected]
+
+- Fixed: Offline migration against RMT sends some requests to 
+  SCC instead (bnc#1090911)
+- 4.0.36
+
+-------------------------------------------------------------------
+Fri Apr 27 15:44:43 UTC 2018 - [email protected]
+
+- Install a registration rollback script to rollback the
+  registration in case YaST is aborted or crashes during upgrade
+  (bsc#1089643)
+- 4.0.35
+
+-------------------------------------------------------------------

Old:
----
  yast2-registration-4.0.34.tar.bz2

New:
----
  yast2-registration-4.0.36.tar.bz2

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ yast2-registration.spec ++++++
--- /var/tmp/diff_new_pack.k1RSlR/_old  2018-05-17 19:31:58.850195842 +0200
+++ /var/tmp/diff_new_pack.k1RSlR/_new  2018-05-17 19:31:58.854195696 +0200
@@ -17,7 +17,7 @@
 
 
 Name:           yast2-registration
-Version:        4.0.34
+Version:        4.0.36
 Release:        0
 
 BuildRoot:      %{_tmppath}/%{name}-%{version}-build

++++++ yast2-registration-4.0.34.tar.bz2 -> yast2-registration-4.0.36.tar.bz2 
++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-registration-4.0.34/package/yast2-registration.changes 
new/yast2-registration-4.0.36/package/yast2-registration.changes
--- old/yast2-registration-4.0.34/package/yast2-registration.changes    
2018-04-17 08:58:29.000000000 +0200
+++ new/yast2-registration-4.0.36/package/yast2-registration.changes    
2018-05-15 09:42:03.000000000 +0200
@@ -1,4 +1,19 @@
 -------------------------------------------------------------------
+Tue May  8 17:27:36 CEST 2018 - [email protected]
+
+- Fixed: Offline migration against RMT sends some requests to 
+  SCC instead (bnc#1090911)
+- 4.0.36
+
+-------------------------------------------------------------------
+Fri Apr 27 15:44:43 UTC 2018 - [email protected]
+
+- Install a registration rollback script to rollback the
+  registration in case YaST is aborted or crashes during upgrade
+  (bsc#1089643)
+- 4.0.35
+
+-------------------------------------------------------------------
 Mon Apr 16 11:39:41 UTC 2018 - [email protected]
 
 - Reimplemented AutoYaST autoupgrade, use the same API and workflow
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-registration-4.0.34/package/yast2-registration.spec 
new/yast2-registration-4.0.36/package/yast2-registration.spec
--- old/yast2-registration-4.0.34/package/yast2-registration.spec       
2018-04-17 08:58:29.000000000 +0200
+++ new/yast2-registration-4.0.36/package/yast2-registration.spec       
2018-05-15 09:42:03.000000000 +0200
@@ -17,7 +17,7 @@
 
 
 Name:           yast2-registration
-Version:        4.0.34
+Version:        4.0.36
 Release:        0
 
 BuildRoot:      %{_tmppath}/%{name}-%{version}-build
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-registration-4.0.34/src/data/registration/registration_rollback.sh 
new/yast2-registration-4.0.36/src/data/registration/registration_rollback.sh
--- 
old/yast2-registration-4.0.34/src/data/registration/registration_rollback.sh    
    1970-01-01 01:00:00.000000000 +0100
+++ 
new/yast2-registration-4.0.36/src/data/registration/registration_rollback.sh    
    2018-05-15 09:42:03.000000000 +0200
@@ -0,0 +1,14 @@
+#! /bin/sh
+
+# This script rolls back the registration status on the server
+# You can optionally pass the target chroot directory as a parameter,
+# the default is "/".
+
+ROOT=${1:-/}
+
+# print the progress in green so it is better visible
+echo -e "\e[0;32mRestoring the registration status at ${ROOT}, \
+this might take several minutes...\e[0m"
+
+# run the rollback
+chroot "$ROOT" SUSEConnect --rollback
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-registration-4.0.34/src/lib/registration/registration.rb 
new/yast2-registration-4.0.36/src/lib/registration/registration.rb
--- old/yast2-registration-4.0.34/src/lib/registration/registration.rb  
2018-04-17 08:58:29.000000000 +0200
+++ new/yast2-registration-4.0.36/src/lib/registration/registration.rb  
2018-05-15 09:42:03.000000000 +0200
@@ -118,7 +118,7 @@
         )
       end
       log.info "Synchronizing products: #{remote_products}"
-      SUSE::Connect::YaST.synchronize(remote_products)
+      SUSE::Connect::YaST.synchronize(remote_products, connect_params)
     end
 
     # @param [String] target_distro new target distribution
@@ -163,7 +163,7 @@
       migrations = []
 
       ConnectHelpers.catch_registration_errors do
-        migrations = SUSE::Connect::YaST.system_migrations(installed_products)
+        migrations = SUSE::Connect::YaST.system_migrations(installed_products, 
connect_params)
       end
 
       log.info "Received system migrations: #{migrations}"
@@ -175,7 +175,8 @@
       migration_paths = []
       ConnectHelpers.catch_registration_errors(show_update_hint: true) do
         migration_paths = SUSE::Connect::YaST
-                          .system_offline_migrations(installed_products, 
target_base_product)
+                          .system_offline_migrations(installed_products,
+                            target_base_product, connect_params)
       end
 
       log.info "Received possible migrations paths: #{migration_paths}"
@@ -227,7 +228,7 @@
 
     def service_for_product(product, &block)
       remote_product = if product.is_a?(Hash)
-        SwMgmt.remote_product(product)
+        SwMgmt.remote_product(product, version_release: false)
       else
         product
       end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-registration-4.0.34/src/lib/registration/rollback_script.rb 
new/yast2-registration-4.0.36/src/lib/registration/rollback_script.rb
--- old/yast2-registration-4.0.34/src/lib/registration/rollback_script.rb       
1970-01-01 01:00:00.000000000 +0100
+++ new/yast2-registration-4.0.36/src/lib/registration/rollback_script.rb       
2018-05-15 09:42:03.000000000 +0200
@@ -0,0 +1,70 @@
+# 
------------------------------------------------------------------------------
+# Copyright (c) 2018 SUSE LLC
+#
+# 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.
+#
+# 
------------------------------------------------------------------------------
+
+require "yast"
+require "fileutils"
+
+module Registration
+  # This class handles creating a registration rollback script  which is called
+  # when the upgrade is aborted or YaST crashes. The script body is stored
+  # in the data/registration/registration_rollback.sh file.
+  class RollbackScript
+    include Yast::Logger
+
+    BACKUP_DIR = "var/adm/backup/system-upgrade".freeze
+
+    # use number 0200, the original repositories need to be restored first,
+    # they are stored in script with number 0100
+    DEFAULT_SCRIPT_NAME = "restore-0200-registration.sh".freeze
+
+    SUSE_CONNECT = "/usr/sbin/SUSEConnect".freeze
+
+    attr_reader :root
+
+    # @param root [String] target root
+    def initialize(root: "/mnt")
+      @root = root
+    end
+
+    # create the registration rollback script
+    # @note The script can be created only when the target root is mounted.
+    def create
+      log.info "Creating registration rollback script #{script_path}"
+      src_file = 
File.expand_path("../../../data/registration/registration_rollback.sh", 
__FILE__)
+      ::FileUtils.cp(src_file, script_path)
+    end
+
+    # delete the script
+    def delete
+      return unless File.exist?(script_path)
+
+      log.info "Removing the registration rollback script (#{script_path})"
+      File.delete(script_path)
+    end
+
+    # can the rollback script be applied?
+    def applicable?
+      # check if the SUSEConnect tool is present, it might not be installed
+      # or not available at all (when upgrading from SLE11)
+      ret = File.exist?(File.join(root, SUSE_CONNECT))
+      log.info("File #{SUSE_CONNECT} found at #{root}: #{ret}")
+      ret
+    end
+
+    # full path to the script
+    # @return [String] path
+    def script_path
+      @path ||= File.join(root, BACKUP_DIR, DEFAULT_SCRIPT_NAME)
+    end
+  end
+end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-registration-4.0.34/src/lib/registration/storage.rb 
new/yast2-registration-4.0.36/src/lib/registration/storage.rb
--- old/yast2-registration-4.0.34/src/lib/registration/storage.rb       
2018-04-17 08:58:29.000000000 +0200
+++ new/yast2-registration-4.0.36/src/lib/registration/storage.rb       
2018-05-15 09:42:03.000000000 +0200
@@ -61,7 +61,7 @@
     end
 
     class Cache < Struct.new(:first_run, :addon_services,
-      :reg_url, :reg_url_cached, :upgrade_failed)
+      :reg_url, :reg_url_cached, :rollback, :upgrade_failed)
 
       include Singleton
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-registration-4.0.34/src/lib/registration/sw_mgmt.rb 
new/yast2-registration-4.0.36/src/lib/registration/sw_mgmt.rb
--- old/yast2-registration-4.0.34/src/lib/registration/sw_mgmt.rb       
2018-04-17 08:58:29.000000000 +0200
+++ new/yast2-registration-4.0.36/src/lib/registration/sw_mgmt.rb       
2018-05-15 09:42:03.000000000 +0200
@@ -134,7 +134,7 @@
       product_info = {
         "name"         => self_update_id,
         "arch"         => base_product.arch,
-        "version"      => base_product.version,
+        "version"      => version_without_release(base_product),
         "release_type" => nil
       }
 
@@ -242,6 +242,8 @@
     # @param product [Hash] product Hash obtained from pkg-bindings
     # @return [SUSE::Connect::Remote::Product] the remote product
     def self.remote_product(product, version_release: true)
+      # default value if it does not exist
+      product["version_version"] ||= product["version"]
       OpenStruct.new(
         arch:         product["arch"],
         identifier:   product["name"],
@@ -252,6 +254,15 @@
       )
     end
 
+    # remove relase string from version. E.g.: "15-0" --> "15"
+    # @param product [Y2Packager::Product] product
+    # @return [String] version
+    def self.version_without_release(product)
+      pkg_product = Yast::Pkg.ResolvableProperties(product.name,
+        :product, product.version).first
+      pkg_product ? pkg_product["version_version"] : product.version
+    end
+
     # create UI label for a base product
     # @param base_product [Hash] Product (hash from pkg-bindings)
     # @return [String] UI Label
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-registration-4.0.34/src/lib/registration/ui/migration_repos_workflow.rb
 
new/yast2-registration-4.0.36/src/lib/registration/ui/migration_repos_workflow.rb
--- 
old/yast2-registration-4.0.34/src/lib/registration/ui/migration_repos_workflow.rb
   2018-04-17 08:58:29.000000000 +0200
+++ 
new/yast2-registration-4.0.36/src/lib/registration/ui/migration_repos_workflow.rb
   2018-05-15 09:42:03.000000000 +0200
@@ -26,6 +26,8 @@
 require "registration/ui/migration_selection_dialog"
 require "registration/ui/migration_repos_selection_dialog"
 require "registration/ui/not_installed_products_dialog"
+require "registration/rollback_script"
+require "registration/storage"
 
 module Registration
   module UI
@@ -322,7 +324,7 @@
         remote_product = OpenStruct.new(
           arch:         base_product.arch.to_s,
           identifier:   base_product.name,
-          version:      base_product.version,
+          version:      SwMgmt.version_without_release(base_product),
           # FIXME: not supported by Y2Packager::Product yet
           release_type: nil
         )
@@ -422,6 +424,7 @@
       # @return [Symbol] workflow symbol (:next)
       def register_migration_products
         migration_progress
+        install_rollback_script if Yast::Stage.initial
 
         begin
           log.info "Registering the migration target products"
@@ -627,6 +630,18 @@
             "using the previous product. The packages from the registration " \
             "repositories can conflict with the new packages.</p>")
       end
+
+      # install the rollback script so the registration is rolled back
+      # when the upgrade is aborted or YaST crashes
+      def install_rollback_script
+        rollback = RollbackScript.new(root: Yast::Installation.destdir)
+        if rollback.applicable?
+          rollback.create
+          Storage::Cache.instance.rollback = rollback
+        else
+          log.info("The rollback script is not applicable")
+        end
+      end
     end
   end
 end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-registration-4.0.34/src/lib/registration/ui/registration_sync_workflow.rb
 
new/yast2-registration-4.0.36/src/lib/registration/ui/registration_sync_workflow.rb
--- 
old/yast2-registration-4.0.34/src/lib/registration/ui/registration_sync_workflow.rb
 2018-04-17 08:58:29.000000000 +0200
+++ 
new/yast2-registration-4.0.36/src/lib/registration/ui/registration_sync_workflow.rb
 2018-05-15 09:42:03.000000000 +0200
@@ -18,6 +18,7 @@
 require "registration/registration_ui"
 require "registration/releasever"
 require "registration/sw_mgmt"
+require "registration/storage"
 require "registration/url_helpers"
 require "registration/ui/wizard_client"
 
@@ -63,6 +64,7 @@
 
         # downgrade all installed products
         return :abort unless downgrade_products(products)
+        remove_rollback_script
 
         reload_repos
 
@@ -107,6 +109,17 @@
           success
         end
       end
+
+      # remove the rollback script after doing the rollback by YaST
+      # (avoid double rollback)
+      def remove_rollback_script
+        rollback = Storage::Cache.instance.rollback
+        return unless rollback
+
+        # remove the saved script and drop the cache
+        rollback.delete
+        Storage::Cache.instance.rollback = nil
+      end
     end
   end
 end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-registration-4.0.34/test/migration_repos_workflow_spec.rb 
new/yast2-registration-4.0.36/test/migration_repos_workflow_spec.rb
--- old/yast2-registration-4.0.34/test/migration_repos_workflow_spec.rb 
2018-04-17 08:58:29.000000000 +0200
+++ new/yast2-registration-4.0.36/test/migration_repos_workflow_spec.rb 
2018-05-15 09:42:03.000000000 +0200
@@ -124,6 +124,7 @@
       before do
         expect(Registration::SwMgmt).to receive(:init).at_least(1)
         allow_any_instance_of(Registration::RepoStateStorage).to 
receive(:write)
+        allow_any_instance_of(Registration::RollbackScript).to receive(:create)
       end
 
       let(:set_success_expectations) do
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yast2-registration-4.0.34/test/registration_spec.rb 
new/yast2-registration-4.0.36/test/registration_spec.rb
--- old/yast2-registration-4.0.34/test/registration_spec.rb     2018-04-17 
08:58:29.000000000 +0200
+++ new/yast2-registration-4.0.36/test/registration_spec.rb     2018-05-15 
09:42:03.000000000 +0200
@@ -190,9 +190,14 @@
     let(:installed_products) { 
load_yaml_fixture("installed_sles12_product.yml") }
     let(:migration_products) { 
load_yaml_fixture("migration_to_sles12_sp1.yml") }
 
+    before do
+      allow_any_instance_of(Registration::Registration).to 
receive(:connect_params)
+        .and_return({})
+    end
+
     it "returns migration products from the server" do
       expect(SUSE::Connect::YaST).to receive(:system_migrations)
-        .with(installed_products)
+        .with(installed_products, {})
         .and_return(migration_products)
       result = 
Registration::Registration.new.migration_products(installed_products)
       expect(result).to eq(migration_products)
@@ -247,6 +252,11 @@
   end
 
   describe "#synchronize_products" do
+    before do
+      allow_any_instance_of(Registration::Registration).to 
receive(:connect_params)
+        .and_return({})
+    end
+
     it "synchronizes the local products with the server" do
       expect(SUSE::Connect::YaST).to receive(:synchronize)
         .with([
@@ -256,23 +266,28 @@
                   version:      "12",
                   release_type: nil
                 )
-              ])
+              ], {})
 
       subject.synchronize_products([installed_sles])
     end
   end
 
   describe "#downgrade_product" do
+    before do
+      allow_any_instance_of(Registration::Registration).to 
receive(:connect_params)
+        .and_return({})
+    end
+
     it "downgrades the product registration" do
       expect(SUSE::Connect::YaST).to receive(:downgrade_product)
         .with(
           OpenStruct.new(
             arch:         "x86_64",
             identifier:   "SLES",
-            version:      "12-0",
+            version:      "12",
             release_type: nil
           ),
-          anything
+          {}
         )
 
       expect(subject.downgrade_product(installed_sles))
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yast2-registration-4.0.34/test/sw_mgmt_spec.rb 
new/yast2-registration-4.0.36/test/sw_mgmt_spec.rb
--- old/yast2-registration-4.0.34/test/sw_mgmt_spec.rb  2018-04-17 
08:58:29.000000000 +0200
+++ new/yast2-registration-4.0.36/test/sw_mgmt_spec.rb  2018-05-15 
09:42:03.000000000 +0200
@@ -550,4 +550,37 @@
       expect(v).to_not include("-")
     end
   end
+
+  describe ".version_without_release" do
+    let(:libzypp_product) do
+      {
+        "name"            => "SLESS",
+        "arch"            => "x86_64",
+        "version"         => "12.1-1.47",
+        "version_version" => "12.1",
+        "flavor"          => "DVD"
+      }
+    end
+    let(:base_product) do
+      instance_double(Y2Packager::Product, name: "SLES", version: "12.1-1.47", 
arch: "x86_64")
+    end
+
+    context "product can be found in libzypp stack" do
+
+      it "returns version number without release" do
+        expect(Yast::Pkg).to 
receive(:ResolvableProperties).and_return([libzypp_product])
+        expect(subject.version_without_release(base_product))
+          .to eq(libzypp_product["version_version"])
+      end
+    end
+
+    context "product cannot be found in libzypp stack" do
+
+      it "returns original version number at least" do
+        expect(Yast::Pkg).to receive(:ResolvableProperties).and_return([])
+        expect(subject.version_without_release(base_product)).to 
eq(libzypp_product["version"])
+      end
+    end
+  end
+
 end


Reply via email to