Class: Y2Packager::ProductControlProduct

Inherits:
Object
  • Object
show all
Extended by:
Yast::Logger
Includes:
ProductLicenseMixin
Defined in:
library/packages/src/lib/y2packager/product_control_product.rb

Overview

This class implements a base product read from the control.xml file.

Constant Summary collapse

REG_ARCH =

map the Arch.architecture to the arch expected by SCC

{
  "s390_32" => "s390",
  "s390_64" => "s390x",
  # ppc64le is the only supported PPC arch, we do not have to distinguish the BE/LE variants
  "ppc64"   => "ppc64le"
}.freeze

Constants included from ProductLicenseMixin

Y2Packager::ProductLicenseMixin::DEFAULT_LICENSE_LANG

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ProductLicenseMixin

#license, #license?, #license_confirmation=, #license_confirmation_required?, #license_confirmed?, #license_content, #license_locales

Constructor Details

#initialize(name:, version:, arch:, label:, license_url:, register_target:) ⇒ ProductControlProduct

Constructor

Parameters:

  • name (String)

    product name (the identifier, e.g. "SLES")

  • version (String)

    version ("15.2")

  • arch (String)

    The architecture ("x86_64")

  • label (String)

    The user visible name ("SUSE Linux Enterprise Server 15 SP2")

  • license_url (String)

    License URL

  • register_target (String)

    The registration target name used for registering the product, the $arch variable is replaced by the current machine architecture


99
100
101
102
103
104
105
106
# File 'library/packages/src/lib/y2packager/product_control_product.rb', line 99

def initialize(name:, version:, arch:, label:, license_url:, register_target:)
  @name = name
  @version = version
  @arch = arch
  @label = label
  @license_url = license_url
  @register_target = register_target
end

Class Attribute Details

.selectedObject

Returns the value of attribute selected


43
44
45
# File 'library/packages/src/lib/y2packager/product_control_product.rb', line 43

def selected
  @selected
end

Instance Attribute Details

#archObject (readonly)

Returns the value of attribute arch


32
33
34
# File 'library/packages/src/lib/y2packager/product_control_product.rb', line 32

def arch
  @arch
end

#labelObject (readonly)

Returns the value of attribute label


32
33
34
# File 'library/packages/src/lib/y2packager/product_control_product.rb', line 32

def label
  @label
end

#license_urlObject (readonly)

Returns the value of attribute license_url


32
33
34
# File 'library/packages/src/lib/y2packager/product_control_product.rb', line 32

def license_url
  @license_url
end

#nameObject (readonly)

Returns the value of attribute name


32
33
34
# File 'library/packages/src/lib/y2packager/product_control_product.rb', line 32

def name
  @name
end

#register_targetObject (readonly)

Returns the value of attribute register_target


32
33
34
# File 'library/packages/src/lib/y2packager/product_control_product.rb', line 32

def register_target
  @register_target
end

#versionObject (readonly)

Returns the value of attribute version


32
33
34
# File 'library/packages/src/lib/y2packager/product_control_product.rb', line 32

def version
  @version
end

Class Method Details

.productsArray<Installation::ProductControlProduct>

Read the base products from the control.xml file. The products for the incompatible machine architecture and the hidden products are filtered out.

Returns:

  • (Array<Installation::ProductControlProduct>)

    List of the products


50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'library/packages/src/lib/y2packager/product_control_product.rb', line 50

def products
  return @products if @products

  control_products = Yast::ProductFeatures.GetFeature("software", "base_products")

  if !control_products.is_a?(Array)
    log.warn("Invalid or missing 'software/base_products' value: #{control_products.inspect}")
    @products = []
    return @products
  end

  arch = REG_ARCH[Yast::Arch.architecture] || Yast::Arch.architecture
  linuxrc_products = (Yast::Linuxrc.InstallInf("specialproduct") || "").split(",").map(&:strip)

  @products = control_products.each_with_object([]) do |p, array|
    # a hidden product requested?
    if p["special_product"] && !linuxrc_products.include?(p["name"])
      log.info "Skipping special hidden product #{p["name"]}"
      next
    end

    # compatible arch?
    if p["archs"] && !p["archs"].split(",").map(&:strip).include?(arch)
      log.info "Skipping product #{p["name"]} - not compatible with arch #{arch}"
      next
    end

    array << new(
      name:            p["name"],
      version:         p["version"],
      arch:            arch,
      label:           p["display_name"],
      license_url:     p["license_url"],
      # expand the "$arch" placeholder
      register_target: (p["register_target"] || "").gsub("$arch", arch)
    )
  end
end

Instance Method Details

#selected?Boolean

Is the product selected?

Returns:

  • (Boolean)

    true if the product is the selected base product


110
111
112
# File 'library/packages/src/lib/y2packager/product_control_product.rb', line 110

def selected?
  self == self.class.selected
end