Class: Yast::ProfileClass

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

Instance Method Summary (collapse)

Instance Method Details

- (Object) checkProfile



808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
# File '../../src/modules/Profile.rb', line 808

def checkProfile
  file = Ops.add(Ops.add(AutoinstConfig.tmpDir, "/"), "valid.xml")
  Save(file)
  summary = "Some schema check failed!\n" +
    "Please attach your logfile to bug id 211014\n" +
    "\n"
  valid = true

  validators = [
    [
      _("Checking XML with RNG validation..."),
      Ops.add(
        Ops.add("/usr/bin/xmllint --noout --relaxng ", Directory.schemadir),
        "/autoyast/rng/profile.rng"
      ),
      ""
    ]
  ]
  if !Stage.cont && PackageSystem.Installed("jing")
    validators = Builtins.add(
      validators,
      [
        _("Checking XML with RNC validation..."),
        Ops.add(
          Ops.add("/usr/bin/jing >&2 -c ", Directory.schemadir),
          "/autoyast/rnc/profile.rnc"
        ),
        "jing_sucks"
      ]
    )
  end

  Builtins.foreach(validators) do |i|
    header = Ops.get_string(i, 0, "")
    cmd = Ops.add(Ops.add(Ops.get_string(i, 1, ""), " "), file)
    summary = Ops.add(Ops.add(summary, header), "\n")
    o = Convert.to_map(SCR.Execute(path(".target.bash_output"), cmd))
    Builtins.y2debug("validation output: %1", o)
    summary = Ops.add(Ops.add(summary, cmd), "\n")
    summary = Ops.add(
      Ops.add(summary, Ops.get_string(o, "stderr", "")),
      "\n"
    )
    summary = Ops.add(summary, "\n")
    if Ops.get_integer(o, "exit", 1) != 0 ||
        Ops.get_string(i, 2, "") == "jing_sucks" &&
          Ops.greater_than(
            Builtins.size(Ops.get_string(o, "stderr", "")),
            0
          )
      valid = false
    end
  end
  if !valid
    Popup.Error(summary)
    Builtins.y2milestone(
      "Profile check failed please attach the log to bug id 211014: %1",
      summary
    )
  end

  nil
end

- (Hash) Compat(__current)

General compatibility issues

Parameters:

  • current

    profile

Returns:

  • (Hash)

    converted profile



575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
# File '../../src/modules/Profile.rb', line 575

def Compat(__current)
  __current = deep_copy(__current)
  # scripts
  if Builtins.haskey(__current, "pre-scripts") ||
      Builtins.haskey(__current, "post-scripts") ||
      Builtins.haskey(__current, "chroot-scripts")
    pre = Ops.get_list(__current, "pre-scripts", [])
    post = Ops.get_list(__current, "post-scripts", [])
    chroot = Ops.get_list(__current, "chroot-scripts", [])
    scripts = {
      "pre-scripts"    => pre,
      "post-scripts"   => post,
      "chroot-scripts" => chroot
    }
    __current = Builtins.remove(__current, "pre-scripts")
    __current = Builtins.remove(__current, "post-scripts")
    __current = Builtins.remove(__current, "chroot-scripts")

    Ops.set(__current, "scripts", scripts)
  end

  # general
  old = false


  general_options = Ops.get_map(__current, "general", {})
  security = Ops.get_map(__current, "security", {})
  report = Ops.get_map(__current, "report", {})

  Builtins.foreach(general_options) do |k, v|
    if k == "keyboard" && Ops.is_string?(v)
      old = true
    elsif k == "encryption_method"
      old = true
    elsif k == "timezone" && Ops.is_string?(v)
      old = true
    end
  end

  new_general = {}

  if old
    Builtins.y2milestone("Old format, converting.....")
    Ops.set(
      new_general,
      "language",
      Ops.get_string(general_options, "language", "")
    )
    keyboard = {}
    Ops.set(
      keyboard,
      "keymap",
      Ops.get_string(general_options, "keyboard", "")
    )
    Ops.set(new_general, "keyboard", keyboard)

    clock = {}
    Ops.set(
      clock,
      "timezone",
      Ops.get_string(general_options, "timezone", "")
    )
    if Ops.get_string(general_options, "hwclock", "") == "localtime"
      Ops.set(clock, "hwclock", "localtime")
    elsif Ops.get_string(general_options, "hwclock", "") == "GMT"
      Ops.set(clock, "hwclock", "GMT")
    end
    Ops.set(new_general, "clock", clock)

    mode = {}
    if Builtins.haskey(general_options, "reboot")
      Ops.set(
        mode,
        "reboot",
        Ops.get_boolean(general_options, "reboot", false)
      )
    end
    if Builtins.haskey(report, "confirm")
      Ops.set(mode, "confirm", Ops.get_boolean(report, "confirm", false))
      report = Builtins.remove(report, "confirm")
    end
    Ops.set(new_general, "mode", mode)


    if Builtins.haskey(general_options, "encryption_method")
      Ops.set(
        security,
        "encryption",
        Ops.get_string(general_options, "encryption_method", "")
      )
    end

    net = Ops.get_map(__current, "networking", {})
    ifaces = Ops.get_list(net, "interfaces", [])

    newifaces = Builtins.maplist(ifaces) do |iface|
      newiface = Builtins.mapmap(iface) do |k, v|
        { Builtins.tolower(k) => v }
      end
      deep_copy(newiface)
    end

    Ops.set(net, "interfaces", newifaces)

    Ops.set(__current, "general", new_general)
    Ops.set(__current, "report", report)
    Ops.set(__current, "security", security)
    Ops.set(__current, "networking", net)
  end

  deep_copy(__current)
end

- (String) DetectVersion

Detect Version

Returns:

  • (String)


64
65
66
# File '../../src/modules/Profile.rb', line 64

def DetectVersion
  ""
end

- (Object) generalCompat

compatibility to new language,keyboard and timezone client in 10.1



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

def generalCompat
  if Builtins.haskey(@current, "general")
    if Builtins.haskey(Ops.get_map(@current, "general", {}), "keyboard")
      Ops.set(
        @current,
        "keyboard",
        Ops.get_map(@current, ["general", "keyboard"], {})
      )
      Ops.set(
        @current,
        "general",
        Builtins.remove(Ops.get_map(@current, "general", {}), "keyboard")
      )
    end
    if Builtins.haskey(Ops.get_map(@current, "general", {}), "language")
      Ops.set(
        @current,
        "language",
        {
          "language" => Ops.get_string(
            @current,
            ["general", "language"],
            ""
          )
        }
      )
      Ops.set(
        @current,
        "general",
        Builtins.remove(Ops.get_map(@current, "general", {}), "language")
      )
    end
    if Builtins.haskey(Ops.get_map(@current, "general", {}), "clock")
      Ops.set(
        @current,
        "timezone",
        Ops.get_map(@current, ["general", "clock"], {})
      )
      Ops.set(
        @current,
        "general",
        Builtins.remove(Ops.get_map(@current, "general", {}), "clock")
      )
    end
    if Ops.get_boolean(@current, ["general", "mode", "final_halt"], false)
      script = {
        "filename" => "zzz_halt",
        "source"   => "chkconfig autoyast off\nshutdown -h now"
      }
      if !Builtins.haskey(@current, "scripts")
        Ops.set(@current, "scripts", {})
      end
      if !Builtins.haskey(
          Ops.get_map(@current, "scripts", {}),
          "init-scripts"
        )
        Ops.set(@current, ["scripts", "init-scripts"], [])
      end
      Ops.set(
        @current,
        ["scripts", "init-scripts"],
        Builtins.add(
          Ops.get_list(@current, ["scripts", "init-scripts"], []),
          script
        )
      )
    end
    if Ops.get_boolean(@current, ["general", "mode", "final_reboot"], false)
      script = {
        "filename" => "zzz_reboot",
        "source"   => "chkconfig autoyast off\nshutdown -r now"
      }
      if !Builtins.haskey(@current, "scripts")
        Ops.set(@current, "scripts", {})
      end
      if !Builtins.haskey(
          Ops.get_map(@current, "scripts", {}),
          "init-scripts"
        )
        Ops.set(@current, ["scripts", "init-scripts"], [])
      end
      Ops.set(
        @current,
        ["scripts", "init-scripts"],
        Builtins.add(
          Ops.get_list(@current, ["scripts", "init-scripts"], []),
          script
        )
      )
    end
    if Builtins.haskey(
        Ops.get_map(@current, "software", {}),
        "additional_locales"
      )
      if !Builtins.haskey(@current, "language")
        Ops.set(@current, "language", {})
      end
      Ops.set(
        @current,
        ["language", "languages"],
        Builtins.mergestring(
          Ops.get_list(@current, ["software", "additional_locales"], []),
          ","
        )
      )
      Ops.set(
        @current,
        "software",
        Builtins.remove(
          Ops.get_map(@current, "software", {}),
          "additional_locales"
        )
      )
    end
  end

  nil
end

- (void) Import(profile)

This method returns an undefined value.

Import Profile

Parameters:

  • profile (Hash{String => Object})


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

def Import(profile)
  profile = deep_copy(profile)
  Builtins.y2milestone("importing profile")
  @current = deep_copy(profile)

  ReadProperties(Ops.get_map(@current, "properties", {}))

  # old style
  if Builtins.haskey(profile, "configure") ||
      Builtins.haskey(profile, "install")
    __configure = Ops.get_map(profile, "configure", {})
    __install = Ops.get_map(profile, "install", {})
    if Builtins.haskey(profile, "configure")
      @current = Builtins.remove(@current, "configure")
    end
    if Builtins.haskey(profile, "install")
      @current = Builtins.remove(@current, "install")
    end
    tmp = Convert.convert(
      Builtins.union(__configure, __install),
      :from => "map",
      :to   => "map <string, any>"
    )
    @current = Convert.convert(
      Builtins.union(tmp, @current),
      :from => "map",
      :to   => "map <string, any>"
    )
  end

  # should not be needed anymore with new libsax
  #if (!current["x11", "configure_x11"]:false)
  #    ProductControl::DisableModule ("x11");

  # raise the network immediately after configuring it
  if Builtins.haskey(@current, "networking") &&
      !Builtins.haskey(
        Ops.get_map(@current, "networking", {}),
        "start_immediately"
      )
    Ops.set(@current, ["networking", "start_immediately"], true)
    Builtins.y2milestone("start_immediately set to true")
  end
  storageLibCompat # compatibility to new storage library (SL 10.0)
  generalCompat # compatibility to new language,keyboard and timezone (SL10.1)
  softwareCompat

  Builtins.y2debug("Current Profile=%1", @current)
  nil
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
# File '../../src/modules/Profile.rb', line 13

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

  Yast.import "Stage"
  Yast.import "Mode"
  Yast.import "AutoinstConfig"
  Yast.import "XML"
  Yast.import "Label"
  Yast.import "Popup"
  Yast.import "ProductControl"
  Yast.import "Directory"
  Yast.import "FileUtils"
  Yast.import "PackageSystem"

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


  # The Complete current Profile
  @current = {}

  # defined in Y2ModuleConfig
  @ModuleMap = {}


  @Version = ""

  @Description = ""

  @changed = false

  @prepare = true
  Profile()
end

- (void) Prepare

This method returns an undefined value.

Prepare Profile for saving and remove empty data structs



356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
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
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
# File '../../src/modules/Profile.rb', line 356

def Prepare
  return if !@prepare

  Popup.ShowFeedback(
    _("Collecting configuration data..."),
    _("This may take a while")
  )

  e = []

  Builtins.foreach(@ModuleMap) do |p, d|
    #
    # Set resource name, if not using default value
    #
    resource = Ops.get_string(d, "X-SuSE-YaST-AutoInstResource", "")
    resource = p if resource == ""
    tomerge = Ops.get_string(d, "X-SuSE-YaST-AutoInstMerge", "")
    module_auto = Ops.get_string(d, "X-SuSE-YaST-AutoInstClient", "none")
    if Convert.to_boolean(WFM.CallFunction(module_auto, ["GetModified"]))
      resource_data = WFM.CallFunction(module_auto, ["Export"])

      s = 0
      if tomerge == ""
        if Ops.get_string(d, "X-SuSE-YaST-AutoInstDataType", "map") == "map"
          s = Builtins.size(Convert.to_map(resource_data))
        else
          s = Builtins.size(Convert.to_list(resource_data))
        end
      end

      if s != 0 || tomerge != ""
        if Ops.greater_than(Builtins.size(tomerge), 0)
          i = 0
          tomergetypes = Ops.get_string(
            d,
            "X-SuSE-YaST-AutoInstMergeTypes",
            ""
          )
          _MergeTypes = Builtins.splitstring(tomergetypes, ",")

          Builtins.foreach(Builtins.splitstring(tomerge, ",")) do |res|
            if Ops.get_string(_MergeTypes, i, "map") == "map"
              rd = Convert.convert(
                resource_data,
                :from => "any",
                :to   => "map <string, any>"
              )
              Ops.set(@current, res, Ops.get_map(rd, res, {}))
            else
              rd = Convert.convert(
                resource_data,
                :from => "any",
                :to   => "map <string, any>"
              )
              Ops.set(@current, res, Ops.get_list(rd, res, []))
            end
            i = Ops.add(i, 1)
          end
        else
          Ops.set(@current, resource, resource_data)
        end
      elsif s == 0
        e = Builtins.add(e, resource)
      end
    end
  end


  Builtins.foreach(@current) do |k, v|
    if !Builtins.haskey(@current, k) && !Builtins.contains(e, k)
      Ops.set(@current, k, v)
    end
  end

  Popup.ClearFeedback
  @prepare = false
  nil
end

- (void) Profile

This method returns an undefined value.

Constructor



50
51
52
53
54
55
56
57
58
59
# File '../../src/modules/Profile.rb', line 50

def Profile
  #
  # setup profile XML parameters for writing
  #
  profileSetup
  if Stage.initial
    SCR.Execute(path(".target.mkdir"), AutoinstConfig.profile_dir)
  end
  nil
end

- (Boolean) ReadProfileStructure(parsedControlFile)

Read YCP data as the control file

Parameters:

  • ycp

    file

Returns:

  • (Boolean)


556
557
558
559
560
561
562
563
564
565
566
567
568
569
# File '../../src/modules/Profile.rb', line 556

def ReadProfileStructure(parsedControlFile)
  @current = Convert.convert(
    SCR.Read(path(".target.ycp"), [parsedControlFile, {}]),
    :from => "any",
    :to   => "map <string, any>"
  )
  if @current == {}
    return false
  else
    Import(@current)
  end

  true
end

- (void) ReadProperties(properties)

This method returns an undefined value.

Read Profile properties and Version

Parameters:

  • map

    Profile Properties



280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
# File '../../src/modules/Profile.rb', line 280

def ReadProperties(properties)
  properties = deep_copy(properties)
  @Version = Ops.get_string(properties, "version", "")
  @Description = Ops.get_string(properties, "description", "")

  if @Version != "3.0" || @Version == ""
    @Version = DetectVersion()
    if @Version == ""
      Builtins.y2milestone("Can't detect Profile Version")
      return
    end
  else
    Builtins.y2milestone("AutoYaST Profile Version  %1 Detected.", @Version)
  end
  nil
end

- (Boolean) ReadXML(file)

Read XML into YCP data

Parameters:

  • path

    to file

Returns:

  • (Boolean)


692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
# File '../../src/modules/Profile.rb', line 692

def ReadXML(file)
  # does not work here
  #if ( !FileUtils::Exists( file ) )
  #    return false;

  tmp = Convert.to_string(SCR.Read(path(".target.string"), file))
  l = Builtins.splitstring(tmp, "\n")
  if tmp != nil && Ops.get(l, 0, "") == "-----BEGIN PGP MESSAGE-----"
    out = {}
    while Ops.get_string(out, "stdout", "") == ""
      UI.OpenDialog(
        VBox(
          Label(
            _("Encrypted AutoYaST profile. Enter the correct password.")
          ),
          Password(Id(:password), ""),
          PushButton(Id(:ok), Label.OKButton)
        )
      )
      p = ""
      button = nil
      begin
        button = UI.UserInput
        p = Convert.to_string(UI.QueryWidget(Id(:password), :Value))
      end until button == :ok
      UI.CloseDialog
      command = Builtins.sformat(
        "gpg2 -d --batch --passphrase \"%1\" %2",
        p,
        file
      )
      out = Convert.convert(
        SCR.Execute(path(".target.bash_output"), command, {}),
        :from => "any",
        :to   => "map <string, any>"
      )
    end
    @current = XML.XMLToYCPString(Ops.get_string(out, "stdout", ""))
    AutoinstConfig.ProfileEncrypted = true

    # FIXME: rethink and check for sanity of that!
    # save decrypted profile for modifying pre-scripts
    if Stage.initial
      #SCR::Write(.target.string, AutoinstConfig::profile_dir+"/autoinst.xml", out["stdout"]:"");
      SCR.Write(
        path(".target.string"),
        file,
        Ops.get_string(out, "stdout", "")
      )
    end
  else
    Builtins.y2debug("Reading %1", file)
    @current = XML.XMLToYCPFile(file)
  end

  if @current != {} && Builtins.size(@current) == 0
    # autoyast has read the autoyast configuration file but something went wrong
    message = _(
      "The XML parser reported an error while parsing the autoyast profile. The error message is:\n"
    )
    message = Ops.add(message, XML.XMLError)
    Popup.Error(message)
    return false
  end
  Import(@current)
  true
end

- (void) Reset

This method returns an undefined value.

Reset profile to initial status



437
438
439
440
441
# File '../../src/modules/Profile.rb', line 437

def Reset
  Builtins.y2milestone("Resetting profile contents")
  @current = {}
  nil
end

- (Boolean) Save(file)

Save YCP data into XML

Parameters:

  • path

    to file

Returns:

  • (Boolean)

    true on success



446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
# File '../../src/modules/Profile.rb', line 446

def Save(file)
  Prepare()
  ret = false
  Builtins.y2debug("Saving data (%1) to XML file %2", @current, file)
  if AutoinstConfig.ProfileEncrypted
    xml = XML.YCPToXMLString(:profile, @current)
    if Ops.greater_than(Builtins.size(xml), 0)
      if AutoinstConfig.ProfilePassword == ""
        p = ""
        q = ""
        begin
          UI.OpenDialog(
            VBox(
              Label(
                _("Encrypted AutoYaST profile. Enter the password twice.")
              ),
              Password(Id(:password), ""),
              Password(Id(:password2), ""),
              PushButton(Id(:ok), Label.OKButton)
            )
          )
          button = nil
          begin
            button = UI.UserInput
            p = Convert.to_string(UI.QueryWidget(Id(:password), :Value))
            q = Convert.to_string(UI.QueryWidget(Id(:password2), :Value))
          end until button == :ok
          UI.CloseDialog
        end while p != q
        AutoinstConfig.ProfilePassword = AutoinstConfig.ShellEscape(p)
      end
      dir = Convert.to_string(SCR.Read(path(".target.tmpdir")))
      command = Builtins.sformat(
        "gpg2 -c --armor --batch --passphrase \"%1\" --output %2/encrypted_autoyast.xml",
        AutoinstConfig.ProfilePassword,
        dir
      )
      SCR.Execute(path(".target.bash_input"), command, xml)
      if Ops.greater_than(
          SCR.Read(
            path(".target.size"),
            Ops.add(dir, "/encrypted_autoyast.xml")
          ),
          0
        )
        command = Builtins.sformat(
          "mv %1/encrypted_autoyast.xml %2",
          dir,
          file
        )
        SCR.Execute(path(".target.bash"), command, {})
        ret = true
      end
    end
  else
    ret = XML.YCPToXMLFile(:profile, @current, file)
  end
  ret
end

- (Object) SaveProfileStructure(parsedControlFile)

Save the current data into a file to be read after a reboot.

Parameters:

  • -

Returns:

  • true on success

See Also:

  • #Restore()


548
549
550
551
# File '../../src/modules/Profile.rb', line 548

def SaveProfileStructure(parsedControlFile)
  Builtins.y2milestone("Saving control file in YCP format")
  SCR.Write(path(".target.ycp"), parsedControlFile, @current)
end

- (Object) SaveSingleSections(dir)

Save sections of current profile to separate files

Parameters:

  • dir (String)
    • directory to store section xml files in

Returns:

    • list of filenames



510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
# File '../../src/modules/Profile.rb', line 510

def SaveSingleSections(dir)
  Prepare()
  Builtins.y2milestone("Saving data (%1) to XML single files", @current)
  sectionFiles = {}
  Builtins.foreach(@current) do |sectionName, section|
    sectionFileName = Ops.add(
      Ops.add(Ops.add(dir, "/"), sectionName),
      ".xml"
    )
    tmpProfile = { sectionName => section }
    if XML.YCPToXMLFile(:profile, tmpProfile, sectionFileName)
      Builtins.y2milestone(
        "Wrote section %1 to file %2",
        sectionName,
        sectionFileName
      )
      sectionFiles = Builtins.add(
        sectionFiles,
        sectionName,
        sectionFileName
      )
    else
      Builtins.y2error(
        Builtins.sformat(
          _("Could not write section %1 to file %2."),
          sectionName,
          sectionFileName
        )
      )
    end
  end
  deep_copy(sectionFiles)
end

- (Object) setElementByList(l, v, m)

this function is a replacement for this code: list<any> l = [ "key1",0,"key3" ]; m[ l ] = v; @return [Hash]



800
801
802
803
804
805
806
# File '../../src/modules/Profile.rb', line 800

def setElementByList(l, v, m)
  l = deep_copy(l)
  v = deep_copy(v)
  m = deep_copy(m)
  m = setMValue(l, v, m)
  deep_copy(m)
end

- (Object) setLValue(l, v, m)



777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
# File '../../src/modules/Profile.rb', line 777

def setLValue(l, v, m)
  l = deep_copy(l)
  v = deep_copy(v)
  m = deep_copy(m)
  i = Ops.get_integer(l, 0, 0)
  tmp = Builtins.remove(l, 0)
  if Ops.greater_than(Builtins.size(tmp), 0)
    if Ops.is_string?(Ops.get(tmp, 0))
      Ops.set(m, i, setMValue(tmp, v, Ops.get_map(m, i, {})))
    else
      Ops.set(m, i, setLValue(tmp, v, Ops.get_list(m, i, [])))
    end
  else
    Builtins.y2debug("setting %1 to %2", i, v)
    Ops.set(m, i, v)
  end
  deep_copy(m)
end

- (Object) setMValue(l, v, m)



759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
# File '../../src/modules/Profile.rb', line 759

def setMValue(l, v, m)
  l = deep_copy(l)
  v = deep_copy(v)
  m = deep_copy(m)
  i = Ops.get_string(l, 0, "")
  tmp = Builtins.remove(l, 0)
  if Ops.greater_than(Builtins.size(tmp), 0)
    if Ops.is_string?(Ops.get(tmp, 0))
      Ops.set(m, i, setMValue(tmp, v, Ops.get_map(m, i, {})))
    else
      Ops.set(m, i, setLValue(tmp, v, Ops.get_list(m, i, [])))
    end
  else
    Builtins.y2debug("setting %1 to %2", i, v)
    Ops.set(m, i, v)
  end
  deep_copy(m)
end

- (Object) softwareCompat



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

def softwareCompat
  Ops.set(@current, "software", Ops.get_map(@current, "software", {}))
  if !Builtins.contains(
      Ops.get_list(@current, ["software", "packages"], []),
      "autoyast2-installation"
    )
    Ops.set(
      @current,
      ["software", "packages"],
      Builtins.add(
        Ops.get_list(@current, ["software", "packages"], []),
        "autoyast2-installation"
      )
    )
  end

  # without autoyast2, <files ...> does not work
  if Builtins.haskey(@current, "files") &&
      !Builtins.contains(
        Ops.get_list(@current, ["software", "packages"], []),
        "autoyast2"
      )
    Ops.set(
      @current,
      ["software", "packages"],
      Builtins.add(
        Ops.get_list(@current, ["software", "packages"], []),
        "autoyast2"
      )
    )
  end

  # workaround for missing "REQUIRES" in content file to stay backward compatible
  # FIXME: needs a more sophisticated or compatibility breaking solution after SLES11
  if Builtins.size(Ops.get_list(@current, ["software", "patterns"], [])) == 0
    Ops.set(@current, ["software", "patterns"], ["base"])
  end

  nil
end

- (Object) storageLibCompat

compatibility to new storage lib in 10.0



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

def storageLibCompat
  newPart = []
  Builtins.foreach(Ops.get_list(@current, "partitioning", [])) do |d|
    if Builtins.haskey(d, "is_lvm_vg") &&
        Ops.get_boolean(d, "is_lvm_vg", false) == true
      d = Builtins.remove(d, "is_lvm_vg")
      Ops.set(d, "type", :CT_LVM)
    elsif Builtins.haskey(d, "device") &&
        Ops.get_string(d, "device", "") == "/dev/md"
      Ops.set(d, "type", :CT_MD)
    elsif !Builtins.haskey(d, "type")
      Ops.set(d, "type", :CT_DISK)
    end
    # actually, this is not a compatibility hook for the new
    # storage lib. It's a hook to be compatibel with the autoyast
    # documentation for reusing partitions
    #
    Ops.set(
      d,
      "partitions",
      Builtins.maplist(Ops.get_list(d, "partitions", [])) do |p|
        if Builtins.haskey(p, "create") &&
            Ops.get_boolean(p, "create", true) == false &&
            Builtins.haskey(p, "partition_nr")
          Ops.set(p, "usepart", Ops.get_integer(p, "partition_nr", 0)) # useless default
        end
        if Builtins.haskey(p, "partition_id")
          # that's a bit strange. There is a naming mixup between
          # autoyast and the storage part of yast. Actually filesystem_id
          # does not make sense at all but in autoyast it is the
          # partition id (maybe that's because yast calls
          # the partition id "fsid" internally).
          # partition_id in the profile does not work at all, so we copy
          # that value to filesystem_id
          Ops.set(p, "filesystem_id", Ops.get_integer(p, "partition_id", 0))
        end
        deep_copy(p)
      end
    )
    newPart = Builtins.add(newPart, d)
  end
  Builtins.y2milestone("partitioning is now %1", newPart)
  Ops.set(@current, "partitioning", newPart)

  nil
end