Hello community,

here is the log from the commit of package yast2-installation for 
openSUSE:Factory checked in at 2019-04-01 12:34:31
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/yast2-installation (Old)
 and      /work/SRC/openSUSE:Factory/.yast2-installation.new.25356 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "yast2-installation"

Mon Apr  1 12:34:31 2019 rev:422 rq:689423 version:4.2.0

Changes:
--------
--- /work/SRC/openSUSE:Factory/yast2-installation/yast2-installation.changes    
2019-03-21 09:51:27.410818768 +0100
+++ 
/work/SRC/openSUSE:Factory/.yast2-installation.new.25356/yast2-installation.changes
 2019-04-01 12:34:33.033816312 +0200
@@ -1,0 +2,7 @@
+Tue Mar 19 09:19:10 UTC 2019 - David Díaz <dgonza...@suse.com>
+
+- Use the select_product attribute from control file to filter
+  available products (bsc#1124590).
+- 4.2.0
+
+-------------------------------------------------------------------

Old:
----
  yast2-installation-4.1.45.tar.bz2

New:
----
  yast2-installation-4.2.0.tar.bz2

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

Other differences:
------------------
++++++ yast2-installation.spec ++++++
--- /var/tmp/diff_new_pack.4O2gP6/_old  2019-04-01 12:34:33.665816474 +0200
+++ /var/tmp/diff_new_pack.4O2gP6/_new  2019-04-01 12:34:33.669816475 +0200
@@ -17,7 +17,7 @@
 
 
 Name:           yast2-installation
-Version:        4.1.45
+Version:        4.2.0
 Release:        0
 
 BuildRoot:      %{_tmppath}/%{name}-%{version}-build

++++++ yast2-installation-4.1.45.tar.bz2 -> yast2-installation-4.2.0.tar.bz2 
++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-installation-4.1.45/package/yast2-installation.changes 
new/yast2-installation-4.2.0/package/yast2-installation.changes
--- old/yast2-installation-4.1.45/package/yast2-installation.changes    
2019-03-18 10:09:47.000000000 +0100
+++ new/yast2-installation-4.2.0/package/yast2-installation.changes     
2019-03-28 18:08:01.000000000 +0100
@@ -1,4 +1,11 @@
 -------------------------------------------------------------------
+Tue Mar 19 09:19:10 UTC 2019 - David Díaz <dgonza...@suse.com>
+
+- Use the select_product attribute from control file to filter
+  available products (bsc#1124590).
+- 4.2.0
+
+-------------------------------------------------------------------
 Fri Mar 15 10:38:35 UTC 2019 - snw...@suse.com
 
 - revert SSH textmode patches (bsc#1129375, bsc#1047470)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-installation-4.1.45/package/yast2-installation.spec 
new/yast2-installation-4.2.0/package/yast2-installation.spec
--- old/yast2-installation-4.1.45/package/yast2-installation.spec       
2019-03-18 10:09:47.000000000 +0100
+++ new/yast2-installation-4.2.0/package/yast2-installation.spec        
2019-03-28 18:08:01.000000000 +0100
@@ -16,7 +16,7 @@
 #
 
 Name:           yast2-installation
-Version:        4.1.45
+Version:        4.2.0
 Release:        0
 
 BuildRoot:      %{_tmppath}/%{name}-%{version}-build
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-installation-4.1.45/src/lib/installation/clients/inst_complex_welcome.rb
 
new/yast2-installation-4.2.0/src/lib/installation/clients/inst_complex_welcome.rb
--- 
old/yast2-installation-4.1.45/src/lib/installation/clients/inst_complex_welcome.rb
  2019-03-18 10:09:47.000000000 +0100
+++ 
new/yast2-installation-4.2.0/src/lib/installation/clients/inst_complex_welcome.rb
   2019-03-28 18:08:01.000000000 +0100
@@ -35,6 +35,7 @@
 Yast.import "Pkg"
 Yast.import "Popup"
 Yast.import "ProductControl"
+Yast.import "ProductFeatures"
 Yast.import "Stage"
 Yast.import "Timezone"
 Yast.import "Wizard"
@@ -145,16 +146,52 @@
     # not know which product we are upgrading yet) nor the product selector
     # (as you cannot change the product during upgrade).
     #
+    # It could return a list with pre-selected product(s), @see 
#preselected_base_product.
+    #
     # @return [Array<Y2Packager::Product>] List of available base products;
     # empty list in update mode.
     def products
       return @products if @products
 
-      @products = Y2Packager::Product.available_base_products
+      @products = preselected_base_product || available_base_products
       @products = [] if Mode.update && @products.size > 1
       @products
     end
 
+    # Returns, if any, the preselected base product (bsc#1124590)
+    #
+    # A product can be pre-selected using the `select_product` element in the 
software section
+    # in the control file.
+    #
+    # @return [nil, Array<Y2Packager::Product>] nil when no preselected 
product in control file,
+    #                                           a list containing the 
preselected base product, or
+    #                                           empty list if preselected 
product is not available
+    def preselected_base_product
+      selected_product_name = ProductFeatures.GetStringFeature("software", 
"select_product")
+
+      return if selected_product_name.empty?
+
+      log.info("control.xml wants to preselect the #{selected_product_name} 
product")
+
+      filtered_base_products = available_base_products.select do |product|
+        product.name == selected_product_name
+      end
+      discarded_base_products = available_base_products - 
filtered_base_products
+
+      if !discarded_base_products.empty?
+        log.info("Ignoring the other available products: 
#{discarded_base_products.map(&:name)}")
+      end
+
+      filtered_base_products
+    end
+
+    # Returns all available base products
+    #
+    # @return [Array<Y2Packager::Product>] List of available base products
+    def available_base_products
+      @available_base_products ||= Y2Packager::Product.available_base_products
+    end
+
     # Determine whether some product is available or not
     #
     # @return [Boolean] false if no product available; true otherwise
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-installation-4.1.45/test/lib/clients/inst_complex_welcome_test.rb 
new/yast2-installation-4.2.0/test/lib/clients/inst_complex_welcome_test.rb
--- old/yast2-installation-4.1.45/test/lib/clients/inst_complex_welcome_test.rb 
2019-03-18 10:09:47.000000000 +0100
+++ new/yast2-installation-4.2.0/test/lib/clients/inst_complex_welcome_test.rb  
2019-03-28 18:08:01.000000000 +0100
@@ -9,16 +9,23 @@
   let(:product) do
     instance_double(
       Y2Packager::Product,
+      name:                           "Product",
       license_confirmation_required?: license_needed?,
       license?:                       license?,
       license:                        "license content",
       license_confirmed?:             license_confirmed?
     )
   end
+  let(:other_product) do
+    instance_double(
+      Y2Packager::Product,
+      name: "Other Product"
+    )
+  end
+
   let(:license_needed?) { true }
   let(:license_confirmed?) { false }
   let(:license?) { true }
-  let(:other_product) { instance_double(Y2Packager::Product) }
   let(:products) { [product, other_product] }
   let(:auto) { false }
   let(:config_mode) { false }
@@ -238,7 +245,7 @@
       context "when running on install mode" do
         let(:update_mode) { false }
 
-        context "and more than 1 product is availble" do
+        context "and more than 1 product is available" do
           let(:products) { [product, other_product] }
 
           it "runs the complex welcome dialog with the list of available 
products" do
@@ -257,6 +264,36 @@
             subject.main
           end
         end
+
+        # Test the behavior when the product name is hardcoded in the control 
file, which solves the
+        # issue with the wrong selected product during a network installation 
having multiples
+        # products in a single repository, bsc#1124590
+        context "and the control file contains a preselected product name" do
+          let(:products) { [product, other_product] }
+          let(:preselected_product) { "Other Product" }
+
+          before do
+            allow(Yast::ProductFeatures).to receive(:GetStringFeature)
+              .with("software", "select_product")
+              .and_return(preselected_product)
+          end
+
+          it "runs the complex welcome dialog with the preselected product" do
+            expect(Installation::Dialogs::ComplexWelcome).to receive(:run)
+              .with([other_product], anything)
+            subject.main
+          end
+
+          context "but it does not match with available products" do
+            let(:preselected_product) { "Unknown product" }
+
+            it "runs the complex welcome dialog with no products" do
+              expect(Installation::Dialogs::ComplexWelcome).to receive(:run)
+                .with([], anything)
+              subject.main
+            end
+          end
+        end
       end
 
       context "when running on update mode" do


Reply via email to