Skip to content

Commit

Permalink
Preselect the installed add-ons (jsc#SLE-7101)
Browse files Browse the repository at this point in the history
...when upgrading from the Full installation medium

- 4.2.32
  • Loading branch information
lslezak committed Nov 8, 2019
1 parent 6d1a8b4 commit 4fe1406
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 3 deletions.
7 changes: 7 additions & 0 deletions package/yast2-packager.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Fri Nov 8 18:58:23 UTC 2019 - Ladislav Slezák <lslezak@suse.cz>

- Preselect the installed add-ons when upgrading from the Full
installation medium (related to jsc#SLE-7101)
- 4.2.32

-------------------------------------------------------------------
Fri Nov 1 18:52:02 UTC 2019 - Ladislav Slezák <lslezak@suse.cz>

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


Name: yast2-packager
Version: 4.2.31
Version: 4.2.32
Release: 0
Summary: YaST2 - Package Library
License: GPL-2.0-or-later
Expand Down
37 changes: 35 additions & 2 deletions src/lib/y2packager/dialogs/addon_selector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@
require "yast"
require "erb"
require "ui/installation_dialog"
require "y2packager/resolvable"

Yast.import "AddOnProduct"
Yast.import "Mode"
Yast.import "Report"
Yast.import "Stage"
Yast.import "UI"
Expand Down Expand Up @@ -77,7 +80,7 @@ def help_text
"subdirectories. Select which products you want to install.</p>")
end

# Handle changing the current item or chaging the selection
# Handle changing the current item or changing the selection
def addon_repos_handler
current_item = Yast::UI.QueryWidget(Id(:addon_repos), :CurrentItem)
current_product = products.find { |p| p.dir == current_item }
Expand Down Expand Up @@ -113,7 +116,8 @@ def create_dialog
attr_writer :selected_products

def selection_content
products.map { |p| Item(Id(p.dir), p.summary || p.name) }
defaults = preselected_products
products.map { |p| Item(Id(p.dir), p.summary || p.name, defaults.include?(p)) }
end

# Dialog content
Expand Down Expand Up @@ -229,6 +233,35 @@ def product_description(product)
# render the ERB template in the context of this object
erb.result(binding)
end

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

installed_addons = Y2Packager::Resolvable.find(
kind: :product, status: :installed, type: "add-on"
).map(&:name) + Y2Packager::Resolvable.find(
kind: :product, status: :removed, type: "add-on"
).map(&:name)

selected_addons = Y2Packager::Resolvable.find(
kind: :product, status: :selected, type: "add-on"
).map(&:name)

# handle the product renames, if a renamed product was installed
# replace it with the new product so the new product is preselected
Yast::AddOnProductClass::DEFAULT_PRODUCT_RENAMES.each do |k,v|
next unless installed_addons.include?(k)
installed_addons.delete(k)
installed_addons.concat(v)
end

# installed but not selected yet products (to avoid duplicates)
products.select {|p| installed_addons.include?(p.details&.product) &&
!selected_addons.include?(p.details&.product)}
end
end
end
end

0 comments on commit 4fe1406

Please sign in to comment.