Skip to content

Commit

Permalink
Preselect the default modules in the offline installation (jsc#SLE-80…
Browse files Browse the repository at this point in the history
…40, jsc#SLE-11455)
  • Loading branch information
lslezak committed Feb 24, 2020
1 parent 41a114a commit 76341c5
Showing 1 changed file with 30 additions and 3 deletions.
33 changes: 30 additions & 3 deletions src/lib/y2packager/dialogs/addon_selector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

Yast.import "AddOnProduct"
Yast.import "Mode"
Yast.import "ProductFeatures"
Yast.import "Report"
Yast.import "Stage"
Yast.import "UI"
Expand Down Expand Up @@ -234,18 +235,44 @@ def product_description(product)
erb.result(binding)
end

# return a list of the preselected products
# during upgrade we want to preselect the installed products
# return a list of the preselected products depending on the installation mode
# @return [Array<Y2Packager::ProductLocation>] the products
def preselected_products
return [] unless Yast::Mode.update
return preselected_upgrade_products if Yast::Mode.update
return preselected_installation_products if Yast::Mode.installation

# in other modes (e.g. installed system) do not preselect anything
[]
end

# return a list of the preselected products at upgrade,
# preselect the installed products
# @return [Array<Y2Packager::ProductLocation>] the products
def preselected_upgrade_products
missing_products = Yast::AddOnProduct.missing_upgrades
# installed but not selected yet products (to avoid duplicates)
products.select do |p|
missing_products.include?(p.details&.product)
end
end

# return a list of the preselected products at installation,
# preselect the default products specified in the control.xml/installation.xml
# @return [Array<Y2Packager::ProductLocation>] the products
def preselected_installation_products
default_modules = Yast::ProductFeatures.GetFeature("software", "default_modules")
return [] unless default_modules

log.info("Defined default modules: #{default_modules.inspect}")
# skip the already selected products (to avoid duplicates)
default_modules -= Y2Packager::Resolvable.find(kind: :product, status: :selected).map(&:name)
log.info("Using default modules: #{default_modules.inspect}")

# select the default products
products.select do |p|
default_modules.include?(p.details&.product)
end
end
end
end
end

0 comments on commit 76341c5

Please sign in to comment.