Skip to content

Commit

Permalink
Merge 6308a1a into d859f99
Browse files Browse the repository at this point in the history
  • Loading branch information
imobachgs committed Nov 12, 2021
2 parents d859f99 + 6308a1a commit 2a0766c
Show file tree
Hide file tree
Showing 14 changed files with 64 additions and 2,122 deletions.
16 changes: 16 additions & 0 deletions library/general/src/modules/Arch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,22 @@ def is_wsl
SCR.Read(path(".target.string"), "/proc/sys/kernel/osrelease").to_s.downcase.include?("-microsoft")
end

# map the Arch.architecture to the arch expected by SCC
RPM_ARCH = {
"s390_32" => "s390",
"s390_64" => "s390x",
# ppc64le is the only supported PPC arch, we do not have to distinguish the BE/LE variants
"ppc64" => "ppc64le"
}.freeze
private_constant :RPM_ARCH

# Returns the architecture expected by SCC
#
# @return [String] Architecture
def rpm_arch
RPM_ARCH[architecture] || architecture
end

publish function: :architecture, type: "string ()"
publish function: :i386, type: "boolean ()"
publish function: :sparc32, type: "boolean ()"
Expand Down
38 changes: 38 additions & 0 deletions library/general/test/arch_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -252,4 +252,42 @@
end
end
end

describe ".rpm_arch" do
before do
allow(subject).to receive(:architecture).and_return(arch)
end

context "on 32 bits s390" do
let(:arch) { "s390_32" }

it "returns s390" do
expect(subject.rpm_arch).to eq("s390")
end
end

context "on 64 bits s390" do
let(:arch) { "s390_64" }

it "returns s390x" do
expect(subject.rpm_arch).to eq("s390x")
end
end

context "on ppc64 architectures" do
let(:arch) { "ppc64" }

it "returns 'ppc64le'" do
expect(subject.rpm_arch).to eq("ppc64le")
end
end

context "on others architectures" do
let(:arch) { "x86_64" }

it "returns the underlying architecture" do
expect(subject.rpm_arch).to eq("x86_64")
end
end
end
end
32 changes: 0 additions & 32 deletions library/packages/src/lib/y2packager/product.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,18 +81,6 @@ def from_resolvable(product, installation_package = "",
)
end

# Create a product from Y2Packager::ProductControlProduct
# @param product [Y2Packager::ProductControlProduct] product
# @return [Y2Packager::Product] converted product
def from_product_control_product(product)
Y2Packager::Product.new(
name: product.name, display_name: product.label,
version: product.version, arch: product.arch,
short_name: product.name,
installation_package: ""
)
end

# Return all known available products
#
# @return [Array<Product>] Known available products
Expand Down Expand Up @@ -140,26 +128,6 @@ def selected_base
def with_status(*statuses)
all.select { |p| p.status?(*statuses) }
end

# Returns, if any, the base product which must be selected
#
# A base product can be forced to be selected through the `select_product`
# element in the software section of the control.xml file (bsc#1124590,
# bsc#1143943).
#
# @return [Y2Packager::Product, nil] the forced base product or nil when
# either, it wasn't selected or the selected wasn't found among the
# available ones.
def forced_base_product
Yast.import "ProductFeatures"

return @forced_base_product if @forced_base_product

forced_product_name = Yast::ProductFeatures.GetStringFeature("software", "select_product")
return if forced_product_name.to_s.empty?

@forced_base_product = available_base_products.find { |p| p.name == forced_product_name }
end
end

# Constructor
Expand Down
114 changes: 0 additions & 114 deletions library/packages/src/lib/y2packager/product_control_product.rb

This file was deleted.

7 changes: 0 additions & 7 deletions library/packages/src/lib/y2packager/product_reader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
require "y2packager/product"
require "y2packager/product_sorter"
require "y2packager/resolvable"
require "y2packager/product_control_product"

Yast.import "Pkg"
Yast.import "Linuxrc"
Expand Down Expand Up @@ -83,12 +82,6 @@ def all_products(force_repos: false)

return @all_products if @all_products && !force_repos

if Yast::Stage.initial && Y2Packager::MediumType.online? && !force_repos
return Y2Packager::ProductControlProduct.products.each_with_object([]) do |p, result|
result << Y2Packager::Product.from_product_control_product(p)
end
end

@all_products = []

available_products.each do |prod|
Expand Down

0 comments on commit 2a0766c

Please sign in to comment.