Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Find the Base Product #599

Draft
wants to merge 1 commit into
base: SLE-15-SP2
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions src/modules/AutoinstFunctions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,15 @@ def identify_product
log.info "Found base products : #{available_base_products.inspect}"

products = available_base_products.select do |product|
if product.is_a?(Y2Packager::ProductLocation)
yield(product.details.product)
product_name = if product.is_a?(Y2Packager::ProductLocation)
product.details.product
else
yield(product.name)
product.name
end

found = yield(product_name)
log.info("Match for product #{product_name}: #{found}")
found
end

return products.first if products.size == 1
Expand All @@ -169,9 +173,11 @@ def identify_product
# the criteria, nil otherwise
def identify_product_by_patterns(profile)
software = profile["software"] || {}
patterns = software.fetch("patterns", [])
log.info("Requested patterns in the profile: #{patterns}")

identify_product do |name|
software.fetch("patterns", []).any? { |p| p =~ /#{name.downcase}-.*/ }
patterns.any? { |p| p =~ /#{name.downcase}-.*/ }
end
end

Expand All @@ -184,9 +190,11 @@ def identify_product_by_patterns(profile)
# the criteria, nil otherwise
def identify_product_by_packages(profile)
software = profile["software"] || {}
packages = software.fetch("packages", [])
log.info("Requested packages in the profile: #{packages}")

identify_product do |name|
software.fetch("packages", []).any? { |p| p =~ /#{name.downcase}-release/ }
packages.any? { |p| p =~ /#{name.downcase}-release/ }
end
end

Expand All @@ -206,7 +214,7 @@ def identify_product_by_selection(profile)
# FIXME: Currently it returns first found product name. It should be no
# problem since this section was unused in AY installation so far.
# However, it might be needed to add a special handling for multiple
# poducts in the future. At least we can filter out products which are
# products in the future. At least we can filter out products which are
# not base products.
#
# @param profile [Hash] AutoYaST profile
Expand All @@ -220,7 +228,9 @@ def base_product_name(profile)
return nil
end

software.fetch("products", []).first
base_product = software.fetch("products", []).first
log.info("Base product in the profile: #{base_product.inspect}")
base_product
end
end

Expand Down