Hello community, here is the log from the commit of package yast2-add-on for openSUSE:Factory checked in at 2017-12-13 11:57:22 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/yast2-add-on (Old) and /work/SRC/openSUSE:Factory/.yast2-add-on.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "yast2-add-on" Wed Dec 13 11:57:22 2017 rev:86 rq:555930 version:4.0.3 Changes: -------- --- /work/SRC/openSUSE:Factory/yast2-add-on/yast2-add-on.changes 2017-11-04 10:21:57.130901807 +0100 +++ /work/SRC/openSUSE:Factory/.yast2-add-on.new/yast2-add-on.changes 2017-12-13 11:57:53.526058107 +0100 @@ -1,0 +2,7 @@ +Mon Dec 4 13:16:40 UTC 2017 - lsle...@suse.cz + +- Fixed adding multiple products from a multi-product medium + (bsc#1062813) +- 4.0.3 + +------------------------------------------------------------------- Old: ---- yast2-add-on-4.0.2.tar.bz2 New: ---- yast2-add-on-4.0.3.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ yast2-add-on.spec ++++++ --- /var/tmp/diff_new_pack.lgQJsK/_old 2017-12-13 11:57:54.182026440 +0100 +++ /var/tmp/diff_new_pack.lgQJsK/_new 2017-12-13 11:57:54.186026247 +0100 @@ -17,7 +17,7 @@ Name: yast2-add-on -Version: 4.0.2 +Version: 4.0.3 Release: 0 Summary: YaST2 - Add-On media installation code License: GPL-2.0 @@ -27,7 +27,9 @@ BuildRequires: update-desktop-files BuildRequires: yast2 >= 3.0.1 BuildRequires: yast2-devtools >= 3.1.10 -BuildRequires: rubygem(yast-rake) +BuildRequires: yast2-packager +BuildRequires: rubygem(%{rb_default_ruby_abi}:rspec) +BuildRequires: rubygem(%{rb_default_ruby_abi}:yast-rake) Requires: autoyast2-installation # ProductProfile Requires: yast2 >= 3.0.1 ++++++ yast2-add-on-4.0.2.tar.bz2 -> yast2-add-on-4.0.3.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-add-on-4.0.2/README.md new/yast2-add-on-4.0.3/README.md --- old/yast2-add-on-4.0.2/README.md 2017-10-31 13:50:18.641458430 +0100 +++ new/yast2-add-on-4.0.3/README.md 2017-12-11 13:30:03.000000000 +0100 @@ -2,4 +2,4 @@ [![Travis Build](https://travis-ci.org/yast/yast-add-on.svg?branch=master)](https://travis-ci.org/yast/yast-add-on) [![Jenkins Build](http://img.shields.io/jenkins/s/https/ci.opensuse.org/yast-add-on-master.svg)](https://ci.opensuse.org/view/Yast/job/yast-add-on-master/) - +[![Coverage Status](https://coveralls.io/repos/github/yast/yast-add-on/badge.svg?branch=master)](https://coveralls.io/github/yast/yast-add-on?branch=master) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-add-on-4.0.2/package/yast2-add-on.changes new/yast2-add-on-4.0.3/package/yast2-add-on.changes --- old/yast2-add-on-4.0.2/package/yast2-add-on.changes 2017-10-31 13:50:18.641458430 +0100 +++ new/yast2-add-on-4.0.3/package/yast2-add-on.changes 2017-12-11 13:30:03.000000000 +0100 @@ -1,4 +1,11 @@ ------------------------------------------------------------------- +Mon Dec 4 13:16:40 UTC 2017 - lsle...@suse.cz + +- Fixed adding multiple products from a multi-product medium + (bsc#1062813) +- 4.0.3 + +------------------------------------------------------------------- Tue Oct 31 12:41:46 UTC 2017 - lsle...@suse.cz - Hide the "I would like to install an additional Add On Product" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-add-on-4.0.2/package/yast2-add-on.spec new/yast2-add-on-4.0.3/package/yast2-add-on.spec --- old/yast2-add-on-4.0.2/package/yast2-add-on.spec 2017-10-31 13:50:18.641458430 +0100 +++ new/yast2-add-on-4.0.3/package/yast2-add-on.spec 2017-12-11 13:30:03.000000000 +0100 @@ -17,17 +17,19 @@ Name: yast2-add-on -Version: 4.0.2 +Version: 4.0.3 Release: 0 Summary: YaST2 - Add-On media installation code License: GPL-2.0 Group: System/YaST Url: http://github.com/yast/yast-add-on Source0: %{name}-%{version}.tar.bz2 -BuildRequires: rubygem(yast-rake) +BuildRequires: rubygem(%{rb_default_ruby_abi}:yast-rake) +BuildRequires: rubygem(%{rb_default_ruby_abi}:rspec) BuildRequires: update-desktop-files BuildRequires: yast2 >= 3.0.1 BuildRequires: yast2-devtools >= 3.1.10 +BuildRequires: yast2-packager Requires: autoyast2-installation # ProductProfile Requires: yast2 >= 3.0.1 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-add-on-4.0.2/src/include/add-on/add-on-workflow.rb new/yast2-add-on-4.0.3/src/include/add-on/add-on-workflow.rb --- old/yast2-add-on-4.0.2/src/include/add-on/add-on-workflow.rb 2017-10-31 13:50:18.645458430 +0100 +++ new/yast2-add-on-4.0.3/src/include/add-on/add-on-workflow.rb 2017-12-11 13:30:03.000000000 +0100 @@ -54,6 +54,11 @@ @new_addon_name = "" @product_infos = {} + + # track the added repositories, using AddOnProduct.src_id does not work + # for multiple repository medium + # Arry<Fixnum> + @added_repos = [] end # Initialize current inst. sources @@ -129,44 +134,32 @@ # used Add-Ons are stored in AddOnProduct::add_on_products # bnc #393620 def AddAddOnToStore(src_id) - if src_id == nil - Builtins.y2error("Wrong src_id: %1", src_id) + if src_id.nil? + log.error("Wrong src_id: #{src_id}") return end # BNC #450274 # Prevent from adding one product twice - matching_products = Builtins.filter(AddOnProduct.add_on_products) do |one_product| - Ops.get_integer(one_product, "media", -1) == src_id + matching_product = AddOnProduct.add_on_products.find do |product| + product["media"] == src_id end - if Ops.greater_than(Builtins.size(matching_products), 0) - Builtins.y2milestone("Product already added: %1", matching_products) + if matching_product + log.info("Product already added: #{matching_product}") return end source_data = Pkg.SourceGeneralData(src_id) - AddOnProduct.add_on_products = Builtins.add( - AddOnProduct.add_on_products, + AddOnProduct.add_on_products << { - "media" => AddOnProduct.src_id, + "media" => src_id, # table cell - "product" => Ops.get_locale( - source_data, - "name", - Ops.get_locale( - source_data, - "alias", - _("No product found in the repository.") - ) - ), - "media_url" => Ops.get_string(source_data, "url", ""), - "product_dir" => Ops.get_string(source_data, "product_dir", "") + "product" => source_data["name"], + "media_url" => source_data["url"], + "product_dir" => source_data["product_dir"] } - ) - - nil end # Run dialog for selecting the media @@ -220,51 +213,8 @@ ret = Sequencer.Run(aliases, sequence) log.info "Repository sequence result: #{ret}" - if ret == :next - sources_after = Pkg.SourceGetCurrent(false) - Builtins.y2milestone("Sources with new one added: %1", sources_after) - - # bnc #393011 - # AddOnProduct::src_id must be set to the latest source ID - src_id_found = false - - Builtins.foreach(sources_after) do |one_source| - if !Builtins.contains(sources_before, one_source) - AddOnProduct.src_id = one_source - Builtins.y2milestone("Added source ID is: %1", AddOnProduct.src_id) - src_id_found = true - raise Break - end - end - - if src_id_found - # BNC #481828: Using LABEL from content file as a repository name - Packages.AdjustSourcePropertiesAccordingToProduct(AddOnProduct.src_id) - # used add-ons are stored in a special list - AddAddOnToStore(AddOnProduct.src_id) - else - AddOnProduct.src_id = Ops.get( - sources_after, - Ops.subtract(Builtins.size(sources_after), 1), - 0 - ) - Builtins.y2warning("Fallback src_id: %1", AddOnProduct.src_id) - end - - # BNC #441380 - # Refresh and load the added source, this is needed since the unified - # functions from packager are used. - Pkg.SourceRefreshNow(AddOnProduct.src_id) - Pkg.SourceLoad - - # BNC #468449 - # It may happen that the add-on control file contains some code that - # would drop the changes made, so it's better to save the soruces now - if Mode.normal - Builtins.y2milestone("Saving all sources") - Pkg.SourceSaveAll - end - end + # activate the changes + activate_addon_changes(sources_before) if ret == :next AddOnProduct.last_ret = ret Builtins.y2milestone("MediaSelect Dialog ret: %1", ret) @@ -457,50 +407,29 @@ # BNC #474745 # Installs all the products from just added add-on media + # @return [Symbol] always returns the :next symbol def InstallProduct - Builtins.y2milestone("AddOnID: %1", AddOnProduct.src_id) + log.info("Installing products from #{@added_repos.inspect}") - if AddOnProduct.src_id == nil || Ops.less_than(AddOnProduct.src_id, 0) - Builtins.y2error("No source has been added") + if @added_repos.empty? + log.error("No source has been added") return :next end all_products = Pkg.ResolvableProperties("", :product, "") - - # `selected and `installed products - # each map contains "name" and "version" - s_a_i_products = [] - - Builtins.foreach(all_products) do |one_product| - s_a_i_products = Builtins.add( - s_a_i_products, - { - "name" => Ops.get_string(one_product, "name", "xyz"), - "version" => Ops.get_string(one_product, "version", "abc") - } - ) - end - - Builtins.foreach(all_products) do |one_product| - # map this_product = $["name":one_product["name"]:"zyx", "version":one_product["version"]:"cba"]; - + all_products.each do |product| # Product doesn't match the new source ID - if Ops.get_integer(one_product, "source", -255) != AddOnProduct.src_id + next unless @added_repos.include?(product["source"]) + # Product is not available (either `installed or `selected or ...) + if product["status"] != :available + log.info("Skipping product #{product["name"].inspect} with status " \ + "#{product["status"].inspect}") next end - # Product is not available (either `installed or `selected or ...) - next if Ops.get_symbol(one_product, "status", :available) != :available - # // Available but also already installed or selected - # if (contains (s_a_i_products, this_product)) { - # y2warning ("Product %1 is already installed", this_product); - # return; - # } - product_name = Ops.get_string(one_product, "name", "-Unknown-Product-") - Builtins.y2milestone( - "Selecting product '%1' for installation -> %2", - product_name, - Pkg.ResolvableInstall(product_name, :product) - ) + + success = Pkg.ResolvableInstall(product["name"], :product) + + log.info("Selecting product '#{product["name"]}' for installation -> #{success}") end :next @@ -843,11 +772,8 @@ # Check new product compliance; may abort the installation def CheckCompliance - if ProductProfile.CheckCompliance(AddOnProduct.src_id) - return :next - else - return :abort - end + compliant = @added_repos.all?{ |src_id| ProductProfile.CheckCompliance(src_id) } + compliant ? :next : :abort end def RunWizard @@ -857,7 +783,6 @@ "check_compliance" => lambda { CheckCompliance() } } - sequence = { "ws_start" => "media", "media" => { @@ -866,16 +791,6 @@ :finish => "check_compliance", :skip => :skip }, - # "catalog" : $[ - # `abort : `abort, - # `next : "product", - # `finish : `next, - # ], - # "product" : $[ - # `abort : `abort, - # `next : `next, - # `finish : `next, - # ], "check_compliance" => { :abort => :abort, :next => "install_product" @@ -890,9 +805,10 @@ end def RunAutorunWizard - aliases = { "catalog" => lambda { CatalogSelect() }, "product" => lambda do - ProductSelect() - end } + aliases = { + "catalog" => lambda { CatalogSelect() }, + "product" => lambda { ProductSelect() } + } sequence = { "ws_start" => "catalog", @@ -902,8 +818,6 @@ Sequencer.Run(aliases, sequence) end - - def Redraw(enable_back, enable_next, enable_abort, back_button, next_button, abort_button) Builtins.y2milestone("Called Redraw()") # main screen heading @@ -1174,33 +1088,27 @@ log.info "Subworkflow result: ret2: #{ret2}" if ret2 == :next + # FIXME: can be these two iterations joined? # Add-On product has been added, integrate it (change workflow, use y2update) - AddOnProduct.Integrate(AddOnProduct.src_id) - + @added_repos.each { |src_id| AddOnProduct.Integrate(src_id) } # check whether it requests registration (FATE #301312) - AddOnProduct.PrepareForRegistration(AddOnProduct.src_id) + @added_repos.each { |src_id| AddOnProduct.PrepareForRegistration(src_id) } + some_addon_changed = true # do not keep first_time, otherwise summary won't be shown during installation ret = nil if ret == :skip_to_add elsif ret2 == :abort || ret2 == :cancel - Builtins.y2milestone("Add-on sequence aborted") - - if AddOnProduct.src_id != nil - Builtins.y2milestone( - "Removing add-on repository: %1", - AddOnProduct.src_id - ) + log.info("Aborted, removing add-on repositories: #{@added_repos.inspect}") - # remove the repository - Pkg.SourceDelete(AddOnProduct.src_id) + # remove the repository + @added_repos.each do |src_id| + Pkg.SourceDelete(src_id) - AddOnProduct.add_on_products = Builtins.filter( - AddOnProduct.add_on_products - ) do |add_on_product| - Ops.get_integer(add_on_product, "media", -1) != - AddOnProduct.src_id + AddOnProduct.add_on_products.reject! do |add_on_product| + add_on_product["media"] == src_id end end + # properly return abort in installation ret = :abort if ret == :skip_to_add # extra handling for the global enable checkbox @@ -1994,5 +1902,46 @@ ret end + + def activate_addon_changes(sources_before) + sources_after = Pkg.SourceGetCurrent(false) + Builtins.y2milestone("Sources with new one added: %1", sources_after) + + # collect the newly added repositories + @added_repos = [] + sources_after.each do |source| + next if sources_before.include?(source) + + @added_repos << source + log.info("Added source ID: #{source}") + end + + if !@added_repos.empty? + @added_repos.each do |src_id| + # BNC #481828: Using LABEL from content file as a repository name + Packages.AdjustSourcePropertiesAccordingToProduct(src_id) + # used add-ons are stored in a special list + AddAddOnToStore(src_id) + end + else + # TODO: can this situation actually happen? + @added_repos << sources_after.last + log.warn("Fallback src_id: #{sources_after.last}") + end + + # BNC #441380 + # Refresh and load the added sources, this is needed since the unified + # functions from packager are used. + @added_repos.each { |src_id| Pkg.SourceRefreshNow(src_id) } + Pkg.SourceLoad + + # BNC #468449 + # It may happen that the add-on control file contains some code that + # would drop the changes made, so it's better to save the soruces now + if Mode.normal + Builtins.y2milestone("Saving all sources") + Pkg.SourceSaveAll + end + end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-add-on-4.0.2/test/repositories_include_test.rb new/yast2-add-on-4.0.3/test/repositories_include_test.rb --- old/yast2-add-on-4.0.2/test/repositories_include_test.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-add-on-4.0.3/test/repositories_include_test.rb 2017-12-11 13:30:03.000000000 +0100 @@ -0,0 +1,108 @@ +require_relative "./test_helper" + +Yast.import "Pkg" +Yast.import "Sequencer" +Yast.import "Packages" + +# just a wrapper class for the repositories_include.rb +module Yast + class AddOnWorkflowIncludeTesterClass < Module + extend Yast::I18n + + def main + Yast.include self, "add-on/add-on-workflow.rb" + end + end +end + +AddonIncludeTester = Yast::AddOnWorkflowIncludeTesterClass.new +AddonIncludeTester.main + +describe "Yast::AddOnWorkflowInclude" do + subject { AddonIncludeTester } + + describe "#MediaSelect" do + before do + allow(Yast::Pkg).to receive(:SourceGetCurrent).and_return([]) + allow(Yast::Sequencer).to receive(:Run).and_return(:next) + allow(Yast::Packages).to receive(:AdjustSourcePropertiesAccordingToProduct) + allow(subject).to receive(:AddAddOnToStore) + allow(Yast::Pkg).to receive(:SourceRefreshNow) + allow(Yast::Pkg).to receive(:SourceLoad) + allow(Yast::Pkg).to receive(:SourceSaveAll) + allow(Yast::AddOnProduct).to receive(:last_ret=) + end + + it "returns the UI symbol" do + expect(Yast::Sequencer).to receive(:Run).and_return(:next) + expect(subject.MediaSelect).to eq(:next) + end + + it "refreshes all added repositories and loads the available packages" do + # no initial repository, then 2 repositories added + allow(Yast::Pkg).to receive(:SourceGetCurrent).and_return([], [42,43]) + expect(Yast::Pkg).to receive(:SourceRefreshNow).with(42) + expect(Yast::Pkg).to receive(:SourceRefreshNow).with(43) + expect(Yast::Pkg).to receive(:SourceLoad) + + subject.MediaSelect + end + end + + describe "#InstallProduct" do + context "no repository has been added" do + before do + AddonIncludeTester.instance_variable_set("@added_repos", []) + end + + it "does not select any product" do + expect(Yast::Pkg).to_not receive(:ResolvableInstall) + AddonIncludeTester.InstallProduct + end + + it "returns :next" do + expect(AddonIncludeTester.InstallProduct).to eq(:next) + end + end + + context "some repositories have been added" do + # add-on products in the repositories + let(:p1) { { "name" => "product1", "source" => 42, "status" => :available } } + let(:p2) { { "name" => "product2", "source" => 43, "status" => :available } } + + before do + AddonIncludeTester.instance_variable_set("@added_repos", [42, 43]) + end + + it "returns :next" do + allow(Yast::Pkg).to receive(:ResolvableProperties).and_return([]) + allow(Yast::Pkg).to receive(:ResolvableInstall) + expect(AddonIncludeTester.InstallProduct).to eq(:next) + end + + it "selects the available products from the added repositories" do + expect(Yast::Pkg).to receive(:ResolvableProperties).and_return([p1, p2]) + expect(Yast::Pkg).to receive(:ResolvableInstall).with("product1", :product) + expect(Yast::Pkg).to receive(:ResolvableInstall).with("product2", :product) + + AddonIncludeTester.InstallProduct + end + + it "ignores the products from other repositories" do + expect(Yast::Pkg).to receive(:ResolvableProperties).and_return( + [p1.merge("source" => 1), p2.merge("source" => 2)]) + expect(Yast::Pkg).to_not receive(:ResolvableInstall) + + AddonIncludeTester.InstallProduct + end + + it "ignores the already selected repositories" do + expect(Yast::Pkg).to receive(:ResolvableProperties).and_return( + [p1.merge("status" => :selected), p2.merge("status" => :selected)]) + expect(Yast::Pkg).to_not receive(:ResolvableInstall) + + AddonIncludeTester.InstallProduct + end + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-add-on-4.0.2/test/test_helper.rb new/yast2-add-on-4.0.3/test/test_helper.rb --- old/yast2-add-on-4.0.2/test/test_helper.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-add-on-4.0.3/test/test_helper.rb 2017-12-11 13:30:03.000000000 +0100 @@ -0,0 +1,28 @@ +srcdir = File.expand_path("../../src", __FILE__) +y2dirs = ENV.fetch("Y2DIR", "").split(":") +ENV["Y2DIR"] = y2dirs.unshift(srcdir).join(":") + +# force English locale to avoid failing tests due to translations +# when running in non-English environment +ENV["LC_ALL"] = "en_US.UTF-8" + +require "yast" + +if ENV["COVERAGE"] + require "simplecov" + SimpleCov.start do + add_filter "/test/" + end + + # track all ruby files under src + SimpleCov.track_files("#{srcdir}/**/*.rb") + + # use coveralls for on-line code coverage reporting at Travis CI + if ENV["TRAVIS"] + require "coveralls" + SimpleCov.formatters = [ + SimpleCov::Formatter::HTMLFormatter, + Coveralls::SimpleCov::Formatter + ] + end +end