Skip to content

Commit

Permalink
Merge pull request #275 from yast/find-base-product
Browse files Browse the repository at this point in the history
Do not depend on system-installation() when finding base product
  • Loading branch information
imobachgs committed Sep 5, 2017
2 parents 1859721 + ddedd7d commit 2704d5e
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 2 deletions.
7 changes: 7 additions & 0 deletions package/yast2-packager.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Tue Sep 5 12:47:26 UTC 2017 - igonzalezsosa@suse.com

- Product's detection on single product media does not require
the 'system-installation()' tag anymore (fate#322276)
- 3.3.11

-------------------------------------------------------------------
Tue Sep 5 10:24:26 UTC 2017 - igonzalezsosa@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: 3.3.10
Version: 3.3.11
Release: 0

BuildRoot: %{_tmppath}/%{name}-%{version}-build
Expand Down
7 changes: 7 additions & 0 deletions src/lib/y2packager/product_reader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@ def self.available_base_products
installation_package: installation_mapping[prod["name"]])
end

# If no product contains a 'system-installation()' tag but there is only 1 product,
# we assume that it is the base one.
if result.size == 1 && installation_mapping.empty?
log.info "Assuming that #{result.inspect} is the base product."
return result
end

# only installable products
result.select!(&:installation_package)

Expand Down
30 changes: 29 additions & 1 deletion test/product_reader_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@
describe Y2Packager::ProductReader do
subject { Y2Packager::ProductReader }
let(:products) { YAML.load(File.read(FIXTURES_PATH.join("products-sles15.yml"))) }
let(:installation_package_map) { { "SLES" => "skelcd-SLES" } }

describe "#available_base_products" do
before do
# TODO: proper mocking of pkg methods
allow(subject).to receive(:installation_package_mapping).and_return("SLES" => "skelcd-SLES")
allow(subject).to receive(:installation_package_mapping).and_return(installation_package_map)
end

it "returns empty list if there is no product" do
Expand Down Expand Up @@ -57,5 +58,32 @@

expect(subject.available_base_products.size).to eq(1)
end

context "when no product with system-installation() tag exists" do
let(:installation_package_map) { {} }
let(:prod1) { { "name" => "SLES" } }
let(:prod2) { { "name" => "SLED" } }

before do
allow(Yast::Pkg).to receive(:ResolvableProperties).with("", :product, "")
.and_return(products)
end

context "and only 1 product exists" do
let(:products) { [prod1] }

it "returns the found product" do
expect(subject.available_base_products.size).to eq(1)
end
end

context "and more than 1 product exsits" do
let(:products) { [prod1, prod2] }

it "returns an empty array" do
expect(subject.available_base_products).to be_empty
end
end
end
end
end

0 comments on commit 2704d5e

Please sign in to comment.