Class: Yast::ProductClass
- Inherits:
-
Module
- Object
- Module
- Yast::ProductClass
- Includes:
- Logger
- Defined in:
- ../../src/modules/Product.rb
Constant Summary
- OS_RELEASE_PROPERTIES =
Values loaded from os-release file
[ :name, :short_name, :version ]
- DROPPED_METHODS =
All these methods have been dropped
[ :vendor, :dist, :distproduct, :distversion, :shortlabel ]
Instance Method Summary (collapse)
-
- (Object) find_property(key = __callee__)
(also: #name, #short_name, #version, #run_you, #flags, #relnotesurl, #relnotesurl_all, #product_of_relnotes)
Loads and returns base product property.
-
- (Array <Hash>) FindBaseProducts
Returns list Hashes of selected (installation) or installed (running system) base products got from libzypp.
- - (Object) main
-
- (Object) ReadProducts
Reads products from libzypp and fills the internal products cache that can be read by other methods in this library.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
- (Object) method_missing(method_name, *args, &block) (private)
Handles using dropped methods
272 273 274 275 276 277 278 279 |
# File '../../src/modules/Product.rb', line 272 def method_missing(method_name, *args, &block) if DROPPED_METHODS.include? method_name log.error "Method Product.#{method_name} dropped" raise "Method Product.#{method_name} has been dropped" else super end end |
Instance Method Details
- (Object) find_property(key = __callee__) Also known as: name, short_name, version, run_you, flags, relnotesurl, relnotesurl_all, product_of_relnotes
Loads and returns base product property
50 51 52 53 |
# File '../../src/modules/Product.rb', line 50 def find_property(key = __callee__) load_product_data(key) get_property(key) end |
- (Array <Hash>) FindBaseProducts
Returns list Hashes of selected (installation) or installed (running system) base products got from libzypp
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File '../../src/modules/Product.rb', line 93 def FindBaseProducts return unless load_zypp log.info "Looking for base products" products = Pkg.ResolvableProperties("", :product, "") || [] # For all (not only base) products # TODO FIXME: filling release notes is a nasty side effect of searching the base product, # it should be handled separately... required_status = use_installed_products? ? :installed : :selected fill_up_relnotes(products.select{ |p| p["status"] == required_status }) # Use only base products products.select! do |p| # The category "base" is not set during installation yet, it is set # only for _installed_ base product (otherwise "addon" is reported). # Use the product from the initial repository during installation. use_installed_products? ? (p["category"] == "base") : (p["source"] == 0) end log.info "Found #{products.size} base product(s)" if products.empty? log.error "No base product found" raise "No base product found" elsif products.size > 1 log.warn "More than one base product found!" end deep_copy(products) end |
- (Object) main
38 39 40 41 42 43 44 45 |
# File '../../src/modules/Product.rb', line 38 def main Yast.import "Pkg" Yast.import "Mode" Yast.import "Stage" Yast.import "OSRelease" Yast.import "PackageLock" Yast.import "PackageSystem" end |
- (Object) ReadProducts
Reads products from libzypp and fills the internal products cache that can be read by other methods in this library
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
# File '../../src/modules/Product.rb', line 128 def ReadProducts # Do not read any product information from zypp on a running system return if Mode.config Builtins.y2milestone("Product.#{__method__} started") return unless load_zypp base_product = FindBaseProducts().fetch(0, {}) set_property( :name, base_product.fetch("display_name", base_product.fetch("summary", base_product.fetch("name", "") ) ) ) set_property(:short_name, base_product.fetch("short_name", name)) set_property(:version, base_product.fetch("version", "").split("-")[0]) set_property(:relnotesurl, base_product.fetch("relnotes_url", "")) set_property(:flags, base_product.fetch("flags", [])) set_property(:run_you, flags.include?("no_you")) nil end |