Skip to content

Commit

Permalink
Merge ea10d28 into 0f65b11
Browse files Browse the repository at this point in the history
  • Loading branch information
jreidinger committed Oct 25, 2019
2 parents 0f65b11 + ea10d28 commit 773560d
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 12 deletions.
5 changes: 4 additions & 1 deletion library/packages/src/lib/y2packager/product.rb
Expand Up @@ -98,7 +98,10 @@ def installed_products
#
# @return [Product] Selected base product
def selected_base
available_base_products.find(&:selected?)
products = Y2Packager::ProductReader.new.available_base_products(force_repos: true)
selected = products.find(&:selected?)
selected ||= products.first
selected
end

# Return the products with a given status
Expand Down
33 changes: 25 additions & 8 deletions library/packages/src/lib/y2packager/product_reader.rb
Expand Up @@ -16,6 +16,7 @@

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

module Y2Packager
# Read the product information from libzypp
Expand Down Expand Up @@ -71,14 +72,26 @@ def installation_package_mapping
# Available products
#
# @return [Array<Product>] Available products
def all_products
def all_products(force_repos: false)
linuxrc_special_products = if Yast::Linuxrc.InstallInf("specialproduct")
linuxrc_string(Yast::Linuxrc.InstallInf("specialproduct")).split(",")
else
[]
end

@all_products ||= available_products.each_with_object([]) do |prod, all_products|
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.new(name: p.name, display_name: p.label,
version: p.version, arch: p.arch,
installation_package: "Test") # just hack as we do not know current package name yet
end
end

@all_products = []

available_products.each do |prod|
prod_pkg = product_package(prod["product_package"])

if prod_pkg
Expand All @@ -95,28 +108,32 @@ def all_products
displayorder = Regexp.last_match[1].to_i if Regexp.last_match
end

all_products << 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,
installation_package: installation_package_mapping[prod["name"]]
)
end

@all_products
end

# In installation Read the available libzypp base products for installation
# @return [Array<Y2Packager::Product>] the found available base products,
# the products are sorted by the 'displayorder' provides value
def available_base_products
def available_base_products(force_repos: false)
# If no product contains a 'system-installation()' tag but there is only 1 product,
# we assume that it is the base one.
if all_products.size == 1 && installation_package_mapping.empty?
log.info "Assuming that #{all_products.inspect} is the base product."
return all_products
products = all_products(force_repos: force_repos)
if products.size == 1 && installation_package_mapping.empty?
log.info "Assuming that #{products.inspect} is the base product."
return products
end

log.info "all products #{products}"
# only installable products
products = all_products.select(&:installation_package).sort(&::Y2Packager::PRODUCT_SORTER)
products = products.select(&:installation_package).sort(&::Y2Packager::PRODUCT_SORTER)
log.info "available base products #{products}"
products
end
Expand Down
4 changes: 2 additions & 2 deletions library/packages/test/y2packager/product_test.rb
Expand Up @@ -32,7 +32,7 @@
let(:selected) { instance_double(Y2Packager::Product, selected?: true) }

it "returns base selected packages" do
allow(described_class).to receive(:available_base_products)
allow(reader).to receive(:available_base_products)
.and_return([not_selected, selected])

expect(described_class.selected_base).to eq(selected)
Expand Down Expand Up @@ -115,7 +115,7 @@
let(:selected) { instance_double(Y2Packager::Product, selected?: true) }

it "returns base selected packages" do
allow(described_class).to receive(:available_base_products)
allow(reader).to receive(:available_base_products)
.and_return([not_selected, selected])

expect(described_class.selected_base).to eq(selected)
Expand Down
7 changes: 7 additions & 0 deletions package/yast2.changes
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Fri Oct 25 12:57:30 UTC 2019 - Josef Reidinger <jreidinger@suse.com>

- Support for products on control file during upgrade
(jsc#SLE-7214)
- 4.2.29

-------------------------------------------------------------------
Fri Oct 18 12:20:52 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.2.28
Version: 4.2.29
Release: 0
Summary: YaST2 Main Package
License: GPL-2.0-only
Expand Down

0 comments on commit 773560d

Please sign in to comment.