diff --git a/package/yast2-migration.changes b/package/yast2-migration.changes index c6b4b66..dd4d726 100644 --- a/package/yast2-migration.changes +++ b/package/yast2-migration.changes @@ -1,3 +1,11 @@ +------------------------------------------------------------------- +Tue Nov 19 12:00:26 CET 2019 - schubi@suse.de + +- Using Y2Packager::Resolvable.any? and Y2Packager::Resolvable.find + in order to decrease the required memory (bsc#1132650, + bsc#1140037). +- 4.2.4 + ------------------------------------------------------------------- Mon Oct 28 09:54:49 UTC 2019 - José Iván López González diff --git a/package/yast2-migration.spec b/package/yast2-migration.spec index 63af65b..356a42f 100644 --- a/package/yast2-migration.spec +++ b/package/yast2-migration.spec @@ -17,7 +17,7 @@ Name: yast2-migration -Version: 4.2.3 +Version: 4.2.4 Release: 0 Summary: YaST2 - Online migration Group: System/YaST @@ -38,7 +38,8 @@ BuildRequires: yast2-update BuildRequires: update-desktop-files Requires: yast2 >= 3.1.130 -Requires: yast2-packager +# product_update_summary, product_update_warning +Requires: yast2-packager >= 4.2.33 Requires: yast2-pkg-bindings Requires: yast2-ruby-bindings # new rollback client diff --git a/src/lib/migration/proposal_client.rb b/src/lib/migration/proposal_client.rb index af637df..1107a2c 100644 --- a/src/lib/migration/proposal_client.rb +++ b/src/lib/migration/proposal_client.rb @@ -15,6 +15,7 @@ require "installation/proposal_client" require "migration/repository_checker" +require "y2packager/resolvable" module Migration # The proposal client for online migration @@ -45,7 +46,7 @@ def make_proposal(_attrs) # recalculate the disk space usage data SpaceCalculation.GetPartitionInfo - products = Pkg.ResolvableProperties("", :product, "") + products = Y2Packager::Resolvable.find(kind: :product) ret = { "preformatted_proposal" => product_summary(products), @@ -92,7 +93,7 @@ def description # check the current products for possible issues, add product warnings # to the proposal summary # @param [Hash] proposal the proposal summary (the value is modified) - # @param [Array] products list of the current products (from libzypp) + # @param [Array] products list of the current products def add_warnings(proposal, products) package_warnings = Packages.product_update_warning(products) repo_warnings = check_repositories(products) @@ -112,7 +113,7 @@ def add_warnings(proposal, products) end # create a product summary for migration proposal - # @param [Array] products the current libzypp products + # @param [Array] products the current libzypp products # @return [String] product summary text (RichText) def product_summary(products) summary_text = Packages.product_update_summary(products).map do |item| @@ -123,7 +124,7 @@ def product_summary(products) end # check for obsolete repositories - # @param [Array] products the current libzypp products + # @param [Array] products the current libzypp products # @return [Hash] warning for the proposal summary, an empty Hash is returned # if everything is OK def check_repositories(products) diff --git a/src/lib/migration/repository_checker.rb b/src/lib/migration/repository_checker.rb index 62352c4..f79cf86 100644 --- a/src/lib/migration/repository_checker.rb +++ b/src/lib/migration/repository_checker.rb @@ -19,6 +19,7 @@ # ------------------------------------------------------------------------------ require "yast" +require "y2packager/resolvable" module Migration # Check for possible repository issues in the libzypp products @@ -26,7 +27,7 @@ class RepositoryChecker include Yast::Logger # constructor - # @param [Array] products list of products from pkg-bindings + # @param [Array] products list of products def initialize(products) @products = products end @@ -35,7 +36,7 @@ def initialize(products) # (an upgrade is available for them) # return [Array] repositories providing obsolete products def obsolete_product_repos - old_repos = obsolete_available_products.map { |product| product["source"] } + old_repos = obsolete_available_products.map(&:source) # make sure the system repo or invalid values are filtered out # (related to gh#yast/yast-registration#198) @@ -53,7 +54,7 @@ def obsolete_product_repos attr_accessor :products # get the available obsolete products - # @return [Array] obsolete products + # @return [Array] obsolete products def obsolete_available_products obsolete_products = [] @@ -73,9 +74,9 @@ def obsolete_available_products # select the products with the specified status # @param [Symbol] status required status of the products - # @return [Array] list of libzypp products + # @return [Array] list of libzypp products def select_products(status) - products.select { |product| product["status"] == status } + products.select { |product| product.status == status } end # Does a product upgrade another product? @@ -86,9 +87,9 @@ def product_upgrade?(new_product, old_product) # use Gem::Version internally for a proper version string comparison # TODO: check also "provides" to handle product renames (should not happen # in SP migration, but anyway...) - old_product["name"] == new_product["name"] && - (Gem::Version.new(old_product["version_version"]) < - Gem::Version.new(new_product["version_version"])) + old_product.name == new_product.name && + (Gem::Version.new(old_product.version_version) < + Gem::Version.new(new_product.version_version)) end end end diff --git a/test/data/sles12_migration_products.yml b/test/data/sles12_migration_products.yml index b001059..67c493d 100644 --- a/test/data/sles12_migration_products.yml +++ b/test/data/sles12_migration_products.yml @@ -1,5 +1,6 @@ --- - arch: x86_64 + kind: :product category: base description: |- SUSE Linux Enterprise offers a comprehensive @@ -42,6 +43,7 @@ version_version: '12' - arch: x86_64 category: addon + kind: :product description: |- SUSE Linux Enterprise offers a comprehensive suite of products built on a single code base. @@ -83,6 +85,7 @@ version_version: '12.1' - arch: x86_64 category: addon + kind: :product description: |- SUSE Linux Enterprise offers a comprehensive suite of products built on a single code base. diff --git a/test/migration_proposal_client_test.rb b/test/migration_proposal_client_test.rb index c59e992..b6a44d0 100644 --- a/test/migration_proposal_client_test.rb +++ b/test/migration_proposal_client_test.rb @@ -47,6 +47,11 @@ describe "#make_proposal" do let(:msg) { "Product Foo will be installed" } + let(:products) do + load_yaml_data("sles12_migration_products.yml").map do |p| + Y2Packager::Resolvable.new(p) + end + end before do expect(Yast::Pkg).to receive(:PkgSolve) @@ -55,13 +60,14 @@ expect(Yast::SpaceCalculation).to receive(:GetPartitionInfo) expect(Yast::Packages).to receive(:product_update_summary) .and_return([msg]) - expect(Yast::Pkg).to receive(:ResolvableProperties).with("", :product, "") - .and_return(load_yaml_data("sles12_migration_products.yml")) + expect(Y2Packager::Resolvable).to receive(:find).with(kind: :product) + .and_return(products) expect(Yast::Pkg).to receive(:SourceGeneralData).with(0) .and_return("name" => "Repo") end it "returns a map with proposal details" do + expect(Yast::Packages).to receive(:product_update_warning).and_return({}) proposal = subject.make_proposal({}) expect(proposal).to include("help", "preformatted_proposal") @@ -69,9 +75,13 @@ end it "returns a warning when an obsoleted repository is present" do + warning_string = "warning string" + expect(Yast::Packages).to receive(:product_update_warning).and_return( + "warning_level" => :warning, + "warning" => warning_string + ) proposal = subject.make_proposal({}) - expect(proposal["warning"]).to include("Repository Repo is obsolete " \ - "and should be excluded from migration") + expect(proposal["warning"]).to include(warning_string) expect(proposal["warning_level"]).to eq(:warning) end end diff --git a/test/repository_checker_test.rb b/test/repository_checker_test.rb index 0656817..4d037a8 100644 --- a/test/repository_checker_test.rb +++ b/test/repository_checker_test.rb @@ -24,7 +24,10 @@ describe Migration::RepositoryChecker do subject do - Migration::RepositoryChecker.new(load_yaml_data("sles12_migration_products.yml")) + products = load_yaml_data("sles12_migration_products.yml").map do |p| + Y2Packager::Resolvable.new(p) + end + Migration::RepositoryChecker.new(products) end describe "#obsolete_product_repos" do