Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
1,092 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# Copyright (c) [2021] SUSE LLC | ||
# | ||
# All Rights Reserved. | ||
# | ||
# This program is free software; you can redistribute it and/or modify it | ||
# under the terms of version 2 of the GNU General Public License as published | ||
# by the Free Software Foundation. | ||
# | ||
# This program is distributed in the hope that it will be useful, but WITHOUT | ||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
# more details. | ||
# | ||
# You should have received a copy of the GNU General Public License along | ||
# with this program; if not, contact SUSE LLC. | ||
# | ||
# To contact SUSE LLC about this file by physical or electronic mail, you may | ||
# find current contact information at www.suse.com. | ||
|
||
require "y2packager/product_spec" | ||
|
||
module Y2Packager | ||
# Describes a product for installation that comes from the XML definition | ||
# | ||
# These products are not backed by a libzypp product at the beginning of the | ||
# installation. The corresponding product should become available as soon as | ||
# the product is registered. | ||
class ControlProductSpec < ProductSpec | ||
# @return [String] License URL | ||
attr_reader :license_url | ||
# @return [String] Registration target name used for registering the product | ||
attr_reader :register_target | ||
|
||
# @param register_target [String] The registration target name used | ||
# for registering the product, the $arch variable is replaced | ||
# by the current machine architecture | ||
# @param license_url [String] License URL | ||
def initialize(name:, version:, arch:, display_name:, order:, license_url:, register_target:) | ||
super(name: name, version: version, display_name: display_name, arch: arch, | ||
order: order, base: true) | ||
|
||
# expand the "$arch" placeholder | ||
@register_target = register_target&.gsub("$arch", arch) || "" | ||
@license_url = license_url | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Copyright (c) [2021] SUSE LLC | ||
# | ||
# All Rights Reserved. | ||
# | ||
# This program is free software; you can redistribute it and/or modify it | ||
# under the terms of version 2 of the GNU General Public License as published | ||
# by the Free Software Foundation. | ||
# | ||
# This program is distributed in the hope that it will be useful, but WITHOUT | ||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
# more details. | ||
# | ||
# You should have received a copy of the GNU General Public License along | ||
# with this program; if not, contact SUSE LLC. | ||
# | ||
# To contact SUSE LLC about this file by physical or electronic mail, you may | ||
# find current contact information at www.suse.com. | ||
|
||
require "y2packager/product_spec" | ||
require "y2packager/product" | ||
|
||
Yast.import "Pkg" | ||
Yast.import "AddOnProduct" | ||
|
||
module Y2Packager | ||
# Describes a product for installation that comes from the libzypp database | ||
class LibzyppProductSpec < ProductSpec | ||
def to_product | ||
@to_product ||= Y2Packager::Product.available_base_products.find { |p| p.name == name } | ||
end | ||
|
||
def select | ||
super | ||
|
||
# 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 | ||
to_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 | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
# Copyright (c) [2021] SUSE LLC | ||
# | ||
# All Rights Reserved. | ||
# | ||
# This program is free software; you can redistribute it and/or modify it | ||
# under the terms of version 2 of the GNU General Public License as published | ||
# by the Free Software Foundation. | ||
# | ||
# This program is distributed in the hope that it will be useful, but WITHOUT | ||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
# more details. | ||
# | ||
# You should have received a copy of the GNU General Public License along | ||
# with this program; if not, contact SUSE LLC. | ||
# | ||
# To contact SUSE LLC about this file by physical or electronic mail, you may | ||
# find current contact information at www.suse.com. | ||
|
||
require "y2packager/product_license_mixin" | ||
|
||
module Y2Packager | ||
# Describes a product that the user can select for installation | ||
# | ||
# The installer allows selecting different products for installation. The list of products can be | ||
# read from different places (the libzypp database, the control.xml file, etc.). This class | ||
# represents those products, read from different places. | ||
# | ||
# Bear in mind that, once selected, the product is mapped to a proper Y2Packager::Product class, | ||
# backed by libzypp. | ||
class ProductSpec | ||
include ProductLicenseMixin | ||
|
||
# @return [String] Name. It corresponds to the libzypp resolvable. | ||
attr_reader :name | ||
|
||
# @return [String] Name to display to the user | ||
attr_reader :display_name | ||
alias_method :label, :display_name | ||
|
||
# @return [String] Version | ||
attr_reader :version | ||
|
||
# @return [String] Architecture | ||
attr_reader :arch | ||
|
||
# @return [Integer] Order in which the product is shown | ||
attr_reader :order | ||
|
||
attr_reader :base | ||
|
||
class << self | ||
# Returns the specs for the base products | ||
# | ||
# The found product specs are cached. Set the +reload+ param to +true+ | ||
# to force reading them again. | ||
# | ||
# @param reload [Boolean] Force reloading the list of products | ||
# @return [Array<Y2Packager::ProductSpec>] List of product specs | ||
# @see Y2Packager::ProductSpecReader | ||
def base_products(reload: false) | ||
return @products if @products && !reload | ||
|
||
require "y2packager/product_spec_reader" | ||
@products = Y2Packager::ProductSpecReader.new.products.select(&:base) | ||
end | ||
|
||
# Returns the selected base product spec | ||
# | ||
# @return [ProductSpec,nil] Returns the select base product spec. It returns nil | ||
# if no product is selected. | ||
def selected_base | ||
base_products.find(&:selected?) | ||
end | ||
|
||
# Resets the products cache | ||
def reset | ||
@products = nil | ||
end | ||
end | ||
|
||
# Constructor | ||
# @param name [String] product name (the identifier, e.g. "SLES") | ||
# @param version [String] version ("15.2") | ||
# @param arch [String] The architecture ("x86_64") | ||
# @param display_name [String] The user visible name ("SUSE Linux Enterprise Server 15 SP2") | ||
def initialize(name:, version:, arch:, display_name:, order: 1, base: true) | ||
@name = name | ||
@version = version | ||
@arch = arch | ||
@display_name = display_name | ||
@order = order | ||
@base = base | ||
@selected = false | ||
end | ||
|
||
def selected? | ||
@selected | ||
end | ||
|
||
def select | ||
@selected = true | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# Copyright (c) [2021] SUSE LLC | ||
# | ||
# All Rights Reserved. | ||
# | ||
# This program is free software; you can redistribute it and/or modify it | ||
# under the terms of version 2 of the GNU General Public License as published | ||
# by the Free Software Foundation. | ||
# | ||
# This program is distributed in the hope that it will be useful, but WITHOUT | ||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
# more details. | ||
# | ||
# You should have received a copy of the GNU General Public License along | ||
# with this program; if not, contact SUSE LLC. | ||
# | ||
# To contact SUSE LLC about this file by physical or electronic mail, you may | ||
# find current contact information at www.suse.com. | ||
|
||
require "y2packager/product_spec_readers/full" | ||
require "y2packager/product_spec_readers/libzypp" | ||
require "y2packager/product_spec_readers/control" | ||
require "y2packager/medium_type" | ||
|
||
module Y2Packager | ||
# Reads product specification from different sources | ||
class ProductSpecReader | ||
include Yast::Logger | ||
|
||
# Returns the list of product specifications. | ||
# | ||
# @return [Y2Packager::ProductSpec] List of product specifications | ||
def products | ||
# products_from_control || products_from_offline || products_from_libzypp | ||
|
||
case Y2Packager::MediumType.type | ||
when :online | ||
products_from_control | ||
when :offline | ||
products_from_offline | ||
else | ||
products_from_libzypp | ||
end | ||
end | ||
|
||
private | ||
|
||
# @raise RuntimeError | ||
def products_from_control | ||
control_products = Y2Packager::ProductSpecReaders::Control.new.products | ||
raise "The control file does not define any base product!" if control_products.empty? | ||
|
||
log.info "Products from control file: #{control_products.map(&:name).join(", ")}" | ||
control_products | ||
end | ||
|
||
def products_from_offline | ||
repo_products = Y2Packager::ProductSpecReaders::Full.new.products( | ||
Yast::InstURL.installInf2Url("") | ||
) | ||
log.info "Products from medium: #{repo_products.map(&:name).join(", ")}" | ||
repo_products | ||
end | ||
|
||
def products_from_libzypp | ||
libzypp_products = Y2Packager::ProductSpecReaders::Libzypp.new.products | ||
log.info "Products from libzypp: #{libzypp_products.map(&:name).join(", ")}" | ||
libzypp_products | ||
end | ||
end | ||
end |
Oops, something went wrong.