Skip to content

Commit

Permalink
support linuxrc option -specialproduct-
Browse files Browse the repository at this point in the history
  • Loading branch information
schubi2 committed Jan 16, 2019
1 parent 15d6751 commit e4f3eb5
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 4 deletions.
14 changes: 14 additions & 0 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,10 +66,22 @@ def installation_package_mapping
#
# @return [Array<Product>] Available products
def all_products
linuxrc_special_products = Yast::Linuxrc.InstallInf("specialproduct") ?
Yast::Linuxrc.InstallInf("specialproduct").split(",") : []

@all_products ||= available_products.map do |prod|
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
Expand All @@ -80,6 +93,7 @@ def all_products
installation_package: installation_package_mapping[prod["name"]]
)
end
@all_products.compact
end

# In installation Read the available libzypp base products for installation
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.51

-------------------------------------------------------------------
Mon Jan 14 10:55:20 UTC 2019 - Josef Reidinger <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.50
Version: 4.1.51
Release: 0
Summary: YaST2 - Main Package
License: GPL-2.0-only
Expand Down

0 comments on commit e4f3eb5

Please sign in to comment.