Skip to content

Commit

Permalink
Merge f0f855a into b7d99b0
Browse files Browse the repository at this point in the history
  • Loading branch information
lslezak committed Mar 13, 2019
2 parents b7d99b0 + f0f855a commit b00b247
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 3 deletions.
18 changes: 16 additions & 2 deletions library/packages/src/lib/y2packager/product_reader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def installation_package_mapping
# @return [Array<Product>] Available products
def all_products
linuxrc_special_products = if Yast::Linuxrc.InstallInf("specialproduct")
Yast::Linuxrc.InstallInf("specialproduct").split(",")
linuxrc_string(Yast::Linuxrc.InstallInf("specialproduct")).split(",")
else
[]
end
Expand All @@ -78,7 +78,7 @@ def all_products
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
special_product_tag = linuxrc_string(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
Expand Down Expand Up @@ -187,5 +187,19 @@ def base_product
def installation_package_mapping
@installation_package_mapping ||= self.class.installation_package_mapping
end

# Process the string in a linuxrc way: remove the "-", "_", "." characters,
# convert it to downcase for case insensitive comparison.
#
# @param input [String] the input string
#
# @return [String] the processed string
#
def linuxrc_string(input)
return nil if input.nil?

ret = input.gsub(/[-_.]/, "")
ret.downcase
end
end
end
25 changes: 25 additions & 0 deletions library/packages/test/y2packager/product_reader_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,31 @@
expect(subject.all_products.size).to eq(2)
end

it "ignores case of the linuxrc specialproduct parameter" do
allow(Yast::Linuxrc).to receive(:InstallInf).with("specialproduct").and_return("sles_bcl")
expect(subject.all_products.size).to eq(2)
end

it "ignores underscores in the linuxrc specialproduct parameter" do
allow(Yast::Linuxrc).to receive(:InstallInf).with("specialproduct").and_return("sles_b_c_l")
expect(subject.all_products.size).to eq(2)
end

it "ignores underscores in the product name" do
allow(Yast::Linuxrc).to receive(:InstallInf).with("specialproduct").and_return("SLESBCL")
expect(subject.all_products.size).to eq(2)
end

it "ignores dashes in the linuxrc specialproduct parameter" do
allow(Yast::Linuxrc).to receive(:InstallInf).with("specialproduct").and_return("sles-b-c-l")
expect(subject.all_products.size).to eq(2)
end

it "ignores dots in the linuxrc specialproduct parameter" do
allow(Yast::Linuxrc).to receive(:InstallInf).with("specialproduct").and_return("sles.b.c.l")
expect(subject.all_products.size).to eq(2)
end

it "returns the available product also when an installed product is found" do
installed = products.first.dup
installed["status"] = :installed
Expand Down
7 changes: 7 additions & 0 deletions package/yast2.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Wed Mar 13 15:34:17 UTC 2019 - Ladislav Slezak <lslezak@suse.cz>

- Process the "specialproduct" value like a linuxrc parameter
(ignore "-_." characters, ignore case) (bsc#1128901)
- 4.1.64

-------------------------------------------------------------------
Wed Mar 13 09:02:12 UTC 2019 - David Díaz <dgonzalez@suse.com>

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


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

0 comments on commit b00b247

Please sign in to comment.