Class: Yast::AutoinstGeneralClass

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

Instance Method Summary (collapse)

Instance Method Details

- (Object) AutoinstGeneral

Constructor



415
416
417
418
419
420
421
422
423
424
# File '../../src/modules/AutoinstGeneral.rb', line 415

def AutoinstGeneral
  if Stage.cont
    # FIXME: wrong position for this
    if Ops.get_map(Profile.current, "general", {}) != {}
      Import(Ops.get_map(Profile.current, "general", {}))
    end
    SetSignatureHandling()
  end
  nil
end

- (Hash) Export

Export Configuration

Returns:

  • (Hash)


185
186
187
188
189
190
191
192
193
194
# File '../../src/modules/AutoinstGeneral.rb', line 185

def Export
  general = {}

  Ops.set(general, "mode", @mode)
  Ops.set(general, "signature-handling", @signature_handling)
  Ops.set(general, "ask-list", @askList)
  Ops.set(general, "proposals", @proposals)
  Ops.set(general, "storage", @storage)
  deep_copy(general)
end

- (Boolean) GetModified

Functions which returns if the settings were modified

Returns:

  • (Boolean)

    settings were modified



69
70
71
# File '../../src/modules/AutoinstGeneral.rb', line 69

def GetModified
  @modified
end

- (Object) Import(settings)

Import Configuration

Parameters:

  • settings (Hash)

Returns:

  • booelan



169
170
171
172
173
174
175
176
177
178
179
180
# File '../../src/modules/AutoinstGeneral.rb', line 169

def Import(settings)
  settings = deep_copy(settings)
  SetModified()
  Builtins.y2milestone("General import: %1", settings)
  @mode = Ops.get_map(settings, "mode", {})
  @signature_handling = Ops.get_map(settings, "signature-handling", {})
  @askList = Ops.get_list(settings, "ask-list", [])
  @proposals = Ops.get_list(settings, "proposals", [])
  @storage = Ops.get_map(settings, "storage", {})

  true
end

- (Object) main



13
14
15
16
17
18
19
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
# File '../../src/modules/AutoinstGeneral.rb', line 13

def main
  Yast.import "Pkg"
  textdomain "autoinst"

  Yast.import "Stage"
  Yast.import "AutoInstall"
  Yast.import "AutoinstConfig"
  Yast.import "Summary"
  Yast.import "Keyboard"
  Yast.import "Language"
  Yast.import "Timezone"
  Yast.import "Misc"
  Yast.import "Profile"
  Yast.import "ProductFeatures"
  Yast.import "Storage"
  Yast.import "SignatureCheckCallbacks"

  # All shared data are in yast2.rpm to break cyclic dependencies
  Yast.import "AutoinstData"

  #
  # Show proposal and ask user for confirmation to go on with auto-installation
  # Similar to interactive mode, without letting use change settings
  # Interactive mode implies confirmation as well..
  #
  @Confirm = true

  #
  # Mode Settings
  #
  @mode = {}

  @signature_handling = {}

  @askList = []

  #    global list<string> proposals = ["bootloader_proposal", "software_proposal", "country_simple_proposal", "timezone_proposal", "users_proposal", "runlevel_proposal", "hwinfo_proposal", "deploying_proposal"];
  @proposals = []

  @storage = {}

  # default value of settings modified
  @modified = false
  AutoinstGeneral()
end

- (Object) SetModified

Function sets internal variable, which indicates, that any settings were modified, to "true"



61
62
63
64
65
# File '../../src/modules/AutoinstGeneral.rb', line 61

def SetModified
  @modified = true

  nil
end

- (void) SetMultipathing

This method returns an undefined value.

set multipathing



377
378
379
380
381
# File '../../src/modules/AutoinstGeneral.rb', line 377

def SetMultipathing
  val = @storage.fetch("start_multipath",false)
  Builtins.y2milestone("SetMultipathing val:%1", val)
  Storage.SetMultipathStartup(val)
end

- (void) SetSignatureHandling

This method returns an undefined value.

set the sigature handling



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
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
# File '../../src/modules/AutoinstGeneral.rb', line 198

def SetSignatureHandling
  # this will break compatibility a bit. A XML file without signature handling can
  # block the installation now because we have the popups back
  Pkg.CallbackAcceptUnsignedFile(
    fun_ref(
      SignatureCheckCallbacks.method(:AcceptUnsignedFile),
      "boolean (string, integer)"
    )
  )
  Pkg.CallbackAcceptFileWithoutChecksum(
    fun_ref(
      SignatureCheckCallbacks.method(:AcceptFileWithoutChecksum),
      "boolean (string)"
    )
  )
  Pkg.CallbackAcceptVerificationFailed(
    fun_ref(
      SignatureCheckCallbacks.method(:AcceptVerificationFailed),
      "boolean (string, map <string, any>, integer)"
    )
  )
  Pkg.CallbackTrustedKeyAdded(
    fun_ref(
      SignatureCheckCallbacks.method(:TrustedKeyAdded),
      "void (map <string, any>)"
    )
  )
  Pkg.CallbackAcceptUnknownGpgKey(
    fun_ref(
      SignatureCheckCallbacks.method(:AcceptUnknownGpgKey),
      "boolean (string, string, integer)"
    )
  )
  Pkg.CallbackImportGpgKey(
    fun_ref(
      SignatureCheckCallbacks.method(:ImportGpgKey),
      "boolean (map <string, any>, integer)"
    )
  )
  Pkg.CallbackAcceptWrongDigest(
    fun_ref(
      SignatureCheckCallbacks.method(:AcceptWrongDigest),
      "boolean (string, string, string)"
    )
  )
  Pkg.CallbackAcceptUnknownDigest(
    fun_ref(
      SignatureCheckCallbacks.method(:AcceptUnknownDigest),
      "boolean (string, string)"
    )
  )
  Pkg.CallbackTrustedKeyRemoved(
    fun_ref(
      SignatureCheckCallbacks.method(:TrustedKeyRemoved),
      "void (map <string, any>)"
    )
  )

  if Builtins.haskey(@signature_handling, "accept_unsigned_file")
    Pkg.CallbackAcceptUnsignedFile(
      Ops.get_boolean(@signature_handling, "accept_unsigned_file", false) ?
        fun_ref(
          AutoInstall.method(:callbackTrue_boolean_string_integer),
          "boolean (string, integer)"
        ) :
        fun_ref(
          AutoInstall.method(:callbackFalse_boolean_string_integer),
          "boolean (string, integer)"
        )
    )
  end
  if Builtins.haskey(@signature_handling, "accept_file_without_checksum")
    Pkg.CallbackAcceptFileWithoutChecksum(
      Ops.get_boolean(
        @signature_handling,
        "accept_file_without_checksum",
        false
      ) ?
        fun_ref(
          AutoInstall.method(:callbackTrue_boolean_string),
          "boolean (string)"
        ) :
        fun_ref(
          AutoInstall.method(:callbackFalse_boolean_string),
          "boolean (string)"
        )
    )
  end
  if Builtins.haskey(@signature_handling, "accept_verification_failed")
    Pkg.CallbackAcceptVerificationFailed(
      Ops.get_boolean(
        @signature_handling,
        "accept_verification_failed",
        false
      ) ?
        fun_ref(
          AutoInstall.method(:callbackTrue_boolean_string_map_integer),
          "boolean (string, map <string, any>, integer)"
        ) :
        fun_ref(
          AutoInstall.method(:callbackFalse_boolean_string_map_integer),
          "boolean (string, map <string, any>, integer)"
        )
    )
  end
  if Builtins.haskey(@signature_handling, "trusted_key_added")
    Pkg.CallbackTrustedKeyAdded(
      fun_ref(
        AutoInstall.method(:callback_void_map),
        "void (map <string, any>)"
      )
    )
  end
  if Builtins.haskey(@signature_handling, "trusted_key_removed")
    Pkg.CallbackTrustedKeyRemoved(
      fun_ref(
        AutoInstall.method(:callback_void_map),
        "void (map <string, any>)"
      )
    )
  end
  if Builtins.haskey(@signature_handling, "accept_unknown_gpg_key")
    Pkg.CallbackAcceptUnknownGpgKey(
      Ops.get_boolean(@signature_handling, "accept_unknown_gpg_key", false) ?
        fun_ref(
          AutoInstall.method(:callbackTrue_boolean_string_string_integer),
          "boolean (string, string, integer)"
        ) :
        fun_ref(
          AutoInstall.method(:callbackFalse_boolean_string_string_integer),
          "boolean (string, string, integer)"
        )
    )
  end
  if Builtins.haskey(@signature_handling, "import_gpg_key")
    Pkg.CallbackImportGpgKey(
      Ops.get_boolean(@signature_handling, "import_gpg_key", false) ?
        fun_ref(
          AutoInstall.method(:callbackTrue_boolean_map_integer),
          "boolean (map <string, any>, integer)"
        ) :
        fun_ref(
          AutoInstall.method(:callbackFalse_boolean_map_integer),
          "boolean (map <string, any>, integer)"
        )
    )
  end
  if Builtins.haskey(@signature_handling, "accept_wrong_digest")
    Pkg.CallbackAcceptWrongDigest(
      Ops.get_boolean(@signature_handling, "accept_wrong_digest", false) ?
        fun_ref(
          AutoInstall.method(:callbackTrue_boolean_string_string_string),
          "boolean (string, string, string)"
        ) :
        fun_ref(
          AutoInstall.method(:callbackFalse_boolean_string_string_string),
          "boolean (string, string, string)"
        )
    )
  end
  if Builtins.haskey(@signature_handling, "accept_unknown_digest")
    Pkg.CallbackAcceptWrongDigest(
      Ops.get_boolean(@signature_handling, "accept_unknown_digest", false) ?
        fun_ref(
          AutoInstall.method(:callbackTrue_boolean_string_string_string),
          "boolean (string, string, string)"
        ) :
        fun_ref(
          AutoInstall.method(:callbackFalse_boolean_string_string_string),
          "boolean (string, string, string)"
        )
    )
  end

  nil
end

- (String) Summary

Summary of configuration

Returns:

  • (String)

    Formatted summary



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
# File '../../src/modules/AutoinstGeneral.rb', line 75

def Summary
  #string language_name		= "";
  #string keyboard_name		= "";


  summary = ""

  summary = Summary.AddHeader(summary, _("Confirm installation?"))
  summary = Summary.AddLine(
    summary,
    Ops.get_boolean(@mode, "confirm", true) ? _("Yes") : _("No")
  )

  summary = Summary.AddHeader(summary, _("Second Stage of AutoYaST"))
  summary = Summary.AddLine(
    summary,
    Ops.get_boolean(@mode, "second_stage", true) ? _("Yes") : _("No")
  )

  summary = Summary.AddHeader(
    summary,
    _("Halting the machine after stage one")
  )
  summary = Summary.AddLine(
    summary,
    Ops.get_boolean(@mode, "halt", false) ? _("Yes") : _("No")
  )
  if Ops.get_boolean(@mode, "final_halt", false) == true
    summary = Summary.AddHeader(
      summary,
      _("Halting the machine after stage two")
    )
    summary = Summary.AddLine(summary, _("Yes"))
  end
  if Ops.get_boolean(@mode, "final_reboot", false) == true
    summary = Summary.AddHeader(
      summary,
      _("Reboot the machine after stage two")
    )
    summary = Summary.AddLine(summary, _("Yes"))
  end


  summary = Summary.AddHeader(summary, _("Signature Handling"))
  summary = Summary.AddLine(
    summary,
    Ops.get_boolean(@signature_handling, "accept_unsigned_file", false) ?
      _("Accepting unsigned files") :
      _("Not accepting unsigned files")
  )
  summary = Summary.AddLine(
    summary,
    Ops.get_boolean(
      @signature_handling,
      "accept_file_without_checksum",
      false
    ) ?
      _("Accepting files without a checksum") :
      _("Not accepting files without a checksum")
  )
  summary = Summary.AddLine(
    summary,
    Ops.get_boolean(
      @signature_handling,
      "accept_verification_failed",
      false
    ) ?
      _("Accepting failed verifications") :
      _("Not accepting failed verifications")
  )
  summary = Summary.AddLine(
    summary,
    Ops.get_boolean(@signature_handling, "accept_unknown_gpg_key", false) ?
      _("Accepting unknown GPG keys") :
      _("Not accepting unknown GPG Keys")
  )
  summary = Summary.AddLine(
    summary,
    Ops.get_boolean(@signature_handling, "import_gpg_key", false) ?
      _("Importing new GPG keys") :
      _("Not importing new GPG Keys")
  )

  #	summary = Summary::AddHeader(summary, _("Proposals"));
  #        foreach(string p, proposals, ``{
  #		summary = Summary::AddLine(summary, p);
  #	});

  summary
end

- (Boolean) Write

Write General Configuration

Returns:

  • (Boolean)

    true on success



385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
# File '../../src/modules/AutoinstGeneral.rb', line 385

def Write
  AutoinstConfig.Confirm = Ops.get_boolean(@mode, "confirm", true)
  if Builtins.haskey(@mode, "forceboot")
    ProductFeatures.SetBooleanFeature(
      "globals",
      "kexec_reboot",
      !Ops.get_boolean(@mode, "forceboot", false)
    )
  end
  AutoinstConfig.Halt = Ops.get_boolean(@mode, "halt", false)
  AutoinstConfig.RebootMsg = Ops.get_boolean(@mode, "rebootmsg", false)
  AutoinstConfig.setProposalList(@proposals)

  # see bug #597723. Some machines can't boot with the new alignment that parted uses
  # `align_cylinder == old behavior
  # `align_optimal  == new behavior
  if @storage.has_key?("partition_alignment")
    val = @storage.fetch("partition_alignment",:align_optimal)
    Storage.SetPartitionAlignment(val)
    Builtins.y2milestone( "alignment set to %1", val )
  end

  SetMultipathing()

  SetSignatureHandling()

  nil
end