Skip to content

Commit

Permalink
Merge pull request #992 from yast/packager-ng
Browse files Browse the repository at this point in the history
Simplify installation workflow and adapt to the ProductSpec API
  • Loading branch information
imobachgs committed Nov 15, 2021
2 parents 79c184b + a664e80 commit dc16faa
Show file tree
Hide file tree
Showing 8 changed files with 90 additions and 179 deletions.
9 changes: 9 additions & 0 deletions package/yast2-installation.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
-------------------------------------------------------------------
Fri Nov 12 14:08:02 UTC 2021 - Imobach Gonzalez Sosa <igonzalezsosa@suse.com>

- bsc#1192626:
- Adapt the code to the new product specification API.
- Remove the code to handle the selected product from the
InstComplexWelcome client.
- 4.4.22

-------------------------------------------------------------------
Mon Nov 1 12:48:19 UTC 2021 - Martin Vidner <mvidner@suse.com>

Expand Down
18 changes: 9 additions & 9 deletions package/yast2-installation.spec
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@


Name: yast2-installation
Version: 4.4.21
Version: 4.4.22
Release: 0
Summary: YaST2 - Installation Parts
License: GPL-2.0-only
Expand All @@ -28,8 +28,8 @@ Source1: YaST2-Second-Stage.service
Source2: YaST2-Firstboot.service

BuildRequires: update-desktop-files
# Yast2::FsSnapshotStore::IOError
BuildRequires: yast2 >= 4.3.53
# ProductSpec API
BuildRequires: yast2 >= 4.4.21
# CIOIgnore
BuildRequires: yast2-bootloader
# storage-ng based version
Expand All @@ -39,8 +39,8 @@ BuildRequires: yast2-devtools >= 3.1.10
BuildRequires: yast2-firewall
# Y2Network::ProposalSettings #modify_defaults and #apply_defaults (forwarding configurable)
BuildRequires: yast2-network >= 4.4.12
# Y2Packager::InstallationData
BuildRequires: yast2-packager >= 4.4.2
# ProductSpec API
BuildRequires: yast2-packager >= 4.4.13
# for AbortException and handle direct abort
BuildRequires: yast2-ruby-bindings >= 4.0.6
# For selinux classes
Expand Down Expand Up @@ -70,8 +70,8 @@ Requires: iproute2
Requires: pciutils
# tar-gzip some system files and untar-ungzip them after the installation (FATE #300421, #120103)
Requires: tar
# Installation::InstallationInfo
Requires: yast2 >= 4.4.4
# ProductSpec API
Requires: yast2 >= 4.4.21
# CIOIgnore
Requires: yast2-bootloader
Requires: yast2-country >= 3.3.1
Expand All @@ -80,8 +80,8 @@ Requires: yast2-country >= 3.3.1
Requires: yast2-country-data >= 2.16.11
# Y2Network::ProposalSettings #modify_defaults and #apply_defaults (forwarding configurable)
Requires: yast2-network >= 4.4.12
# Y2Packager::InstallationData
Requires: yast2-packager >= 4.4.2
# ProductSpec API
Requires: yast2-packager >= 4.4.13
# Pkg::ProvidePackage
Requires: yast2-pkg-bindings >= 3.1.33
# Proxy settings for 2nd stage (bnc#764951)
Expand Down
63 changes: 10 additions & 53 deletions src/lib/installation/clients/inst_complex_welcome.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@

require "installation/dialogs/complex_welcome"
require "y2packager/medium_type"
require "y2packager/product"
require "y2packager/product_control_product"
require "y2packager/product_location"
require "y2packager/product_sorter"
require "y2packager/product_spec"

Yast.import "Console"
Yast.import "FileUtils"
Expand All @@ -46,7 +43,6 @@
Yast.import "Stage"
Yast.import "Timezone"
Yast.import "Wizard"
Yast.import "WorkflowManager"

module Yast
# This client shows main dialog for choosing the language, keyboard,
Expand Down Expand Up @@ -77,12 +73,7 @@ def main
products, disable_buttons: disable_buttons
)
result = handle_dialog_result(dialog_result)
next unless result

return result if !available_products? || result != :next
# in the online installation the workflow is merged after registering the system
return result if Y2Packager::MediumType.online?
return merge_and_run_workflow
return result if result
end
end

Expand Down Expand Up @@ -113,14 +104,6 @@ def handle_dialog_result(value)
end
end

# Merge selected product's workflow and go to next step
#
# @see Yast::WorkflowManager.merge_product_workflow
def merge_and_run_workflow
Yast::WorkflowManager.merge_product_workflow(selected_product)
Yast::ProductControl.RunFrom(Yast::ProductControl.CurrentStep + 1, true)
end

# Set up system according to user choices
def setup_final_choice
# Language has been set already.
Expand Down Expand Up @@ -158,44 +141,21 @@ def setup_final_choice
# list because the dialog will not show the license (we do not know which product we are
# upgrading yet) nor the product selector (as you cannot change the product during upgrade).
#
# @return [Array<Y2Packager::Product>, Array<Y2Packager::ProductControlProduct, Array<Y2Packager::ProductLocation>] List of
# available base products; if any, a list containing only the forced base product;
# empty list in update mode.
# @return [Array<Y2Packager::ProductSpec>] List of available base products; if any, a list
# containing only the forced base product; empty list in update mode.
def products
return @products if @products

@products = Array(Y2Packager::Product.forced_base_product || available_base_products)
@products = Array(Y2Packager::ProductSpec.forced_base_product || available_base_products)
@products = [] if Mode.update && @products.size > 1
@products
end

# Returns all available base products
#
# @return [Array<Y2Packager::Product>, Array<Y2Packager::ProductControlProduct>, Array<Y2Packager::ProductLocation>] List of
# available base products
# @return [Array<Y2Packager::ProductSpec>] List of available base products
def available_base_products
return @available_base_products if @available_base_products

case Y2Packager::MediumType.type
when :online
# read the products from the control.xml
@available_base_products = Y2Packager::ProductControlProduct.products
log.info "Found base products in the control.xml: #{@available_base_products.pretty_inspect}"

# we cannot continue, the control.xml in the installer is invalid
raise "control.xml does not define any base products!" if @available_base_products.empty?
when :offline
url = InstURL.installInf2Url("")
@available_base_products = Y2Packager::ProductLocation
.scan(url)
.select { |p| p.details && p.details.base }
.sort(&::Y2Packager::PRODUCT_SORTER)
log.info "Found base products on the offline medium: #{@available_base_products.pretty_inspect}"
else
@available_base_products = Y2Packager::Product.available_base_products
end

@available_base_products
@available_base_products ||= Y2Packager::ProductSpec.base_products
end

# Determine whether some product is available or not
Expand All @@ -207,13 +167,10 @@ def available_products?

# Convenience method to find out the selected base product
#
# @return [Y2Packager::Product] Selected base product
# @return [Y2Packager::ProductSpec,nil] Selected base product. When no product is selected,
# it returns nil.
def selected_product
if Y2Packager::MediumType.online?
Y2Packager::ProductControlProduct.selected
else
Y2Packager::Product.selected_base
end
Y2Packager::ProductSpec.selected_base
end

# Buttons to disable according to GetInstArgs
Expand Down
2 changes: 2 additions & 0 deletions src/lib/installation/proposal_runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ def initialize(store = ::Installation::ProposalStore)

# BNC #463567
@submods_already_called = []
# NOTE: it would be better to receive the object already initialized. Why? Because if it
# needs some argument, we do not know how to handle it.
@store_class = store
@errors = ProposalErrors.new
end
Expand Down
37 changes: 5 additions & 32 deletions src/lib/installation/widgets/product_selector.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require "yast"

require "y2packager/medium_type"
require "y2packager/product_control_product"
require "y2packager/product_sorter"

Yast.import "Pkg"
Yast.import "Popup"
Expand All @@ -18,11 +18,11 @@ class ProductSelector < CWM::RadioButtons
attr_reader :items, :products
attr_reader :product

# @param products [Array<Installation::Product>] to display
# @param products [Array<Y2Packager::Product>] products to display
# @param skip_validation [Boolean] Skip value validation
def initialize(products, skip_validation: false)
@products = products
@items = products.map { |p| [item_id(p), p.label] }
@items = products.sort(&Y2Packager::PRODUCT_SORTER).map { |p| [item_id(p), p.label] }
@skip_validation = skip_validation
textdomain "installation"
end
Expand Down Expand Up @@ -52,34 +52,7 @@ def store

return unless @product

# online product from control.xml
if @product.is_a?(Y2Packager::ProductControlProduct)
Y2Packager::ProductControlProduct.selected = @product
# offline product from the medium repository
elsif @product.is_a?(Y2Packager::ProductLocation)
# in offline installation add the repository with the selected base product
show_popup = true
base_url = Yast::InstURL.installInf2Url("")
log_url = Yast::URL.HidePassword(base_url)
Yast::Packages.Initialize_StageInitial(show_popup, base_url, log_url, @product.dir)
# select the product to install
Yast::Pkg.ResolvableInstall(@product.details && @product.details.product, :product, "")
# initialize addons and the workflow manager
Yast::AddOnProduct.SetBaseProductURL(base_url)
Yast::WorkflowManager.SetBaseWorkflow(false)
else
# reset both YaST and user selection (when going back or any products
# selected by YaST in the previous steps)
Yast::Pkg.PkgApplReset
Yast::Pkg.PkgReset
@product.select

# Reselecting existing add-on-products for installation again
Yast::AddOnProduct.selected_installation_products.each do |product|
log.info "Reselecting add-on product #{product} for installation"
Yast::Pkg.ResolvableInstall(product, :product, "")
end
end
@product.select
end

def validate
Expand Down Expand Up @@ -113,7 +86,7 @@ def offline_product_selected?
# unique widget ID for the product
# @return [String] widget ID
def item_id(prod)
return prod.dir if prod.is_a?(Y2Packager::ProductLocation)
return prod.dir if prod.respond_to?(:dir)
"#{prod.name}-#{prod.version}-#{prod.arch}"
end
end
Expand Down
Loading

0 comments on commit dc16faa

Please sign in to comment.