Skip to content

Commit

Permalink
Merge 040d66f into fb65bf8
Browse files Browse the repository at this point in the history
  • Loading branch information
shundhammer committed Apr 26, 2022
2 parents fb65bf8 + 040d66f commit f08424c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/lib/y2packager/product_spec_reader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ module Y2Packager
class ProductSpecReader
include Yast::Logger
Yast.import "Mode"
Yast.import "Linuxrc"

# Returns the list of product specifications.
#
Expand All @@ -35,7 +36,7 @@ def products
# products_from_control || products_from_offline || products_from_libzypp

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

if InstallationMedium.contain_multi_repos?
products_from_multi_repos
Expand Down Expand Up @@ -70,5 +71,12 @@ def products_from_libzypp
log.info "Products from libzypp: #{libzypp_products.map(&:name).join(", ")}"
libzypp_products
end

# Is information from an install.inf file available?
#
# @return [Boolean]
def install_inf?
!Yast::Linuxrc.keys.empty?
end
end
end
15 changes: 15 additions & 0 deletions test/lib/product_spec_reader_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@
let(:full_products) { [instance_double(Y2Packager::ProductSpec, name: "SLES")] }
let(:control_products) { [instance_double(Y2Packager::ProductSpec, name: "SLED")] }
let(:libzypp_products) { [instance_double(Y2Packager::ProductSpec, name: "SLE-HA")] }
let(:linuxrc_fake) { { foo: "bar" } }
let(:linuxrc_empty) { {} }
let(:linuxrc_keys) { linuxrc_fake }

describe "#products" do
before do
Expand All @@ -47,6 +50,7 @@
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)
allow(Yast::Linuxrc).to receive(:keys).and_return(linuxrc_keys)
end

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

context "without /etc/install.inf" do
let(:linuxrc_keys) { linuxrc_empty }
before do
allow(Yast::Mode).to receive(:normal).and_return(false)
end

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

0 comments on commit f08424c

Please sign in to comment.