Module: Yast::PackagerLoadReleaseNotesInclude

Defined in:
src/include/packager/load_release_notes.rb

Overview

Load release notes from media

Instance Method Summary collapse

Instance Method Details

#initialize_packager_load_release_notes(_include_target) ⇒ Object


5
6
7
8
9
10
11
12
13
14
15
# File 'src/include/packager/load_release_notes.rb', line 5

def initialize_packager_load_release_notes(_include_target)
  Yast.import "Pkg"
  textdomain "packager"

  Yast.import "Language"
  Yast.import "Report"
  Yast.import "Stage"

  # release notes
  @media_text = ""
end

#load_release_notes(source_id) ⇒ Object

function to load release notes


20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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
# File 'src/include/packager/load_release_notes.rb', line 20

def load_release_notes(source_id)
  if source_id.nil? || Ops.less_than(source_id, 0)
    Builtins.y2error("Source_id: %1", source_id)
    return false
  end

  path_to_relnotes = "/docu"
  filename_templ = UI.TextMode ? "/RELEASE-NOTES.%1.txt" : "/RELEASE-NOTES.%1.rtf"

  path_templ = path_to_relnotes + filename_templ
  Builtins.y2debug("Path template: %1", path_templ)

  # try 'en_UK' for 'en_UK'
  tmp = Builtins.sformat(path_templ, Language.language)
  Builtins.y2debug("Trying to get %1", tmp)
  tmp = Pkg.SourceProvideDigestedFile(
    source_id, # optional
    1,
    tmp,
    true
  )

  # try 'es' for 'es_ES'
  if tmp.nil?
    tmp = Builtins.sformat(
      path_templ,
      Builtins.substring(Language.language, 0, 2)
    )
    Builtins.y2debug("Trying to get %1", tmp)
    tmp = Pkg.SourceProvideDigestedFile(
      source_id, # optional
      1,
      tmp,
      true
    )
  end

  # try 'en'
  if tmp.nil?
    tmp = Builtins.sformat(path_templ, "en")
    Builtins.y2debug("Trying to get %1", tmp)
    tmp = Pkg.SourceProvideDigestedFile(
      source_id, # optional
      1,
      tmp,
      true
    )
  end

  # no other fallback
  return false if tmp.nil?

  # read the release notes content
  @media_text = Convert.to_string(
    SCR.Read(path(".target.string"), [tmp, ""])
  )
  return true if @media_text != "" && !@media_text.nil?

  false
end