Class: Yast::AutoinstConfigClass

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

Defined Under Namespace

Modules: Target

Instance Method Summary (collapse)

Instance Method Details

- (void) AutoinstConfig

This method returns an undefined value.

Constructor



400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
# File '../../src/modules/AutoinstConfig.rb', line 400

def AutoinstConfig
  if (Mode.autoinst || Mode.autoupgrade) && Stage.initial
    autoinstall = SCR.Read(path(".etc.install_inf.AutoYaST"))
    if autoinstall != nil && Ops.is_string?(autoinstall)
      ParseCmdLine(Convert.to_string(autoinstall))
      Builtins.y2milestone("cmd line=%1", autoinstall)
      SetProtocolMessage()
    end
  elsif Mode.config
    # Load configuration data from /etc/sysconfig/autoinstall
    @Repository = Misc.SysconfigRead(
      path(".sysconfig.autoinstall.REPOSITORY"),
      "/var/lib/autoinstall/repository/"
    )
    @classDir = Misc.SysconfigRead(
      path(".sysconfig.autoinstall.CLASS_DIR"),
      Ops.add(@Repository, "/classes")
    )
    tmp_dontmerge = Misc.SysconfigRead(
      path(".sysconfig.autoinstall.XSLT_DONTMERGE"),
      "addon,conf"
    )
    tmp_no_writenow = Misc.SysconfigRead(
      path(".sysconfig.autoinstall.FORBID_WRITENOW"),
      "add-on,suse_register,partitioning,bootloader,general,report"
    )

    @dontmerge = Builtins.splitstring(tmp_dontmerge, ",")
    @noWriteNow = Builtins.splitstring(tmp_no_writenow, ",")

    # Set the defaults, just in case.
    if @Repository == "" || @Repository == nil
      @Repository = "/var/lib/autoinstall/repository"
    end
  end
  #This probably gets never executed and it only breaks the commandline iface
  #by Mode::test() call which instantiates UI
  # else if (Mode::test () && Mode::normal ())
  # {
  #     local_rules_file = (string)WFM::Args(1);
  # }
  nil
end

- (Object) getProposalList



199
200
201
# File '../../src/modules/AutoinstConfig.rb', line 199

def getProposalList
  deep_copy(@Proposals)
end

- (Object) main



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

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

  Yast.import "Misc"
  Yast.import "Mode"
  Yast.import "Installation"
  Yast.import "URL"
  Yast.import "SLP"
  Yast.import "Stage"

  Yast.include self, "autoinstall/xml.rb"



  @runModule = ""

  # Profile Repository
  @Repository = ""

  @ProfileEncrypted = false
  @ProfilePassword = ""

  # Package Repository
  @PackageRepository = ""

  # Classes
  @classDir = ""

  # Current file name
  @currentFile = ""

  #
  # Temporary directory for storing profile before installation starts
  #
  @tmpDir = Convert.to_string(SCR.Read(path(".target.tmpdir")))

  #
  # Main directory for data generated during installation
  #
  @var_dir = "/var/adm/autoinstall"

  #
  # Directory for the pre/post and chroot scripts
  #
  @scripts_dir = Ops.add(@var_dir, "/scripts")
  @initscripts_dir = Ops.add(@var_dir, "/init.d")

  #
  # Directory where log files of pre/post and chroot scripts are kept
  #
  @logs_dir = Ops.add(@var_dir, "/logs")

  #
  # Destination dir
  #
  @destdir = Installation.destdir


  #
  # Cache directory
  #
  @cache = Ops.add(@var_dir, "/cache")

  #
  # Temporary file name for retrieved system profile
  #
  @xml_tmpfile = Ops.add(@tmpDir, "/autoinst.xml")

  #
  # Final location for retrieved system profile
  #
  @xml_file = Ops.add(@cache, "/installedSystem.xml")


  #
  # Direcotry for runtime operation data
  #
  @runtime_dir = "/var/lib/autoinstall"

  #
  # Directory where complete configuration files are kept.
  #
  @files_dir = Ops.add(@var_dir, "/files")

  #
  # Directory to store profile for possible user manipulation.
  #
  @profile_dir = "/tmp/profile"

  #
  # The user  modified version of the Profile
  #
  @modified_profile = Ops.add(@profile_dir, "/modified.xml")


  @autoconf_file = Ops.add(@runtime_dir, "/autoconf/autoconf.xml")

  #
  # Parsed data from XML control in YCP format
  #
  @parsedControlFile = Ops.add(@cache, "/autoinst.ycp")


  @remote_rules_location = "rules/rules.xml"
  @local_rules_location = Ops.add(@tmpDir, "/rules")
  @local_rules_file = Ops.add(@local_rules_location, "/rules.xml")

  # Data from command line
  @urltok = {}

  @scheme = ""
  @host = ""
  @filepath = ""
  @directory = ""
  @port = ""
  @user = ""
  @pass = ""


  #
  # Default systemd target
  #
  @default_target = Target::GRAPHICAL


  #
  # Confirm installation
  #
  @Confirm = true


  @OriginalURI = ""

  @message = ""

  # Class merging.
  # lists not to be merged, instead they will be "added"
  #
  @dontmerge = []

  # the "writo setting now" button is disabled for there modules
  #
  #
  @noWriteNow = []

  #
  # Halt after initial phase
  #
  @Halt = false

  #
  # Dont Hard Reboot
  #
  @ForceBoot = false

  #
  # Show Reboot Message
  #
  @RebootMsg = false

  #
  # AutoYaST profile is stored in the root partition (for upgrade)
  #
  @ProfileInRootPart = false


  #
  # remote profile (invented for pre-probing of s390)
  # in case of a remote profile, the profile can be fetched
  # before the probing stage DASD module can has run
  #
  @remoteProfile = true
  @Proposals = []

  Yast.include self, "autoinstall/io.rb"
  AutoinstConfig()
end

- (Object) MainHelp



444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
# File '../../src/modules/AutoinstConfig.rb', line 444

def MainHelp
  main_help = _(
    "<h3>AutoYaST Configuration Management System</h3>\n" +
      "<p>Almost all resources of the control file can be\n" +
      "configured using the configuration management system.</p>\n"
  ) +
    _(
      "<p>Most of the modules used to create the configuration are identical to those available\n" +
        "through the YaST Control Center. Instead of configuring this system, the data\n" +
        "entered is collected and exported to the control file that can be used to\n" +
        "install another system using AutoYaST.\n" +
        "</p>\n"
    ) +
    _(
      "<p>In addition to the existing and familiar modules,\n" +
        "new interfaces were created for special and complex configurations, including\n" +
        "partitioning, general options, and software.</p>\n"
    )
  main_help
end

- (Hash) ParseCmdLine(autoinstall)

Return location of profile from command line.

Examples:

Returns:

  • (Hash)

    with protocol, server, path



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

def ParseCmdLine(autoinstall)
  Yast.import "URL"

  result = {}
  cmdLine = ""

  if Ops.greater_than(Builtins.size(autoinstall), 0)
    cmdLine = autoinstall
    if cmdLine == "default"
      Ops.set(result, "scheme", "file")
      Ops.set(result, "path", "/autoinst.xml")
    else
      if cmdLine == "slp"
        slpData = SLP.FindSrvs("autoyast", "")
        if Ops.greater_than(Builtins.size(slpData), 1)
          dummy = []
          comment2url = {}
          Builtins.foreach(slpData) do |m|
            attrList = SLP.FindAttrs(Ops.get_string(m, "srvurl", ""))
            if Ops.greater_than(Builtins.size(attrList), 0)
              url = Builtins.substring(Ops.get_string(m, "srvurl", ""), 17)
              # FIXME: that's really lazy coding here but I allow only one attribute currently anyway
              #        so it's lazy but okay. No reason to be too strict here with the checks
              #        As soon as more than one attr is possible, I need to iterate over the attr list
              #
              comment = Ops.get(attrList, 0, "")
              # The line above needs to be fixed when we have more attributes

              # comment will look like this: "(description=BLA BLA)"
              startComment = Builtins.findfirstof(comment, "=")
              endComment = Builtins.findlastof(comment, ")")
              if startComment != nil && endComment != nil &&
                  Ops.greater_than(
                    Ops.subtract(Ops.subtract(endComment, startComment), 1),
                    0
                  )
                comment = Builtins.substring(
                  comment,
                  Ops.add(startComment, 1),
                  Ops.subtract(Ops.subtract(endComment, startComment), 1)
                )
              else
                comment = ""
              end
              if Ops.less_than(Builtins.size(comment), 1)
                comment = Builtins.sformat(
                  "bad description in SLP for %1",
                  url
                )
              end
              dummy = Builtins.add(dummy, Item(comment, false))
              Ops.set(comment2url, comment, url)
            else
              url = Builtins.substring(Ops.get_string(m, "srvurl", ""), 17)
              dummy = Builtins.add(dummy, Item(url, false))
              Ops.set(comment2url, url, url)
            end
          end
          dlg = Left(ComboBox(Id(:choose), _("Choose Profile"), dummy))
          UI.OpenDialog(VBox(dlg, PushButton(Id(:ok), "Ok")))
          UI.UserInput
          cmdLine = Ops.get(
            comment2url,
            Convert.to_string(UI.QueryWidget(Id(:choose), :Value)),
            ""
          )
          UI.CloseDialog
        elsif Builtins.size(slpData) == 1
          cmdLine = Builtins.substring(
            Ops.get_string(slpData, [0, "srvurl"], ""),
            17
          )
        else
          cmdLine = "slp query for 'autoyast' failed"
        end
      end
      result = URL.Parse(cmdLine)
      @OriginalURI = cmdLine
    end
  end


  if Ops.get_string(result, "scheme", "") == ""
    # Autoinstall mode was not activated from command line.
    # There must be a floppy with an 'autoinst.xml' in order
    # to be able to reach this point, so we set floppy with
    # autoinst.xml as the control file.

    result = Builtins.add(result, "scheme", "floppy")
    result = Builtins.add(result, "path", "/autoinst.xml")
  end
  @urltok = deep_copy(result)

  @scheme = Ops.get_string(@urltok, "scheme", "default")
  @host = Ops.get_string(@urltok, "host", "")
  @filepath = Ops.get_string(@urltok, "path", "")
  @port = Ops.get_string(@urltok, "port", "")
  @user = Ops.get_string(@urltok, "user", "")
  @pass = Ops.get_string(@urltok, "pass", "")

  if @scheme == "default" || @scheme == "file" || @scheme == "floppy"
    @remoteProfile = false
  end
  Builtins.y2milestone("urltok = %1", @urltok)
  true
end

- (void) Save

This method returns an undefined value.

Save Configuration global settings



373
374
375
376
377
378
379
380
381
# File '../../src/modules/AutoinstConfig.rb', line 373

def Save
  # Write sysconfig variables.
  Builtins.y2milestone("Saving configuration data")

  SCR.Write(path(".sysconfig.autoinstall.REPOSITORY"), @Repository)
  SCR.Write(path(".sysconfig.autoinstall.CLASS_DIR"), @classDir)

  nil
end

- (Object) setProposalList(l)



202
203
204
205
206
207
# File '../../src/modules/AutoinstConfig.rb', line 202

def setProposalList(l)
  l = deep_copy(l)
  @Proposals = deep_copy(l)

  nil
end

- (void) SetProtocolMessage

This method returns an undefined value.

SetProtocolMessage ()



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

def SetProtocolMessage
  if @scheme == "floppy"
    @message = _("Retrieving control file from floppy.")
  elsif @scheme == "tftp"
    @message = Builtins.sformat(
      _("Retrieving control file (%1) from TFTP server: %2."),
      @filepath,
      @host
    )
  elsif @scheme == "nfs"
    @message = Builtins.sformat(
      _("Retrieving control file (%1) from NFS server: %2."),
      @filepath,
      @host
    )
  elsif @scheme == "http"
    @message = Builtins.sformat(
      _("Retrieving control file (%1) from HTTP server: %2."),
      @filepath,
      @host
    )
  elsif @scheme == "ftp"
    @message = Builtins.sformat(
      _("Retrieving control file (%1) from FTP server: %2."),
      @filepath,
      @host
    )
  elsif @scheme == "file"
    @message = Builtins.sformat(
      _("Copying control file from file: %1."),
      @filepath
    )
  elsif @scheme == "device"
    @message = Builtins.sformat(
      _("Copying control file from device: /dev/%1."),
      @filepath
    )
  elsif @scheme == "default"
    @message = _("Copying control file from default location.")
  else
    @message = _("Source unknown.")
  end
  nil
end

- (Object) ShellEscape(s)

escape a string so it can be passed to a shell

Returns:

  • escaped string string



385
386
387
388
389
390
391
392
393
394
395
396
# File '../../src/modules/AutoinstConfig.rb', line 385

def ShellEscape(s)
  i = 0
  res = ""

  while Ops.less_than(i, Builtins.size(s))
    c = Builtins.substring(s, i, 1)
    c = Ops.add("\\", c) if c == "\"" || c == "$" || c == "\\" || c == "`"
    res = Ops.add(res, c)
    i = Ops.add(i, 1)
  end
  res
end