Class: Yast::InstPrepareprogressClient

Inherits:
Client
  • Object
show all
Defined in:
src/lib/installation/clients/inst_prepareprogress.rb

Instance Method Summary collapse

Instance Method Details

#mainObject



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
80
81
82
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
121
122
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
# File 'src/lib/installation/clients/inst_prepareprogress.rb', line 32

def main
  textdomain "installation"
  Yast.import "Installation"
  Yast.import "Mode"
  Yast.import "Packages"
  Yast.import "Language"
  Yast.import "SlideShow"
  Yast.import "ImageInstallation"
  Yast.import "PackageSlideShow"
  Yast.import "Wizard"
  Yast.import "InstData"
  Yast.import "Product"
  Yast.import "Report"

  Builtins.y2milestone("BEGIN of inst_prepareprogress.ycp")

  # hide the RN button and set the release notes for SlideShow (bnc#871158)
  Wizard.HideReleaseNotesButton
  base_products = Product.FindBaseProducts
  base_product_name = base_products && !base_products.empty? &&
    base_products.first["name"]
  if !base_product_name || base_product_name.empty?
    Builtins.y2error "base product not found. Products: #{base_products.inspect}."
    Report.Error _("Cannot find base product. Release notes will not be shown.")
    SlideShow.SetReleaseNotes(InstData.release_notes, "")
  else
    SlideShow.SetReleaseNotes(InstData.release_notes, base_product_name)
  end

  Packages.SlideShowSetUp(Language.language)

  SlideShow.OpenDialog
  PackageSlideShow.InitPkgData(true) # FIXME: this is odd!

  # Details (such as images sizes) have to known before initializing the SlideShow
  # but only if Installation from Images is in use
  ImageInstallation.FillUpImagesDetails if Installation.image_installation

  @live_size = 0
  if Mode.live_installation
    @cmd = Builtins.sformat("df -P -k %1", "/")
    Builtins.y2milestone("Executing %1", @cmd)
    @out = Convert.to_map(SCR.Execute(path(".target.bash_output"), @cmd))
    Builtins.y2milestone("Output: %1", @out)
    @total_str = Ops.get_string(@out, "stdout", "")
    @total_str = Ops.get(Builtins.splitstring(@total_str, "\n"), 1, "")
    @live_size = Builtins.tointeger(
      Ops.get(
        Builtins.filter(Builtins.splitstring(@total_str, " ")) do |s|
          s != ""
        end,
        2,
        "0"
      )
    )

    # Using df-based progress estimation, is rather faster
    #    may be less precise
    #    see bnc#555288
    #     string cmd = sformat ("du -x -B 1024 -s %1", "/");
    #     y2milestone ("Executing %1", cmd);
    #     map out = (map)SCR::Execute (.target.bash_output, cmd);
    #     y2milestone ("Output: %1", out);
    #     string total_str = out["stdout"]:"";
    #     live_size = tointeger (total_str);
    @live_size = 1024 * 1024 if @live_size == 0 # 1 GB is a good approximation
  end

  @stages = [
    {
      "name"        => "disk",
      "description" => _("Preparing disks..."),
      "value"       => Mode.update ? 0 : 120, # FIXME: 2 minutes
      "units"       => :sec
    },
    {
      "name"        => "images",
      "description" => _("Deploying Images..."),
      # Use 'zero' if image installation is not used
      # BNC #439104
      "value"       => if @live_size > 0
                         @live_size
                       elsif Installation.image_installation
                         ImageInstallation.TotalSize / 1024
                       else
                         0
                       end,
      "units"       => :kb
    },
    {
      "name"        => "packages",
      "description" => _("Installing Packages..."),
      # here, we do a hack, because until images are deployed, we cannot determine how many
      # packages will be really installed additionally
      "value"       => Ops.divide(
        Ops.subtract(
          PackageSlideShow.total_size_to_install,
          ImageInstallation.TotalSize
        ),
        1024
      ), # kilobytes
      "units"       => :kb
    },
    {
      "name"        => "finish",
      "description" => _("Finishing Basic Installation"),
      # fixed value
      "value"       => 100,
      "units"       => :sec
    }
  ]

  # own workflow for OEM image deployment
  if InstData.image_target_disk
    @stages = [
      {
        "name"        => "images",
        "description" => _("Deploying Images..."),
        "value"       => 300_000, # just make it longer than inst_finish, TODO: better value later
        "units"       => :kb
      },
      {
        "name"        => "finish",
        "description" => _("Finishing Basic Installation"),
        # fixed value
        "value"       => 100,
        "units"       => :sec
      }
    ]

  end

  SlideShow.Setup(@stages)

  @ret_val = :auto

  Builtins.y2milestone("END of inst_prepareprogress.ycp")

  Builtins.y2milestone("Cleaning memory.")
  Builtins.y2milestone("Memory before:\n#{File.read("/proc/#{Process.pid}/status")}")
  # clean as much memory as possible before doing real installation, because some packages
  # can have memory demanding scripts
  GC.start
  Builtins.y2milestone("Memory after:\n#{File.read("/proc/#{Process.pid}/status")}")

  @ret_val
end