Hello community, here is the log from the commit of package yast2-add-on for openSUSE:Factory checked in at 2020-07-21 15:47:00 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/yast2-add-on (Old) and /work/SRC/openSUSE:Factory/.yast2-add-on.new.3592 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "yast2-add-on" Tue Jul 21 15:47:00 2020 rev:107 rq:821773 version:4.3.2 Changes: -------- --- /work/SRC/openSUSE:Factory/yast2-add-on/yast2-add-on.changes 2020-06-11 14:44:44.449389289 +0200 +++ /work/SRC/openSUSE:Factory/.yast2-add-on.new.3592/yast2-add-on.changes 2020-07-21 15:48:48.124177847 +0200 @@ -1,0 +2,7 @@ +Thu Jul 16 10:17:01 UTC 2020 - Imobach Gonzalez Sosa <igonzalezs...@suse.com> + +- Do not export registered add-ons, as they should be included + in the <suse_register/> section of the profile (bsc#1174202). +- 4.3.2 + +------------------------------------------------------------------- Old: ---- yast2-add-on-4.3.1.tar.bz2 New: ---- yast2-add-on-4.3.2.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ yast2-add-on.spec ++++++ --- /var/tmp/diff_new_pack.jBqVx3/_old 2020-07-21 15:48:49.244179231 +0200 +++ /var/tmp/diff_new_pack.jBqVx3/_new 2020-07-21 15:48:49.248179236 +0200 @@ -17,7 +17,7 @@ Name: yast2-add-on -Version: 4.3.1 +Version: 4.3.2 Release: 0 Summary: YaST2 - Add-On media installation code License: GPL-2.0-only ++++++ yast2-add-on-4.3.1.tar.bz2 -> yast2-add-on-4.3.2.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-add-on-4.3.1/package/yast2-add-on.changes new/yast2-add-on-4.3.2/package/yast2-add-on.changes --- old/yast2-add-on-4.3.1/package/yast2-add-on.changes 2020-06-10 17:49:53.000000000 +0200 +++ new/yast2-add-on-4.3.2/package/yast2-add-on.changes 2020-07-19 23:21:03.000000000 +0200 @@ -1,4 +1,11 @@ ------------------------------------------------------------------- +Thu Jul 16 10:17:01 UTC 2020 - Imobach Gonzalez Sosa <igonzalezs...@suse.com> + +- Do not export registered add-ons, as they should be included + in the <suse_register/> section of the profile (bsc#1174202). +- 4.3.2 + +------------------------------------------------------------------- Wed Jun 10 14:04:00 UTC 2020 - Josef Reidinger <jreidin...@suse.com> - Reduce autoyast profile size if addons are empty (bsc#1172749) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-add-on-4.3.1/package/yast2-add-on.spec new/yast2-add-on-4.3.2/package/yast2-add-on.spec --- old/yast2-add-on-4.3.1/package/yast2-add-on.spec 2020-06-10 17:49:53.000000000 +0200 +++ new/yast2-add-on-4.3.2/package/yast2-add-on.spec 2020-07-19 23:21:03.000000000 +0200 @@ -17,7 +17,7 @@ Name: yast2-add-on -Version: 4.3.1 +Version: 4.3.2 Release: 0 Summary: YaST2 - Add-On media installation code License: GPL-2.0-only diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-add-on-4.3.1/src/modules/AddOnOthers.rb new/yast2-add-on-4.3.2/src/modules/AddOnOthers.rb --- old/yast2-add-on-4.3.1/src/modules/AddOnOthers.rb 2020-06-10 17:49:53.000000000 +0200 +++ new/yast2-add-on-4.3.2/src/modules/AddOnOthers.rb 2020-07-19 23:21:03.000000000 +0200 @@ -58,18 +58,65 @@ # </add_on_others> # </add-on> def Export - others = @add_on_others.map do |p| - { "media_url" => p["url"], - "alias" => p["alias"], - "priority" => p["priority"], - "name" => p["name"], - "product_dir" => p["product_dir"] } + others = @add_on_others.each_with_object([]) do |addon, all| + next if registered_addon?(addon) + + all << { + "media_url" => addon["url"], + "alias" => addon["alias"], + "priority" => addon["priority"], + "name" => addon["name"], + "product_dir" => addon["product_dir"] + } end { "add_on_others" => others } end publish function: :Export, type: "map ()" publish function: :Read, type: "map()" + + private + + # Determine whether an addon corresponds to a registered product + # + # @param addon [Hash] Addon data + # @return [Boolean] + def registered_addon?(addon) + return false unless addon["url"] + + url = normalize_url(addon["url"]) + registered_repositories_urls.include?(url) + end + + # Returns the URLs corresponding to registered products repositories + # + # @return [Array<URI>] + def registered_repositories_urls + return @registered_repositories_urls if @registered_repositories_urls + + begin + require "registration/registration" + rescue LoadError + return [] + end + activated_products = Registration::Registration.new.activated_products + repositories = activated_products.map(&:repositories).flatten + @registered_repositories_urls = repositories.map { |r| normalize_url(r["url"]) } + end + + # Normalizes the URL to make the comparison easier + # + # It removes the query, the fragment and the trailing '/' character is found. + # + # @param url [URI,String] URL to normalize + # @return [URI] + def normalize_url(url) + uri = URI(url) + uri.fragment = nil + uri.query = nil + uri.path = uri.path.delete_suffix("/") + uri + end end AddOnOthers = AddOnOthersClass.new diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-add-on-4.3.1/test/addon_others_test.rb new/yast2-add-on-4.3.2/test/addon_others_test.rb --- old/yast2-add-on-4.3.1/test/addon_others_test.rb 2020-06-10 17:49:53.000000000 +0200 +++ new/yast2-add-on-4.3.2/test/addon_others_test.rb 2020-07-19 23:21:03.000000000 +0200 @@ -44,7 +44,7 @@ let(:repo_hash) do { "alias" => "user defined", - "url" => "http://xxx.url", + "url" => "http://xxx.url?foo=bar", "name" => "user_defined", "priority" => 19, "product_dir" => "/" } @@ -57,6 +57,8 @@ .and_return(installed_products) allow(Yast::Pkg).to receive(:SourceGetCurrent).with(true) .and_return([0, 1, 2, 3, 4]) + allow(subject).to receive(:require).with("registration/registration") + .and_raise(LoadError) end describe "#Read" do @@ -72,7 +74,6 @@ end describe "#Export" do - context "installed products and add-ons are available" do let(:ret) do { "media_url" => repo_hash["url"], @@ -82,12 +83,42 @@ "product_dir" => repo_hash["product_dir"] } end - it "returns an array of user defined repos in AY format" do + before do allow(Yast::Pkg).to receive(:SourceGeneralData).with(4) .and_return(repo_hash) + end + + it "returns an array of user defined repos in AY format" do Yast::AddOnOthers.Read() expect(Yast::AddOnOthers.Export).to eq("add_on_others" => [ret]) end + + context "when an add-on is registered" do + let(:registration_module) do + double("Registration::Registration", new: registration) + end + + let(:registration) do + instance_double("Registration::Registration", activated_products: [product]) + end + + let(:product) do + double("SUSE::Connect::Remote::Product", repositories: [scc_repo]) + end + + let(:scc_repo) do + { "url" => "http://xxx.url" } + end + + before do + allow(subject).to receive(:require).with("registration/registration") + stub_const("Registration::Registration", registration_module) + end + + it "does not export such an addon" do + expect(Yast::AddOnOthers.Export).to eq("add_on_others" => []) + end + end end end end