Skip to content

Commit

Permalink
Merge bea0249 into 6bd8862
Browse files Browse the repository at this point in the history
  • Loading branch information
schubi2 committed Jan 17, 2019
2 parents 6bd8862 + bea0249 commit 2128dc0
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 6 deletions.
20 changes: 18 additions & 2 deletions library/packages/src/lib/y2packager/product_reader.rb
Expand Up @@ -15,6 +15,7 @@
require "y2packager/product_sorter"

Yast.import "Pkg"
Yast.import "Linuxrc"

module Y2Packager
# Read the product information from libzypp
Expand Down Expand Up @@ -65,15 +66,30 @@ def installation_package_mapping
#
# @return [Array<Product>] Available products
def all_products
@all_products ||= available_products.map do |prod|
linuxrc_special_products = if Yast::Linuxrc.InstallInf("specialproduct")
Yast::Linuxrc.InstallInf("specialproduct").split(",")
else
[]
end

@all_products ||= available_products.each_with_object([]) do |prod, all_products|
prod_pkg = product_package(prod["product_package"])

if prod_pkg
# remove special products if they have not been defined in linuxrc
prod_pkg["deps"].find { |dep| dep["provides"] =~ /\Aspecialproduct\(\s*(.*?)\s*\)\z/ }
special_product_tag = Regexp.last_match[1] if Regexp.last_match
if special_product_tag && !linuxrc_special_products.include?(special_product_tag)
log.info "Special product #{prod["name"]} has not been defined via linuxrc. --> do not offer it"
next
end

# Evaluating display order
prod_pkg["deps"].find { |dep| dep["provides"] =~ /\Adisplayorder\(\s*([0-9]+)\s*\)\z/ }
displayorder = Regexp.last_match[1].to_i if Regexp.last_match
end

Y2Packager::Product.new(
all_products << Y2Packager::Product.new(
name: prod["name"], short_name: prod["short_name"], display_name: prod["display_name"],
version: prod["version"], arch: prod["arch"], category: prod["category"],
vendor: prod["vendor"], order: displayorder,
Expand Down
28 changes: 25 additions & 3 deletions library/packages/test/y2packager/product_reader_test.rb
Expand Up @@ -104,16 +104,38 @@
end
end

describe "#products" do
describe "#all_products" do
let(:special_prod) do
# reuse the available SLES15 product, just change some attributes
special = products.first.dup
special["name"] = "SLES_BCL"
special["status"] = :available
special["product_package"] = "SLES_BCL-release"
special["display_name"] = "SUSE Linux Enterprise Server 15 Business Critical Linux"
special["short_name"] = "SLE-15-BCL"
special
end

before do
allow(Yast::Pkg).to receive(:ResolvableProperties).with("", :product, "")
.and_return(products)
.and_return(products + [special_prod])
allow(Yast::Pkg).to receive(:PkgQueryProvides).with("system-installation()")
.and_return([])
allow(subject).to receive(:product_package).with("sles-release")
.and_return(nil)
allow(subject).to receive(:product_package).with("SLES_BCL-release")
.and_return("deps" => [{ "conflicts"=>"kernel < 4.4" },
{ "provides"=>"specialproduct(SLES_BCL)" }])
end

it "returns available products" do
it "returns available products without special products" do
allow(Yast::Linuxrc).to receive(:InstallInf).with("specialproduct").and_return(nil)
expect(subject.all_products.size).to eq(1)
end

it "returns available products with special product" do
allow(Yast::Linuxrc).to receive(:InstallInf).with("specialproduct").and_return("SLES_BCL")
expect(subject.all_products.size).to eq(2)
end
end
end
7 changes: 7 additions & 0 deletions package/yast2.changes
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Wed Jan 16 16:52:19 CET 2019 - schubi@suse.de

- Support special products which will be enabled via linuxrc
(flag "specialproduct") (fate#327099)
- 4.1.52

-------------------------------------------------------------------
Wed Jan 16 13:03:59 UTC 2019 - jreidinger@suse.com

Expand Down
2 changes: 1 addition & 1 deletion package/yast2.spec
Expand Up @@ -17,7 +17,7 @@


Name: yast2
Version: 4.1.51
Version: 4.1.52
Release: 0
Summary: YaST2 - Main Package
License: GPL-2.0-only
Expand Down

0 comments on commit 2128dc0

Please sign in to comment.