Class: Yast::ProductClass

Inherits:
Module
  • Object
show all
Defined in:
../../src/modules/Product.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) FindBaseProducts



83
84
85
86
87
88
89
90
91
92
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
# File '../../src/modules/Product.rb', line 83

def FindBaseProducts
  # bugzilla #238556
  if !PackageLock.Check
    Builtins.y2error("Locked!")
    return []
  end

  Builtins.y2milestone("Looking for base products")
  products = Pkg.ResolvableProperties("", :product, "")
  products = Builtins.filter(products) do |p|
    Ops.get_symbol(p, "status", :none) == :installed
  end

  Builtins.y2milestone("All found products: %1", products)

  products = Builtins.filter(products) do |p|
    # bug 165314, relnotes_url needn't be defined (or empty string)
    if Ops.get_string(p, "relnotes_url", "") != ""
      rn_url = Ops.get_string(p, "relnotes_url", "")
      @relnotesurl_all = Builtins.add(@relnotesurl_all, rn_url)
      # bug 180581, relnotes should be identified by name
      Ops.set(
        @product_of_relnotes,
        rn_url,
        Ops.get_string(p, "display_name", "")
      )
    end
    Ops.get_string(p, "category", "") == "base"
  end

  Builtins.y2milestone("Found base products: %1", products)
  if Builtins.size(products) == 0
    Builtins.y2error("No base product found")
  elsif Ops.greater_than(Builtins.size(products), 1)
    Builtins.y2warning("More than one base product found")
  end
  deep_copy(products)
end

- (Object) main



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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
# File '../../src/modules/Product.rb', line 35

def main
  Yast.import "Pkg"

  Yast.import "Mode"
  Yast.import "Stage"
  Yast.import "OSRelease"
  Yast.import "PackageLock"
  Yast.import "PackageSystem"

  # General product name and version
  @name = "" # "SuSE Linux 8.1"
  @short_name = "" # "SuSE Linux"
  @version = "" # "8.1"
  @vendor = "" # "SuSE Linux AG"

  # Distribution: Personal, Professional, etc.
  @dist = ""
  @distproduct = "" # "SuSE-Linux-Professional-INT-i386"
  @distversion = "" # "8.1-0"

  # base product
  @baseproduct = "" # "UnitedLinux"
  @baseversion = "" # "1.0"

  # url of release notes (downloaded during internet test)
  @relnotesurl = ""

  # list of all urls of release notes (downloaded during internet test)
  # bugzilla #160563
  @relnotesurl_all = []

  # map relnotes url to product name
  @product_of_relnotes = {}

  #  Run YOU during the Internet connection test.
  @run_you = true

  # list of flags from content file
  @flags = []

  # list of patterns from content file
  @patterns = []

  # Short label for bootloader entry
  @shortlabel = ""
  Product()
end

- (Object) Product

———————————————– Constructor



163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
# File '../../src/modules/Product.rb', line 163

def Product
  if Stage.initial && !Mode.live_installation
    # it should use the same mechanism as running system. But it would
    # mean to initialize package manager from constructor, which is
    # not reasonable
    @name = Convert.to_string(SCR.Read(path(".content.LABEL")))
    @short_name = Convert.to_string(SCR.Read(path(".content.SHORTLABEL")))
    @short_name = @name if @short_name == nil
    @version = Convert.to_string(SCR.Read(path(".content.VERSION")))
    @vendor = Convert.to_string(SCR.Read(path(".content.VENDOR")))

    @distproduct = Convert.to_string(SCR.Read(path(".content.DISTPRODUCT")))
    @distversion = Convert.to_string(SCR.Read(path(".content.DISTVERSION")))

    @baseproduct = Convert.to_string(SCR.Read(path(".content.BASEPRODUCT")))
    @baseproduct = @name if @baseproduct == ""
    @baseversion = Convert.to_string(SCR.Read(path(".content.BASEVERSION")))

    @relnotesurl = Convert.to_string(SCR.Read(path(".content.RELNOTESURL")))
    @shortlabel = Convert.to_string(SCR.Read(path(".content.SHORTLABEL")))

    tmp1 = SCR.Read(path(".content.FLAGS"))
    if tmp1 != nil
      @flags = Builtins.splitstring(Convert.to_string(tmp1), " ")
    end
    tmp1 = SCR.Read(path(".content.PATTERNS"))
    if tmp1 != nil
      @patterns = Builtins.splitstring(Convert.to_string(tmp1), " ")
    end

    # bugzilla #252122, since openSUSE 10.3
    # deprecated:
    # 		content.PATTERNS: abc cba bac
    # should re replaced with (and/or)
    # 		content.REQUIRES: pattern:abc pattern:cba pattern:bac
    #		content.RECOMMENDS: pattern:abc pattern:cba pattern:bac
    if @patterns != []
      Builtins.y2warning(
        "Product content file contains deprecated PATTERNS tag, use REQUIRES and/or RECOMMENDS instead"
      )
      Builtins.y2milestone("PATTERNS: %1", @patterns)
    end
  # not during testing: Misc::CustomSysconfigRead used by OSRelease creates agent in runtime,
  # mocking IniParser not possible
  elsif !Mode.config && !Mode.test
    @short_name = OSRelease.ReleaseName
    @version = OSRelease.ReleaseVersion
    @name = Ops.add(Ops.add(@short_name, " "), @version)
  end

  @distproduct = "" if @distproduct == nil
  @dist = Ops.get(Builtins.splitstring(@distproduct, "-"), 2, "")

  @run_you = !Builtins.contains(@flags, "no_you")

  # set the product name for UI
  Yast.import "Wizard"

  Builtins.y2milestone("Product name: '%1'", @name)

  Wizard.SetProductName(@name) if @name != nil && @name != ""

  nil
end

- (Object) ReadProducts

Read the products from the package manager



123
124
125
126
127
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
154
155
156
157
158
# File '../../src/modules/Product.rb', line 123

def ReadProducts
  Builtins.y2milestone("Product::ReadProducts() started")
  if !Mode.config
    # bugzilla #238556
    if !PackageLock.Check
      Builtins.y2error("Locked!")
      return
    end

    PackageSystem.EnsureTargetInit
    PackageSystem.EnsureSourceInit # TODO: is it still needed?

    # run the solver to compute the installed products
    Pkg.PkgSolve(true) # TODO: is it still needed?

    base_products = FindBaseProducts()
    base_product = Ops.get(base_products, 0, {}) # there should be only one - hopefuly

    @name = Ops.get_string(
      base_product,
      "display_name",
      Ops.get_string(
        base_product,
        "summary",
        Ops.get_string(base_product, "name", "")
      )
    )
    @short_name = Ops.get_string(base_product, "short_name", @name)
    @version = Ops.get_string(base_product, "version", "")
    @vendor = Ops.get_string(base_product, "vendor", "")
    @relnotesurl = Ops.get_string(base_product, "relnotes_url", "")
    @flags = Ops.get_list(base_product, "flags", [])
  end

  nil
end