Skip to content

Commit

Permalink
Merge pull request #608 from yast/read_products
Browse files Browse the repository at this point in the history
Read the products from libzypp in installed system
  • Loading branch information
lslezak committed Mar 17, 2022
2 parents 5adaf00 + 0d04a2f commit 78488dd
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
7 changes: 7 additions & 0 deletions package/yast2-packager.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Thu Mar 17 08:01:35 UTC 2022 - Ladislav Slezák <lslezak@suse.cz>

- Read the products from libzypp in installed system, fixes crash
during online migration (related to jsc#SLE-17309)
- 4.4.26

-------------------------------------------------------------------
Tue Mar 15 17:20:53 UTC 2022 - Steffen Winterfeldt <snwint@suse.com>

Expand Down
2 changes: 1 addition & 1 deletion package/yast2-packager.spec
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@


Name: yast2-packager
Version: 4.4.25
Version: 4.4.26
Release: 0
Summary: YaST2 - Package Library
License: GPL-2.0-or-later
Expand Down
4 changes: 4 additions & 0 deletions src/lib/y2packager/product_spec_reader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,17 @@ module Y2Packager
# Reads product specification from different sources
class ProductSpecReader
include Yast::Logger
Yast.import "Mode"

# Returns the list of product specifications.
#
# @return [Y2Packager::ProductSpec] List of product specifications
def products
# products_from_control || products_from_offline || products_from_libzypp

# online migration (in installed system)
return products_from_libzypp if Yast::Mode.normal

if InstallationMedium.contain_multi_repos?
products_from_multi_repos
elsif InstallationMedium.contain_repo?
Expand Down
11 changes: 11 additions & 0 deletions test/lib/product_spec_reader_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
allow(Y2Packager::ProductSpecReaders::Libzypp).to receive(:new).and_return(libzypp_reader)
allow(Y2Packager::InstallationMedium).to receive(:contain_repo?).and_return(false)
allow(Y2Packager::InstallationMedium).to receive(:contain_multi_repos?).and_return(false)
allow(Yast::Mode).to receive(:normal).and_return(false)
end

context "when medium does not contain any repository" do
Expand Down Expand Up @@ -74,5 +75,15 @@
expect(reader.products).to eq(libzypp_products)
end
end

context "in installed system" do
before do
allow(Yast::Mode).to receive(:normal).and_return(true)
end

it "returns the libzypp products" do
expect(reader.products).to eq(libzypp_products)
end
end
end
end

0 comments on commit 78488dd

Please sign in to comment.