Class: Yast::InstCongratulateClient

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

Instance Method Summary collapse

Instance Method Details

#CallCloningObject



308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
# File 'src/lib/installation/clients/inst_congratulate.rb', line 308

def CallCloning
  # #187558
  # Load Add-On products configured in the fist stage
  AddOnProduct.ReadTmpExportFilename

  if Package.InstallMsg(
    "autoyast2",
    _(
      "<p>To clone the current system, the <b>%1</b> package must be installed.</p>"
    ) +
      _("<p>Install it now?</p>")
  )
    # #165860
    # Save sources now because cloning garbles the target
    # Cloning reinitializes sources when it needs them
    Pkg.SourceSaveAll

    Call.Function("clone_system", [])
  else
    Popup.Error(_("autoyast2 package not installed. Cloning disabled."))
  end

  nil
end

#DisplayKDEHelpBoolean

Function returns true when the default windowmanager is KDE See bug 170880 for more information

Returns:

  • (Boolean)

    wm is is_kde



294
295
296
297
298
299
300
301
302
303
304
305
306
# File 'src/lib/installation/clients/inst_congratulate.rb', line 294

def DisplayKDEHelp
  default_wm = Convert.to_string(
    SCR.Read(path(".sysconfig.windowmanager.\"DEFAULT_WM\""))
  )
  Builtins.y2debug("Default WM: %1", default_wm)

  if !default_wm.nil? &&
      Builtins.issubstring(Builtins.tolower(default_wm), "kde")
    return true
  end

  false
end

#mainObject



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
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
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
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
# File 'src/lib/installation/clients/inst_congratulate.rb', line 30

def main
  Yast.import "Pkg"
  Yast.import "UI"
  textdomain "installation"

  Yast.import "Mode"
  Yast.import "Wizard"
  Yast.import "Popup"
  Yast.import "Label"
  Yast.import "ProductFeatures"
  Yast.import "GetInstArgs"
  Yast.import "Call"
  Yast.import "Package"
  Yast.import "ProductControl"
  Yast.import "Stage"
  Yast.import "AddOnProduct"
  Yast.import "Service"

  @argmap = GetInstArgs.argmap

  # show button "clone system"?
  @show_clone_checkbox = !(Stage.firstboot || Mode.live_installation)
  @clone_checkbox_active = ProductFeatures.GetBooleanFeature(
    "globals",
    "enable_clone"
  )
  @clone_enabled = Package.Installed("autoyast2")

  # #302495: Switching ZMD off
  # by default, the checkbox is not visible
  @zmd_service_name = "novell-zmd"
  @zmd_package_name = "zmd"
  @check_box_turnoff_zmd = Empty()
  @turnoff_zmd_help = ""

  # See FATE #302495
  # Param 'show_zmd_turnoff_checkbox' says whether the checkbox for stopping and
  # disabling ZMD should be shown
  @show_zmd_turnoff_checkbox = Ops.get_string(
    @argmap,
    "show_zmd_turnoff_checkbox",
    "no"
  ) == "yes"

  # Param 'zmd_turnoff_default_state' says whether the checkbox is selected or
  # not by default
  @turnoff_zmd_default_state = Ops.get_string(
    @argmap,
    "zmd_turnoff_default_state",
    "no"
  ) == "yes"

  @zmd_installed = Package.Installed(@zmd_package_name)
  # don't check for state a service that is not installed
  @zmd_enabled_or_running = @zmd_installed &&
    (Service.Enabled(@zmd_service_name) ||
      Service.Status(@zmd_service_name) == 0)
  Builtins.y2milestone(
    "ZMD Installed: %1, Enabled/Running: %2",
    @zmd_installed,
    @zmd_enabled_or_running
  )
  Builtins.y2milestone(
    "Show TurnOffZMD checkbox: %1, default state: %2",
    @show_zmd_turnoff_checkbox,
    @turnoff_zmd_default_state
  )

  # + 'show_zmd_turnoff_checkbox'
  # + ZMD package needs to be installed
  # + ZMD service needs to be enabled
  if @show_zmd_turnoff_checkbox && @zmd_installed && @zmd_enabled_or_running
    @check_box_turnoff_zmd = CheckBox(
      Id(:turnoff_zmd),
      # TRANSLATORS: check box, see #ZMD
      _("&Disable ZMD Service"),
      # control_file->software->zmd_turnoff_default_state
      # says whether the checkbox is selected or not by default
      @turnoff_zmd_default_state
    )

    # TRANSLATORS: help text, see #ZMD
    @turnoff_zmd_help = _(
      "<p>Select <b>Disable ZMD Service</b> to stop and disable\n" \
      "the ZMD service during system start.</p>\n"
    )
  else
    Builtins.y2milestone("ZMD Turnoff check-box will be invisible")
  end

  @display = UI.GetDisplayInfo
  @space = Ops.get_boolean(@display, "TextMode", true) ? 1 : 3
  @vendor_url_tmp = ProductFeatures.GetStringFeature(
    "globals",
    "vendor_url"
  )

  # fallback
  @vendor_url = "http://www.suse.com/"
  @vendor_url = "http://www.openSUSE.org" if ProductFeatures.GetStringFeature("globals",
    "ui_mode") == "simple"
  Builtins.y2milestone(
    "UI mode: %1",
    ProductFeatures.GetStringFeature("globals", "ui_mode")
  )

  @vendor_url = @vendor_url_tmp if !@vendor_url_tmp.nil? && @vendor_url_tmp != ""

  @check_box_do_clone = Empty()

  if @show_clone_checkbox
    @check_box_do_clone = CheckBox(
      Id(:do_clone),
      # Check box: start the clone process and store the AutoYaST
      # profile in /root/autoinst.xml
      _("&Clone This System for AutoYaST"),
      @clone_checkbox_active
    )
  end

  # caption for dialog "Congratulation Dialog"
  @caption = _("Installation Completed")

  @text = ProductControl.GetTranslatedText("congratulate")

  @text = if @text == ""
    # congratulation text 1/4
    Ops.add(
      Ops.add(
        _("<p><b>Congratulations!</b></p>") +
          # congratulation text 2/4
          _(
            "<p>The installation of &product; on your machine is complete.\n" \
            "After clicking <b>Finish</b>, you can log in to the system.</p>\n"
          ),
        # congratulation text 3/4
        Builtins.sformat(_("<p>Visit us at %1.</p>"), @vendor_url)
      ),
      # congratulation text 4/4
      _("<p>Have a lot of fun!<br>Your SUSE Development Team</p>")
    )
  else
    Builtins.sformat(@text, @vendor_url)
  end

  @contents = VBox(
    VSpacing(@space),
    HBox(
      HSpacing(Ops.multiply(2, @space)),
      VBox(
        RichText(Id(:text), @text),
        VSpacing(Ops.divide(@space, 2)),
        Left(@check_box_turnoff_zmd),
        Left(@check_box_do_clone)
      ),
      HSpacing(Ops.multiply(2, @space))
    ),
    VSpacing(@space),
    VSpacing(2)
  )

  @help_file = ""
  # help 1/4 for dialog "Congratulation Dialog"
  @help = _("<p>Your system is ready for use.</p>") +
    # help 2/4 for dialog "Congratulation Dialog"
    _(
      "<p><b>Finish</b> will close the YaST installation and take you\n" \
      "to the login screen.</p>\n"
    ) +
    # help 3/4 for dialog "Congratulation Dialog"
    (if DisplayKDEHelp()
       _(
         "<p>If you choose the default graphical desktop KDE, you can\n" \
         "adjust some KDE settings to your hardware. Also notice\n" \
         "our SUSE Welcome Dialog.</p>\n"
       )
     else
       ""
     end) # Show this help only in case of KDE as the default windowmanager

  if @show_clone_checkbox
    @help = Ops.add(
      @help,
      _(
        "<p>Use <b>Clone</b> if you want to create an AutoYaST profile.\n" \
        "AutoYaST is a way to do a complete SUSE Linux installation without user " \
        "interaction. AutoYaST\n" \
        "needs a profile to know what the installed system should look like. " \
        "If this option is\n" \
        "selected, a profile of the current system is stored in " \
        "<tt>/root/autoinst.xml</tt>.</p>"
      )
    )
  end
  @help = Ops.add(@help, @turnoff_zmd_help) if @show_zmd_turnoff_checkbox

  Wizard.SetContents(
    @caption,
    @contents,
    @help,
    GetInstArgs.enable_back,
    GetInstArgs.enable_next
  )

  Wizard.SetNextButton(:next, Label.FinishButton)
  Wizard.RestoreAbortButton
  # At this point the configuration is already applied and aborting doesn't
  # make sense at all, at least for firstboot. For that reason we will
  # hide the option (bsc#1095253)
  Wizard.HideAbortButton if Stage.firstboot
  Wizard.SetFocusToNextButton
  UI.ChangeWidget(Id(:do_clone), :Enabled, @clone_enabled) if UI.WidgetExists(Id(:do_clone))

  @ret = nil
  loop do
    @ret = Wizard.UserInput

    case @ret
    when :abort
      break if Popup.ConfirmAbort(:incomplete)
    when :help
      Wizard.ShowHelp(@help)
    end
    break if [:next, :back].include?(@ret)
  end

  # bugzilla #221190
  case @ret
  when :back
    Wizard.RestoreNextButton
  when :next
    # BNC #441452
    # Remove the congrats dialog
    @zmd = UI.WidgetExists(Id(:turnoff_zmd)) &&
      Convert.to_boolean(UI.QueryWidget(Id(:turnoff_zmd), :Value))
    @clone = UI.WidgetExists(Id(:do_clone)) &&
      Convert.to_boolean(UI.QueryWidget(Id(:do_clone), :Value))

    # Dialog busy message
    Wizard.SetContents(
      @caption,
      Label(_("Finishing the installation...")),
      @help,
      GetInstArgs.enable_back,
      GetInstArgs.enable_next
    )

    StopAndDisableZMD() if @zmd

    CallCloning() if @clone
  end

  # save all sources and finish target
  # bnc #398315
  Pkg.SourceSaveAll
  Pkg.TargetFinish

  deep_copy(@ret)
end

#StopAndDisableZMDObject



333
334
335
336
337
338
339
340
341
342
343
344
345
346
# File 'src/lib/installation/clients/inst_congratulate.rb', line 333

def StopAndDisableZMD
  Builtins.y2milestone(
    "Stopping service: %1 -> %2",
    @zmd_service_name,
    Service.Stop(@zmd_service_name)
  )
  Builtins.y2milestone(
    "Disabling service: %1 -> %2",
    @zmd_service_name,
    Service.Disable(@zmd_service_name)
  )

  nil
end