Hello community,

here is the log from the commit of package yast2-packager for openSUSE:Factory 
checked in at 2014-06-26 08:00:33
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/yast2-packager (Old)
 and      /work/SRC/openSUSE:Factory/.yast2-packager.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "yast2-packager"

Changes:
--------
--- /work/SRC/openSUSE:Factory/yast2-packager/yast2-packager.changes    
2014-06-18 07:47:53.000000000 +0200
+++ /work/SRC/openSUSE:Factory/.yast2-packager.new/yast2-packager.changes       
2014-06-26 08:00:53.000000000 +0200
@@ -1,0 +2,14 @@
+Wed Jun 25 13:18:20 UTC 2014 - [email protected]
+
+- colorize the product removal warning using HTML.Colorize method
+  to render the same color
+- 3.1.25
+
+-------------------------------------------------------------------
+Wed Jun 25 10:32:52 UTC 2014 - [email protected]
+
+- Packages.rb - added methods for checking product removal at
+  update (bnc#883047)
+- 3.1.24
+
+-------------------------------------------------------------------

Old:
----
  yast2-packager-3.1.23.tar.bz2

New:
----
  yast2-packager-3.1.25.tar.bz2

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

Other differences:
------------------
++++++ yast2-packager.spec ++++++
--- /var/tmp/diff_new_pack.C4Fv2Z/_old  2014-06-26 08:00:54.000000000 +0200
+++ /var/tmp/diff_new_pack.C4Fv2Z/_new  2014-06-26 08:00:54.000000000 +0200
@@ -17,7 +17,7 @@
 
 
 Name:           yast2-packager
-Version:        3.1.23
+Version:        3.1.25
 Release:        0
 
 BuildRoot:      %{_tmppath}/%{name}-%{version}-build

++++++ yast2-packager-3.1.23.tar.bz2 -> yast2-packager-3.1.25.tar.bz2 ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yast2-packager-3.1.23/package/yast2-packager.changes 
new/yast2-packager-3.1.25/package/yast2-packager.changes
--- old/yast2-packager-3.1.23/package/yast2-packager.changes    2014-06-13 
10:29:49.000000000 +0200
+++ new/yast2-packager-3.1.25/package/yast2-packager.changes    2014-06-25 
15:34:23.000000000 +0200
@@ -1,4 +1,18 @@
 -------------------------------------------------------------------
+Wed Jun 25 13:18:20 UTC 2014 - [email protected]
+
+- colorize the product removal warning using HTML.Colorize method
+  to render the same color
+- 3.1.25
+
+-------------------------------------------------------------------
+Wed Jun 25 10:32:52 UTC 2014 - [email protected]
+
+- Packages.rb - added methods for checking product removal at
+  update (bnc#883047)
+- 3.1.24
+
+-------------------------------------------------------------------
 Thu Jun 12 19:35:30 UTC 2014 - [email protected]
 
 - make sure float time is not reported (bnc#882240)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yast2-packager-3.1.23/package/yast2-packager.spec 
new/yast2-packager-3.1.25/package/yast2-packager.spec
--- old/yast2-packager-3.1.23/package/yast2-packager.spec       2014-06-13 
10:29:49.000000000 +0200
+++ new/yast2-packager-3.1.25/package/yast2-packager.spec       2014-06-25 
15:34:23.000000000 +0200
@@ -17,7 +17,7 @@
 
 
 Name:           yast2-packager
-Version:        3.1.23
+Version:        3.1.25
 Release:        0
 
 BuildRoot:      %{_tmppath}/%{name}-%{version}-build
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yast2-packager-3.1.23/src/modules/Packages.rb 
new/yast2-packager-3.1.25/src/modules/Packages.rb
--- old/yast2-packager-3.1.23/src/modules/Packages.rb   2014-06-13 
10:29:50.000000000 +0200
+++ new/yast2-packager-3.1.25/src/modules/Packages.rb   2014-06-25 
15:34:23.000000000 +0200
@@ -4,16 +4,26 @@
 # Package:     Package selections
 # Authors:     Anas Nashif <[email protected]>
 #
-# $Id$
 require "yast"
 
+# html_escape()
+require "erb"
+
 module Yast
   class PackagesClass < Module
     include Yast::Logger
+    include ERB::Util
 
     # All known types of resolvables
     RESOLVABLE_TYPES = [:product, :patch, :package, :pattern, :language]
 
+    # product renames needed for detecting the product update
+    # <old_name> => <new_name>
+    PRODUCT_RENAMES = {
+      "SUSE_SLES" => "SLES",
+      "SUSE_SLED" => "SLED",
+    }
+
     def main
       Yast.import "UI"
       Yast.import "Pkg"
@@ -48,6 +58,7 @@
       Yast.import "Installation"
       Yast.import "URL"
       Yast.import "PackagesProposal"
+      Yast.import "HTML"
 
       Yast.include self, "packager/load_release_notes.rb"
 
@@ -651,10 +662,120 @@
       deep_copy(ret)
     end
 
+    # group products according to the current state
+    # @param [Array<Hash>] products list of products (returned by 
Pkg.ResolvableProperties call)
+    # @return [Hash<Symbol,Object>] grouped products
+    #   the keys are :new, :removed, :kept, :updated
+    #   For each key the value is a list of products, except for :updated
+    #   key which contains a Hash with old_product => new_product mapping
+    def group_products_by_status(products)
+      to_install = products_to_install(products)
+      to_remove = products_to_remove(products)
+      to_update = products_to_update(to_install, to_remove)
+
+      # remove the updated products from selected and removed lists
+      to_remove -= to_update.keys
+      to_install -= to_update.values
+
+      ret = {
+        :new => to_install,
+        :removed => to_remove,
+        :kept => kept_products(products),
+        :updated => to_update
+      }
+
+      log.info "Product update status: #{ret}"
+
+      ret
+    end
+
+    # create a product update summary (in rich text format)
+    # usable in update proposal
+    # @see #product_update_warning how to set and display possible issues
+    # @param [Array<Hash>] products list of products (returned by 
Pkg.ResolvableProperties call)
+    # @return [Array<String>] list of rich text descriptions
+    def product_update_summary(products)
+      status = group_products_by_status(products)
+
+      # newly installed products
+      ret = status[:new].map do |product|
+        log.info "New product will be installed: #{product}"
+        _("New product <b>%s</b> will be installed") % 
h(product_label(product))
+      end
+
+      ret += status[:updated].map do |removed, installed|
+        old_product = product_label(removed)
+        new_product = product_label(installed)
+        log.info "Detected product update: #{old_product} -> #{new_product}"
+
+        (old_product == new_product) ?
+          # product update: %s is a product name
+        _("Product <b>%s</b> will be updated") % h(old_product) :
+          # product update: %{old_product} is an old product, %{new_product} 
is the new one
+        _("Product <b>%{old_product}</b> will be updated to 
<b>%{new_product}</b>") % {
+          :old_product => h(old_product), :new_product => h(new_product)
+        }
+      end
+
+      ret += status[:kept].map do |product|
+        log.info "Unchanged product: #{product}"
+        _("Product <b>%s</b> will stay installed") % h(product_label(product))
+      end
+
+      ret += status[:removed].map do |product|
+        transact_by = product["transact_by"]
+        log.warn "Product will be removed (by #{transact_by}): #{product}"
 
+        # Removing another product might be an issue
+        # (just warn if removed by user or by YaST)
+        msg = (transact_by == :user || transact_by == :app_high) ?
+          _("<b>Warning:</b> Product <b>%s</b> will be removed.") % 
h(product_label(product)) :
+          _("<b>Error:</b> Product <b>%s</b> will be automatically 
removed.</font>") \
+            % h(product_label(product))
+
+        HTML.Colorize(msg, "red")
+      end
+
+      log.info "Product update summary: #{ret}"
+      ret
+    end
 
+    # create a warning for product update summary (in rich text format) if
+    # there is an update problem
+    # @see #product_update_summary how to get the summary text
+    # @param [Array<Hash>] products list of products (returned by 
Pkg.ResolvableProperties call)
+    # @return [Hash] hash with warning attributes or empty if there is no 
problem
+    def product_update_warning(products)
+      status = group_products_by_status(products)
+
+      return {} if status[:removed].all? { |product| product["transact_by"] != 
:solver }
+
+      # Automatic product removal MUST be confirmed by user, otherwise update
+      # cannot be started.
+      return {
+        "warning_level" => :blocker,
+        # update proposal warning
+        "warning" => _(
+          "<ul><li><b>Some products are marked for automatic 
removal.</b></li>\n" \
+            "<ul><li>Contact the vendor of the removed add-on to provide you 
with a new\n" \
+            "installation media</li><li>Or select the appropriate online 
extension or module\n" \
+            "in the registration step</li><li>Or resolve the conflicts 
manually in the \n" \
+            "package management</li></ul></li></ul>")
+      }
+    end
+
+    # return a printable name of product resolvable
+    # @param [Hash] product the product (returned by Pkg.ResolvableProperties 
call)
+    # @return [String] product name
+    def product_label(product)
+      display_name = product["display_name"]
+      return display_name if display_name && !display_name.empty?
 
+      short_name = product["short_name"]
+      return short_name if short_name && !short_name.empty?
 
+      product["name"]
+    end
 
     # proposal control functions
 
@@ -2514,6 +2635,42 @@
     publish :function => :SelectKernelPackages, :type => "void ()"
     publish :function => :default_patterns, :type => "list <string> ()"
     publish :function => :log_software_selection, :type => "void ()"
+
+    private
+
+    # list of all products that will be installed (are selected)
+    def products_to_install(products)
+      products.select { |product| product["status"] == :selected }
+    end
+
+    # list of all products that will be removed
+    def products_to_remove(products)
+      products.select { |product| product["status"] == :removed }
+    end
+
+    def products_to_update(installed_products, removed_products)
+      # process the selected and removed products and find product updates
+      # map content: old_product => new_product
+      updated_products = {}
+      installed_products.each do |installed_product|
+        removed = removed_products.find do |removed_product|
+          installed_name = installed_product["name"]
+          removed_name = removed_product["name"]
+
+          # check the current product names or product renames
+          removed_name == installed_name || PRODUCT_RENAMES[removed_name] == 
installed_name
+        end
+
+        updated_products[removed] = installed_product if removed
+      end
+
+      updated_products
+    end
+
+    # list of all products that will be unchanged (kept installed)
+    def kept_products(products)
+      products.select { |product| product["status"] == :installed }
+    end
   end
 
   Packages = PackagesClass.new
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-packager-3.1.23/test/data/zypp/products_update.yml 
new/yast2-packager-3.1.25/test/data/zypp/products_update.yml
--- old/yast2-packager-3.1.23/test/data/zypp/products_update.yml        
1970-01-01 01:00:00.000000000 +0100
+++ new/yast2-packager-3.1.25/test/data/zypp/products_update.yml        
2014-06-25 15:34:23.000000000 +0200
@@ -0,0 +1,105 @@
+---
+- arch: x86_64
+  category: addon
+  description: |-
+    SUSE Linux Enterprise offers a comprehensive
+            suite of products built on a single code base.
+            The platform addresses business needs from
+            the smallest thin-client devices to the world's
+            most powerful high-performance computing
+            and mainframe servers. SUSE Linux Enterprise
+            offers common management tools and technology
+            certifications across the platform, and
+            each product is enterprise-class.
+  display_name: SUSE Linux Enterprise Server 12
+  download_size: 0
+  eol: 1420070400
+  flags: []
+  flavor: DVD
+  inst_size: 0
+  license: "SUSE(R) End User License Agreement..."
+  license_confirmed: false
+  locked: false
+  medium_nr: 0
+  name: SLES
+  product_file: SLES.prod
+  product_package: sles-release
+  register_release: ''
+  register_target: sle-12-x86_64
+  relnotes_url: 
https://www.suse.com/releasenotes/x86_64/SUSE-SLES/12/release-notes-sles.rpm
+  relnotes_urls:
+  - 
https://www.suse.com/releasenotes/x86_64/SUSE-SLES/12/release-notes-sles.rpm
+  short_name: SLES12
+  source: 0
+  status: :selected
+  summary: SUSE Linux Enterprise Server 12
+  transact_by: :app_high
+  type: addon
+  update_urls: []
+  vendor: SUSE LLC <https://www.suse.com/>
+  version: 12-0
+- arch: x86_64
+  category: base
+  description: |-
+    SUSE Linux Enterprise offers a comprehensive
+            suite of products built on a single code base.
+            The platform addresses business needs from
+            the smallest thin-client devices to the world’s
+            most powerful high-performance computing
+            and mainframe servers. SUSE Linux Enterprise
+            offers common management tools and technology
+            certifications across the platform, and
+            each product is enterprise-class.
+  display_name: SUSE Linux Enterprise Server 11 SP3
+  download_size: 0
+  flags: []
+  flavor: ''
+  inst_size: 0
+  locked: false
+  medium_nr: 0
+  name: SUSE_SLES
+  product_file: /mnt/etc/products.d/SUSE_SLES.prod
+  register_release: ''
+  register_target: sle-11-x86_64
+  register_urls:
+  - http://register.novell.com/
+  relnotes_url: 
https://www.suse.com/releasenotes/x86_64/SUSE-SLES/11-SP3/release-notes-sles.rpm
+  relnotes_urls:
+  - 
https://www.suse.com/releasenotes/x86_64/SUSE-SLES/11-SP3/release-notes-sles.rpm
+  short_name: SLES11_SP3
+  smolt_urls:
+  - http://smolt.novell.com/register.pl
+  source: -1
+  status: :removed
+  summary: SUSE Linux Enterprise Server 11 SP3
+  transact_by: :solver
+  type: base
+  update_urls: []
+  upgrades: []
+  vendor: SUSE LINUX Products GmbH, Nuernberg, Germany
+  version: 11.3-1.138
+- arch: x86_64
+  category: addon
+  description: This is the SUSE Linux Enterprise Software Development Kit
+  display_name: SUSE Linux Enterprise Software Development Kit 11 SP3
+  download_size: 0
+  flags: []
+  flavor: ''
+  inst_size: 0
+  locked: false
+  medium_nr: 0
+  name: sle-sdk
+  product_file: /mnt/etc/products.d/sle-sdk.prod
+  register_release: ''
+  register_target: sle-11-x86_64
+  relnotes_url: ''
+  short_name: sle-sdk
+  source: -1
+  status: :removed
+  summary: SUSE Linux Enterprise Software Development Kit 11 SP3
+  transact_by: :solver
+  type: addon
+  update_urls: []
+  upgrades: []
+  vendor: SUSE LINUX Products GmbH, Nuernberg, Germany
+  version: 11.3-1.69
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yast2-packager-3.1.23/test/packages_test.rb 
new/yast2-packager-3.1.25/test/packages_test.rb
--- old/yast2-packager-3.1.23/test/packages_test.rb     2014-06-13 
10:29:50.000000000 +0200
+++ new/yast2-packager-3.1.25/test/packages_test.rb     2014-06-25 
15:34:23.000000000 +0200
@@ -237,4 +237,73 @@
       expect(Yast::Packages.log_software_selection).to be_nil
     end
   end
+
+  describe "#product_label" do
+    let(:product) { load_zypp("products_update.yml").first }
+
+    it "returns display_name if available" do
+      expect(Yast::Packages.product_label(product)).to eq("SUSE Linux 
Enterprise Server 12")
+    end
+
+    it "return short_name if display_name is not available" do
+      product["display_name"] = ""
+      expect(Yast::Packages.product_label(product)).to eq("SLES12")
+    end
+
+    it "returns name when both display_name and short_name are not available" 
do
+      product["display_name"] = ""
+      product["short_name"] = ""
+      expect(Yast::Packages.product_label(product)).to eq("SLES")
+    end
+  end
+
+  describe "#group_products_by_status" do
+    let(:products) { load_zypp("products_update.yml") }
+
+    it "returns groups of the products" do
+      status = Yast::Packages.group_products_by_status(products)
+
+      expect(status[:new]).to eq([])
+
+      # no update replacement for SDK, it will be removed
+      expect(status[:removed].first["display_name"]).to \
+        eq("SUSE Linux Enterprise Software Development Kit 11 SP3")
+
+      expect(status[:kept]).to eq([])
+
+      # update from SLES11-SP3 to SLES12
+      expect(status[:updated].size).to eq(1)
+      old_product, new_product = status[:updated].first
+      expect(old_product["display_name"]).to eq("SUSE Linux Enterprise Server 
11 SP3")
+      expect(new_product["display_name"]).to eq("SUSE Linux Enterprise Server 
12")
+    end
+  end
+
+  describe "#product_update_summary" do
+    let(:products) { load_zypp("products_update.yml") }
+
+    it "describes the product update as a human readable summary" do
+      summary_string = Yast::Packages.product_update_summary(products).to_s
+
+      expect(summary_string).to match(
+        /SUSE Linux Enterprise Server 11 SP3.*will be updated to.*SUSE Linux 
Enterprise Server 12/)
+
+      expect(summary_string).to match(
+        /SUSE Linux Enterprise Software Development Kit 11 SP3.*will be 
automatically removed/)
+    end
+  end
+
+  describe "#product_update_warning" do
+    let(:products) { load_zypp("products_update.yml") }
+
+    it "returns a hash with warning when there is an automatically removed 
product" do
+      expect(Yast::Packages.product_update_warning(products)).to 
include("warning", "warning_level")
+    end
+
+    it "returns empty hash when there is no automatically removed product" do
+      products.each { |product| product["transact_by"] = :user }
+      expect(Yast::Packages.product_update_warning(products)).to eq({})
+    end
+  end
+
 end

-- 
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to