Class: Yast::BootPOWERLILOClass

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

Instance Method Summary (collapse)

Instance Method Details

- (Object) BootPOWERLILO

Constructor



1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
# File '../../src/modules/BootPOWERLILO.rb', line 1287

def BootPOWERLILO
  Ops.set(
    BootCommon.bootloader_attribs,
    "ppc",
    {
      "required_packages" => ["lilo"],
      "loader_name"       => "ppc",
      "initializer"       => fun_ref(method(:Initializer), "void ()")
    }
  )

  nil
end

- (Object) choosePrepBootPartition

Select PReP boot partition to propose Changes internal variables.



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

def choosePrepBootPartition
  Builtins.y2milestone("Resetting selected PReP boot partition")
  root_disks = []
  if Storage.CheckForLvmRootFs
    tm = Storage.GetTargetMap
    vg = ""
    Builtins.foreach(tm) do |dev, info|
      if Ops.get_symbol(info, "type", :CT_UNKNOWN) == :CT_LVM
        volumes = Ops.get_list(info, "partitions", [])
        Builtins.foreach(volumes) do |v|
          if Ops.get_string(v, "mount", "") == "/"
            vg = Ops.get_string(info, "name", "")
            Builtins.y2milestone("Volume group of root FS: %1", vg)
          end
        end
      end
    end
    Builtins.foreach(tm) do |dev, info|
      partitions = Ops.get_list(info, "partitions", [])
      Builtins.foreach(partitions) do |p|
        if Ops.get_string(p, "used_by_device", "") == Ops.add("/dev/", vg)
          root_disks = Builtins.add(root_disks, dev)
        end
      end
    end
    Builtins.y2milestone("Disks holding LVM with root fs: %1", root_disks)
  else
    root_disks = [
      Ops.get_string(
        Storage.GetDiskPartition(BootStorage.RootPartitionDevice),
        "disk",
        ""
      )
    ]
  end

  @prep_boot_partition = ""
  # First take the partitions that Storage:: hinted us to take, then
  # consider the other prep_boot_partitions
  @prep_boot_partitions = Convert.convert(
    Builtins.merge(@install_prep_boot_partitions, @prep_boot_partitions),
    :from => "list",
    :to   => "list <string>"
  )
  # in the combined list, look for "usable" partitions:
  #	- if we require the boot partition to be on the same disk as
  #	  the root partition ("prep_same_disk_as_root"), select the
  #	  first prep partition from that disk
  #	- otherwise take the first prep partition in the list
  Builtins.foreach(@prep_boot_partitions) do |partition|
    if @prep_boot_partition == ""
      usable = true
      if @prep_same_disk_as_root
        part_split = Storage.GetDiskPartition(partition)
        part_disk = Ops.get_string(part_split, "disk", "")
        usable = false if !Builtins.contains(root_disks, part_disk)
      end
      @prep_boot_partition = partition if usable
    end
  end

  # For CHRP lilo can handle PReP partition on other disks now
  # If all above fails, take the first one then ...
  if @prep_boot_partition == "" && getBoardType == "chrp"
    @prep_boot_partition = Ops.get(@prep_boot_partitions, 0, "")
  end

  Builtins.y2milestone(
    "Selected PReP boot partition: %1",
    @prep_boot_partition
  )
  BootCommon.activate = @prep_boot_partition != ""
  Builtins.y2milestone("Install bootloader: %1", BootCommon.activate)

  nil
end

- (Object) CHRPInit

Initialize attributes of the board type



276
277
278
279
280
281
282
283
284
285
286
287
288
# File '../../src/modules/BootPOWERLILO.rb', line 276

def CHRPInit
  Builtins.y2milestone("Initializing CHRP attributes")
  @prep_only_active = true
  @prep_only_iseries_vd = false
  @prep_only_primary = true
  # On CHRP, if there is no bootable partition on the disk containing
  # "/", there is CHRP-specific code in choosePrepBootPartition that
  # takes the first prep partition in the system.
  @prep_same_disk_as_root = true
  @table_items = ["__chrp_location", "__set_default_of"]

  nil
end

- (Object) CreateGlobals

Propose global options of bootloader modifies internal structures



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

def CreateGlobals
  BootCommon.globals = {
    "activate" => "true",
    "default"  => Ops.get_string(BootCommon.sections, [0, "name"], ""),
    "timeout"  => "8"
  }

  boot_map = {}

  Builtins.y2milestone(
    "RootPartDevice is %1",
    BootStorage.RootPartitionDevice
  )
  case getBoardType
    when "chrp"
      boot_map = { "boot_chrp_custom" => BootStorage.BootPartitionDevice }
    when "prep"
      boot_map = { "boot_prep_custom" => BootStorage.BootPartitionDevice }
    when "pmac"
      boot_map = { "boot_pmac_custom" => BootStorage.BootPartitionDevice }
    when "iseries"
      boot_map = {
        "boot_slot" => "B",
        # FIXME: what file should be used here?
        "boot_file" => "/tmp/suse_linux_image"
      }

      # If we have an empty BootPartitionDevice on iseries, this means:
      # do not boot from BootPartitionDevice but from some other place.
      # Do not pass down to perl-Bootloader, lilo fails on an empty "boot =" line.
      if BootStorage.BootPartitionDevice != nil &&
          BootStorage.BootPartitionDevice != ""
        Ops.set(
          boot_map,
          "boot_iseries_custom",
          BootStorage.BootPartitionDevice
        )
      end
    else
      Builtins.y2error("Unknown ppc architecture")
  end

  # Finally merge results into "globals": new values replace old ones
  BootCommon.globals = Convert.convert(
    Builtins.union(BootCommon.globals, boot_map),
    :from => "map",
    :to   => "map <string, string>"
  )

  nil
end

- (Hash) CreateImageSection(title)

Create section for bootable image

Parameters:

  • title (String)

    string the section name to create (untranslated)

Returns:

  • (Hash)

    describes the section



443
444
445
446
447
448
449
450
451
452
# File '../../src/modules/BootPOWERLILO.rb', line 443

def CreateImageSection(title)
  ret = BootCommon.CreateLinuxSection(title)
  #Do not use translated names, as we are happy if it work with kernel device
  Ops.set(ret, "root", BootStorage.RootPartitionDevice)
  # bnc #217443
  Ops.set(ret, "optional", "true")
  #do not use translated name FIXME this should be filtered out
  Ops.set(ret, "name", title)
  deep_copy(ret)
end

- (Object) CreateSections

Propose sections to bootloader menu modifies internal sreuctures



612
613
614
615
616
617
618
619
620
# File '../../src/modules/BootPOWERLILO.rb', line 612

def CreateSections
  linux = CreateImageSection("linux")

  # FIXME: create an 'other' section for MACs to boot MacOS

  BootCommon.sections = [linux]

  nil
end

- (Object) currentBoardInit

Initialize the attribute of currently used board type



426
427
428
429
430
431
432
433
434
435
436
437
# File '../../src/modules/BootPOWERLILO.rb', line 426

def currentBoardInit
  if getBoardType == "iseries"
    iSeriesInit
  elsif getBoardType == "prep"
    PRePInit()
  elsif getBoardType == "chrp"
    CHRPInit()
  end 
  # TODO other boards

  nil
end

- (Object) Dialogs



1208
1209
1210
1211
# File '../../src/modules/BootPOWERLILO.rb', line 1208

def Dialogs
  # PPC definitly needs other text modules
  { "loader" => fun_ref(method(:PPCDetailsDialog), "symbol ()") }
end

- (Object) Export

Export bootloader settings to a map

Returns:

  • bootloader settings



844
845
846
847
848
849
850
851
# File '../../src/modules/BootPOWERLILO.rb', line 844

def Export
  exp = {
    "global"   => BootCommon.remapGlobals(BootCommon.globals),
    "sections" => BootCommon.remapSections(BootCommon.sections),
    "activate" => BootCommon.activate
  }
  deep_copy(exp)
end

- (Boolean) FlagOnetimeBoot(section)

Set section to boot on next reboot

Parameters:

  • section (String)

    string section to boot

Returns:

  • (Boolean)

    true on success



1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
# File '../../src/modules/BootPOWERLILO.rb', line 1216

def FlagOnetimeBoot(section)
  result = Convert.to_map(
    SCR.Execute(
      path(".target.bash_output"),
      Builtins.sformat("/sbin/lilo -R \"%1\"", section)
    )
  )
  Builtins.y2milestone("lilo returned %1", result)
  Ops.get_integer(result, "exit", -1) == 0
end

- (Object) getBoardType



420
421
422
423
# File '../../src/modules/BootPOWERLILO.rb', line 420

def getBoardType
  initBoardType if @board_type == nil
  @board_type
end

- (Hash) GetFunctions

Return map of provided functions

Returns:

  • (Hash)

    map of functions (eg. $[“write”:BootPOWERLILO::Write])



1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
# File '../../src/modules/BootPOWERLILO.rb', line 1235

def GetFunctions
  {
    "export"          => fun_ref(method(:Export), "map ()"),
    "import"          => fun_ref(method(:Import), "boolean (map)"),
    "read"            => fun_ref(
      method(:Read),
      "boolean (boolean, boolean)"
    ),
    "reset"           => fun_ref(method(:Reset), "void (boolean)"),
    "propose"         => fun_ref(method(:Propose), "void ()"),
    "save"            => fun_ref(
      method(:Save),
      "boolean (boolean, boolean, boolean)"
    ),
    "summary"         => fun_ref(method(:Summary), "list <string> ()"),
    "update"          => fun_ref(method(:Update), "void ()"),
    "write"           => fun_ref(method(:Write), "boolean ()"),
    "widgets"         => fun_ref(
      method(:ppcWidgets),
      "map <string, map <string, any>> ()"
    ),
    "dialogs"         => fun_ref(
      method(:Dialogs),
      "map <string, symbol ()> ()"
    ),
    "section_types"   => fun_ref(
      method(:ppc_section_types),
      "list <string> ()"
    ),
    "flagonetimeboot" => fun_ref(
      method(:FlagOnetimeBoot),
      "boolean (string)"
    )
  }
end

- (String) GoodPmacBootPartition

Choose a boot partition on pmac type == Apple_HFS|Apple_Bootstrap && size < 20 cyl

Returns:

  • (String)

    device name of pmac boot partition



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
505
506
507
508
509
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
543
544
545
546
547
548
549
550
551
552
553
554
# File '../../src/modules/BootPOWERLILO.rb', line 457

def GoodPmacBootPartition
  Builtins.y2milestone("Detecting pmac boot partition")
  targetMap = Storage.GetTargetMap
  Builtins.y2milestone("TargetMap: %1", targetMap)

  boot_partitions = []
  selected_boot_partition = ""

  Builtins.foreach(targetMap) do |dname, ddata|
    partitions = Ops.get_list(ddata, "partitions", [])
    Builtins.y2milestone("Partitions: %1", partitions)
    # does this device contain the root partition?
    hasrootdev = Builtins.find(partitions) do |p|
      !Ops.get_boolean(p, "delete", false) &&
        Ops.get_string(p, "device", "") == BootStorage.RootPartitionDevice &&
        !Builtins.contains(
          [:lvm, :evms, :sw_raid],
          Ops.get_symbol(p, "type", :primary)
        )
    end != nil
    # find possible boot partitions
    partitions = Builtins.filter(partitions) do |p|
      !Ops.get_boolean(p, "delete", false) &&
        Ops.is_integer?(Ops.get(p, "fsid")) &&
        # both partition types Apple_Bootstrap and Apple_HFS can be
        # handled by PPC lilo; yast2-storage maps both to fsid 258
        Ops.get(p, "fsid") == 258 &&
        !Builtins.contains(
          [:lvm, :evms, :sw_raid],
          Ops.get_symbol(p, "type", :primary)
        )
    end
    Builtins.y2milestone("Filtered existing partitions: %1", partitions)
    # bug #459860 - no boot partition found during fresh install
    # find the smallest partition
    max_size = 1000000000
    iter = -1
    min_position = -1
    Builtins.foreach(partitions) do |p|
      iter = Ops.add(iter, 1)
      if Ops.less_than(Ops.get_integer(p, "size_k", 0), max_size)
        min_position = iter
        max_size = Ops.get_integer(p, "size_k", 0)
      end
    end
    # if any partition was found
    if Ops.greater_than(min_position, -1)
      tmp_partitions = []
      partition = Ops.get(partitions, min_position, {})
      if Ops.less_than(Ops.get_integer(partition, "size_k", 0), 160650)
        Builtins.y2milestone(
          "Partition smaller than 160650k: %1",
          partition
        )
      else
        Builtins.y2warning(
          "Partition is not smaller than 160650k: %1",
          partition
        )
      end
      tmp_partitions = Builtins.add(tmp_partitions, partition)
      partitions = deep_copy(tmp_partitions)
    end
    Builtins.y2milestone("Filtered existing partitions: %1", partitions)
    # found a boot partition on the same device as the root partition?
    if hasrootdev && Ops.greater_than(Builtins.size(partitions), 0) &&
        selected_boot_partition == ""
      Builtins.y2milestone(
        "Selected pmac boot partition %1 on device with root partition %2",
        Ops.get_string(partitions, [0, "device"], ""),
        BootStorage.RootPartitionDevice
      )
      selected_boot_partition = Ops.get_string(
        partitions,
        [0, "device"],
        ""
      )
    end
    # collect found boot partitions
    boot_partitions = Convert.convert(
      Builtins.merge(boot_partitions, Builtins.maplist(partitions) do |p|
        Ops.get_string(p, "device", "")
      end),
      :from => "list",
      :to   => "list <string>"
    )
  end
  Builtins.y2milestone("Detected pmac boot partitions: %1", boot_partitions)
  @pmac_boot_partitions = deep_copy(boot_partitions)
  if selected_boot_partition == ""
    selected_boot_partition = Ops.get(boot_partitions, 0, "")
  end
  Builtins.y2milestone(
    "Selected pmac boot partition: %1",
    selected_boot_partition
  )
  selected_boot_partition
end

- (Boolean) Import(settings)

Import settings from a map

Parameters:

  • settings (Hash)

    map of bootloader settings

Returns:

  • (Boolean)

    true on success



857
858
859
860
861
862
863
# File '../../src/modules/BootPOWERLILO.rb', line 857

def Import(settings)
  settings = deep_copy(settings)
  BootCommon.globals = Ops.get_map(settings, "global", {})
  BootCommon.sections = Ops.get_list(settings, "sections", [])
  BootCommon.activate = Ops.get_boolean(settings, "activate", false)
  true
end

- (Object) initBoardType

misc. functions



401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
# File '../../src/modules/BootPOWERLILO.rb', line 401

def initBoardType
  if Arch.board_iseries
    @board_type = "iseries"
  elsif Arch.board_prep
    @board_type = "prep"
  elsif Arch.board_chrp
    @board_type = "chrp"
  elsif Arch.board_mac_new
    @board_type = "pmac"
  elsif Arch.board_mac_old
    @board_type = "pmac"
  else
    @board_type = "unknown"
  end
  Builtins.y2milestone("setting board type to: %1", @board_type)

  nil
end

- (Object) Initializer

Initializer of PowerLILO bootloader



1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
# File '../../src/modules/BootPOWERLILO.rb', line 1272

def Initializer
  Builtins.y2milestone("Called PowerLILO initializer")
  BootCommon.current_bootloader_attribs = {
    "propose"            => true,
    "read"               => true,
    "scratch"            => true,
    "bootloader_on_disk" => true
  }

  BootCommon.InitializeLibrary(false, "ppc")

  nil
end

- (Boolean) iSeriesExecute(command, logfile)

Helper function that executes a command with the shell, appending stdout and stderr to a logfile. On error, it writes log entries to the yast2 log.

Parameters:

  • command (String)

    string command to execute

  • logfile (String)

    string logfile for the commands output

Returns:

  • (Boolean)

    true on success



297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
# File '../../src/modules/BootPOWERLILO.rb', line 297

def iSeriesExecute(command, logfile)
  command = Ops.add(Ops.add(Ops.add(command, " >>"), logfile), " 2>&1")
  command_ret = Convert.to_integer(
    SCR.Execute(path(".target.bash"), command)
  )
  if command_ret != 0
    Builtins.y2error(
      "Execution of command failed: %1, error code: %2",
      command,
      command_ret
    )
    log = Convert.to_string(SCR.Read(path(".target.string"), logfile))
    Builtins.y2error("stderr and stdout of the command: %1", log)
    return false
  end
  true
end

- (Object) iSeriesInit

Initialize attributes of the board type



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

def iSeriesInit
  Builtins.y2milestone("Initializing iSeries attributes")
  @prep_only_active = true
  @prep_only_iseries_vd = true
  @prep_only_primary = true
  @prep_same_disk_as_root = false
  @table_items = ["__iseries_location"]

  nil
end

- (Boolean) iSeriesWrite

Install the board-type-specific part of bootloader

Returns:

  • (Boolean)

    true on success



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
374
375
376
377
378
379
380
381
382
383
# File '../../src/modules/BootPOWERLILO.rb', line 318

def iSeriesWrite
  return true if !BootCommon.activate

  # during installation (fresh or update), always install the ISERIES64
  # file into slot A as a "rescue system"
  if Stage.initial
    command = ""
    my_log = "/var/log/YaST2/y2log_bootloader_iseries_slot_a"

    # bnc #409927 VUL-0: yast2: slideshow not checked cryptographically
    src_filename = Pkg.SourceProvideDigestedFile(
      @base_source,
      1,
      "/ISERIES64",
      false
    )

    if @base_source == -1 || src_filename == nil
      Builtins.y2milestone(
        "Cannot write rescue kernel to slot A, base source not found"
      )
      return false
    end

    rescue_bootbinary = Ops.add(
      Convert.to_string(SCR.Read(path(".target.tmpdir"))),
      "/rescue_bootbinary"
    )

    tg_rescue_bootbinary = Ops.add(Installation.destdir, rescue_bootbinary)
    Builtins.y2milestone(
      "Copying %1 to %2",
      src_filename,
      tg_rescue_bootbinary
    )
    WFM.Execute(
      path(".local.bash"),
      Builtins.sformat("/bin/cp %1 %2", src_filename, tg_rescue_bootbinary)
    )

    Builtins.y2milestone("start writing rescue kernel to slot A ...")
    command = Ops.add(
      Ops.add("time dd if=", rescue_bootbinary),
      " of=/proc/iSeries/mf/A/vmlinux bs=64k"
    )
    return false if !iSeriesExecute(command, my_log)

    if !iSeriesExecute(
        "dd if=/dev/zero of=/proc/iSeries/mf/A/cmdline bs=255 count=1",
        my_log
      )
      return false
    end

    # NOTE: on SLES10, the "root=" parameter is not handled by the
    # initrd in the ISERIES64 file. The initrd just boots up to a
    # shell.
    SCR.Execute(
      path(".target.bash"),
      "echo -en 'start_shell manual=1\\0' > /proc/iSeries/mf/A/cmdline"
    )
    Builtins.y2milestone("done writing rescue kernel to slot A.")
  end

  true
end

- (Object) LocationProposal

Propose the location of the root device on disk and the boot device (if any), according to the subarchitecture. Results are stored in global variables.



560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
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
# File '../../src/modules/BootPOWERLILO.rb', line 560

def LocationProposal
  BootCommon.DetectDisks
  # del_parts is used by FixSections() in lilolike.ycp (imported by BootCommon.ycp)
  BootCommon.del_parts = BootStorage.getPartitionList(:deleted, "ppc")

  if BootCommon.DisksChanged
    Builtins.y2milestone("Reconfiguring locations")
    BootCommon.DetectDisks
  end

  if updatePrepBootPartitions || @prep_boot_partition == ""
    # TODO warning to user
    choosePrepBootPartition
  end

  case getBoardType
    when "chrp"
      BootStorage.BootPartitionDevice = @prep_boot_partition
    when "prep"
      BootStorage.BootPartitionDevice = @prep_boot_partition
    when "iseries"
      BootStorage.BootPartitionDevice = @prep_boot_partition
    when "pmac"
      BootStorage.BootPartitionDevice = GoodPmacBootPartition()
    else
      Builtins.y2error("Unknown ppc architecture")
  end

  # These need to be set, for POWERLILO probably only to interface with
  # autoyast, others base subsequent decisions on this.
  # See ConfigureLocation() in lilolike.ycp.
  #
  # Mini-discussion: If autoyast is mainly used to clone configs, the
  # loader_device and repl_mbr interface is enough, because loader_device
  # simply contains the name of the device (partition, disk MBR, RAID
  # device) to use for the bootloader.
  # But if autoyast some day is used to transport configurations to less
  # similar machines and setups, or to specify some sort of generic setup
  # with special settings that will work on most machines, it may (or may
  # not) be helpful to be able to specify boot_* variables in the autoyast
  # file. This may apply better to the boot_* variables in BootGRUB.ycp
  # though.
  # FIXME: what about loader_location (aka selected_location internally)?
  BootCommon.loader_device = BootStorage.BootPartitionDevice
  BootCommon.activate = true
  Builtins.y2milestone("Boot partition is %1", BootCommon.loader_device)

  nil
end

- (Object) main



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

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

  textdomain "bootloader"

  Yast.import "Arch"
  Yast.import "BootArch"
  Yast.import "BootCommon"
  Yast.import "BootStorage"
  Yast.import "Installation"
  Yast.import "Kernel"
  Yast.import "Mode"
  Yast.import "Stage"
  Yast.import "Storage"

  # include ppc specific help messages
  Yast.include self, "bootloader/ppc/helps.rb"

  # read my dialogs
  Yast.include self, "bootloader/routines/popups.rb"




  # This whole code is a big mess. To have a solution at all I included and
  # adapted copies of the code from the old BootPPC.ycp, from common code in
  # lilolike.ycp and others.
  #
  # od - February and March 2006

  # partition number for the bootloader (either 41PReP boot or Apple_HFS)
  # start with disabled value and let the partition scanner find a match.
  @prep_boot_partition = ""

  # map available of 41 PReP partitions, used on iSeries and CHRP
  @prep_boot_partitions = []

  # map available HFS partitions, used on PMac
  @pmac_boot_partitions = []

  # PReP boot partitions that were proposed by partitioner to install BL
  @install_prep_boot_partitions = []

  # saved ID of the base installation source
  @base_source = -1

  # iSeries specific global settings

  # current board attribs
  @prep_only_active = true
  @prep_only_iseries_vd = true
  @prep_only_primary = true
  @prep_same_disk_as_root = true
  @table_items = []
  @boot_device = ""

  @board_type = nil


  Yast.include self, "bootloader/ppc/dialogs.rb"
  BootPOWERLILO()
end

- (Object) ppc_section_types



1227
1228
1229
1230
1231
# File '../../src/modules/BootPOWERLILO.rb', line 1227

def ppc_section_types
  return ["image", "other"] if Arch.board_iseries

  ["image"]
end

- (Object) PRePInit

Initialize attributes of the board type



263
264
265
266
267
268
269
270
271
272
# File '../../src/modules/BootPOWERLILO.rb', line 263

def PRePInit
  Builtins.y2milestone("Initializing PReP attributes")
  @prep_only_active = true
  @prep_only_iseries_vd = false
  @prep_only_primary = true
  @prep_same_disk_as_root = false
  @table_items = ["__prep_location"]

  nil
end

- (Object) Propose

Propose bootloader settings



771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
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
# File '../../src/modules/BootPOWERLILO.rb', line 771

def Propose
  Builtins.y2debug(
    "Started propose: Glob: %1, Sec: %2",
    BootCommon.globals,
    BootCommon.sections
  )

  # Need to remember inst source ID now to get the ISERIES64 file from the
  # inst source later on (see Bug #165497, Comment #16). This won't work
  # later during inst_finish, so we need to do it earlier -- only the
  # proposal is a possible place.
  SaveInstSourceId()

  # FIXME: make modern code out of these conditionals
  #        - comments
  #        - simplify
  #        - check validity
  initial_propose = true
  if BootCommon.was_proposed
    # FIXME: autoyast settings are simply Import()ed and was_proposed is
    # set to true. The settings for the current board still need to be
    # initialized though. We do this every time the bootloader proposal is
    # called, because it also does not harm (results for the board
    # detection are cached both in Arch.ycp and in our variable
    # board_type.) To fix: make the "where does the information come
    # from", when, more clear and obvious (in the code and/or in docs).
    currentBoardInit if Mode.autoinst
    initial_propose = false
  else
    currentBoardInit
  end
  Builtins.y2milestone("board type is: %1", @board_type)

  # Get root and boot partition (if any)
  LocationProposal()

  if BootCommon.sections == nil || Builtins.size(BootCommon.sections) == 0
    CreateSections() # make an initial proposal for at least one section
    BootCommon.kernelCmdLine = Kernel.GetCmdLine
  else
    if Mode.autoinst
      Builtins.y2debug("Nothing to do in AI mode if sections exist")
      # bnc #439674 Autoyast install of Cell blades fails to install bootloader
      UpdateGlobalsInAutoInst()
    else
      BootCommon.FixSections(fun_ref(method(:CreateSections), "void ()"))
    end
  end

  if BootCommon.globals == nil ||
      # consider globals empty even if lines_cache_id is present
      Builtins.size(Builtins.filter(BootCommon.globals) do |key, v|
        key != "lines_cache_id"
      end) == 0
    CreateGlobals()
  else
    if Mode.autoinst
      Builtins.y2debug("Nothing to do in AI mode if globals are defined")
    else
      BootCommon.FixGlobals
    end
  end

  Builtins.y2milestone("Proposed sections: %1", BootCommon.sections)
  Builtins.y2milestone("Proposed globals: %1", BootCommon.globals)

  nil
end

- (Boolean) Read(reread, avoid_reading_device_map)

Read settings from disk internal data

Parameters:

  • reread (Boolean)

    boolean true to force reread settings from system

  • avoid_reading_device_map (Boolean)

    do not read new device map from file, use

Returns:

  • (Boolean)

    true on success



871
872
873
874
875
876
877
878
879
880
881
# File '../../src/modules/BootPOWERLILO.rb', line 871

def Read(reread, avoid_reading_device_map)
  BootCommon.InitializeLibrary(reread, "ppc")
  BootCommon.ReadFiles(avoid_reading_device_map) if reread

  ret = BootCommon.Read(false, avoid_reading_device_map)
  Builtins.y2milestone(":: Read globals: %1", BootCommon.globals)

  #importMetaData();

  ret
end

- (Object) Reset(init)

Reset bootloader settings



885
886
887
888
889
890
891
892
893
# File '../../src/modules/BootPOWERLILO.rb', line 885

def Reset(init)
  # Reset global variables to default values
  @prep_boot_partition = ""
  @prep_boot_partitions = []
  @install_prep_boot_partitions = []
  BootCommon.Reset(init)

  nil
end

- (Boolean) Save(clean, init, flush)

Save all bootloader configuration files to the cache of the PlugLib PlugLib must be initialized properly !!!

Parameters:

  • clean (Boolean)

    boolean true if settings should be cleaned up (checking their correctness, supposing all files are on the disk

  • init (Boolean)

    boolean true to init the library

  • flush (Boolean)

    boolean true to flush settings to the disk

Returns:

  • (Boolean)

    true if success



903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
# File '../../src/modules/BootPOWERLILO.rb', line 903

def Save(clean, init, flush)
  ret = true

  # FIXME: this is currently a copy from BootCommon::Save
  if clean
    BootCommon.RemoveUnexistentSections("", "")
    BootCommon.UpdateAppend
  end

  # check if there is selected "none" bootloader
  bl = BootCommon.getLoaderType(false)

  if bl == "none"
    BootCommon.InitializeLibrary(init, bl)
    return true
  end

  if !BootCommon.InitializeLibrary(init, "ppc")
    # send current disk/partition information to perl-Bootloader
    BootCommon.SetDiskInfo
  end

  # convert
  my_globals = Builtins.mapmap(BootCommon.globals) do |k, v|
    if k == "stage1_dev" || Builtins.regexpmatch(k, "^boot_.*custom$")
      next { k => BootStorage.Dev2MountByDev(v) }
    else
      next { k => v }
    end
  end

  # FIXME: remove all mountpoints of type 'boot/boot' through some Storage::<func>

  # FIXME: set one mountpoint 'boot/boot' for every boot target means all
  # partitions in 'boot_<arch>_custom' and 'clone' (chrp)

  # ret = ret && BootCommon::SetDeviceMap (device_mapping);

  # bnc #450506 root=kernelname in lilo.conf after upgrade
  BootCommon.sections = BootCommon.remapSections(BootCommon.sections)

  ret = ret && BootCommon.SetSections(BootCommon.sections)
  ret = ret && BootCommon.SetGlobal(my_globals)
  ret = ret && BootCommon.CommitSettings if flush

  #importMetaData();

  BootCommon.WriteToSysconf(false)
  ret
end

- (Object) SaveInstSourceId

Save the ID of the base installation source modifies internal variable



678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
# File '../../src/modules/BootPOWERLILO.rb', line 678

def SaveInstSourceId
  @base_source = -1

  # Find the source ID of the base product:
  # list all products
  products = Pkg.ResolvableProperties("", :product, "")
  Builtins.y2milestone("products: %1", products)
  # filter products to be installed
  products = Builtins.filter(products) do |p|
    Ops.get_integer(p, "source", -1) != -1
  end
  # get base products
  base_products = Builtins.filter(products) do |p|
    Ops.get_string(p, "category", "") == "base"
  end
  base_products = deep_copy(products) if Builtins.size(base_products) == 0 # just to be safe in case of a bug...
  sources = Builtins.maplist(base_products) do |p|
    Ops.get_integer(p, "source", -1)
  end
  Builtins.y2milestone(
    "remaining products: %1, sources: %2",
    products,
    sources
  )
  sources = Builtins.sort(sources)
  @base_source = Ops.get(sources, 0, -1)

  Builtins.y2milestone("Base source: %1", @base_source)

  nil
end

- (Object) Summary

Display bootloader summary

Returns:

  • a list of summary lines



957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
# File '../../src/modules/BootPOWERLILO.rb', line 957

def Summary
  result = []

  # FIXME:
  #	- evaluate and use the text from iSeriesSummary(), PRePSummary() and
  #	  CHRPSummary()
  #  - add the cases for mac_old and mac_new (see BootPPC::Summary())

  # summary text, %1 is bootloader name
  result = Builtins.add(
    result,
    Builtins.sformat(
      _("Boot loader type: %1"),
      BootCommon.getLoaderName(BootCommon.getLoaderType(false), :summary)
    )
  )

  # summary text for boot loader locations, sum up all locations to one string
  boot_loader_locations = Builtins.mergestring(
    Builtins.filter(Builtins.maplist(BootCommon.global_options) do |key, value|
      Builtins.substring(key, 0, 5) == "boot_" ?
        Ops.get(BootCommon.globals, key, "") :
        ""
    end) { |bll| bll != "" },
    ", "
  )
  result = Builtins.add(
    result,
    Builtins.sformat(_("Location: %1"), boot_loader_locations)
  )

  sects = []
  Builtins.foreach(BootCommon.sections) do |s|
    title = Ops.get_string(s, "name", "")
    # section name "suffix" for default section
    _def = title == Ops.get(BootCommon.globals, "default", "") ?
      _(" (default)") :
      ""
    sects = Builtins.add(
      sects,
      String.EscapeTags(Builtins.sformat("+ %1%2", title, _def))
    )
  end
  # summary text. %1 is list of bootloader sections
  result = Builtins.add(
    result,
    Builtins.sformat(
      _("Sections:<br>%1"),
      Builtins.mergestring(sects, "<br>")
    )
  )

  # FIXME: does the following code make any sense for ppc? (see also #163387)
  # It seems not. (We do not do this, cf. jplack.) Keeping the code cadaver
  # around until finally ready for removal.
  # if (BootCommon::loader_device == "/dev/null")
  #    // summary text
  #    result = add (result,
  #		_("Do not install boot loader; just create configuration files"));
  deep_copy(result)
end

- (Object) Update

Update read settings to new version of configuration files



1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
# File '../../src/modules/BootPOWERLILO.rb', line 1021

def Update
  # Firstly update sections of bootloader configuration and modify internal
  # structures as needed. This means right now:
  #
  # - no change of "resume=" parameter in append entry, not used on ppc yet
  # - delete console= parameters as console autodetection now works

  # This function has been copied from lilolike.ycp::UpdateSections and
  # adapted to conform with the image parameter
  # BootPOWERLILO.ycp/perl-Bootloader uses. Some unneeded code has been
  # removed.
  # FIXME: SLES9 -> SLES10 update: check loader_type = lilo in
  # /etc/sysconfig/bootloader

  # take current sections as starting point
  updated_sections = deep_copy(BootCommon.sections)
  linux_resume_added = false

  default_sect = CreateImageSection("linux")
  default_name = Ops.get_string(default_sect, "name", "")

  # assumption is that all of the following section names ar "good" names
  # meaning that we will return a valid section description from
  # CreateImageSection for them.
  sections_to_recreate = ["linux"]

  updated_sections = Builtins.maplist(updated_sections) do |s|
    name = Ops.get_string(s, "name", "")
    oname = Ops.get_string(s, "original_name", name)
    # if we find a section that looks like it has been initially proposed
    # from the installer, replace with the actual "good" proposal
    if Builtins.contains(sections_to_recreate, oname)
      sections_to_recreate = Builtins.filter(sections_to_recreate) do |this_name|
        this_name != oname
      end
      # check for a new global default if oname != name
      if name == Ops.get(BootCommon.globals, "default", "")
        # we assume that the new name produced by CreateImageSection
        # will be oname
        Ops.set(BootCommon.globals, "default", oname)
      end
      next CreateImageSection(oname)
    end
    # else adjust the entries of the found section according to some
    # fancy rules
    Builtins.foreach(["image", "initrd"]) do |key|
      value = Ops.get_string(s, key, "")
      # FIXME: check whether this is code for update from SLES8?
      #        then we would delete it.
      if Builtins.regexpmatch(value, "^.*.shipped.*$")
        value = Builtins.regexpsub(value, "^(.*).shipped(.*)$", "\\1\\2")
      elsif Builtins.regexpmatch(value, "^.*.suse.*$")
        value = Builtins.regexpsub(value, "^(.*).suse(.*)$", "\\1\\2")
      end
      Ops.set(s, key, value)
    end
    # update root= entry in selected sections as the device naming
    # changes in the linux kernel from time to time ...
    if Builtins.contains(BootCommon.update_section_types, oname) &&
        Builtins.haskey(s, "root")
      Builtins.y2milestone("Updating root device of section %1", name)
      Ops.set(
        s,
        "root",
        BootCommon.UpdateDevice(Ops.get_string(s, "root", ""))
      )
    end
    # handle the append line
    append = Ops.get_string(s, "append", "")
    # FIXME: how should we handle root= entries in append= lines?

    # add additional kernel parameters to the end of the append entry
    # of special image section 'linux'
    #
    if oname == "linux"
      Builtins.foreach(BootCommon.ListAdditionalKernelParams) do |o|
        append = BootCommon.setKernelParamToLine(append, o, "false")
      end
      append = Ops.add(
        Ops.add(append, " "),
        BootCommon.GetAdditionalKernelParams
      )

      if BootCommon.getKernelParamFromLine(append, "splash") == "false"
        append = BootCommon.setKernelParamToLine(append, "splash", "silent")
      end
    end
    # remove console= entries from kernel parameters, console auto
    # detection now works. For special sections take what's given on boot
    # command line
    console = "false" # false means delete to 'setKernelParamToLine'
    if Builtins.contains(BootCommon.update_section_types, oname)
      console = BootCommon.getKernelParamFromLine(
        Kernel.GetCmdLine,
        "console"
      )
    end
    append = BootCommon.setKernelParamToLine(append, "console", console)
    # finally append entry is written back
    if append != ""
      Ops.set(s, "append", append)
    else
      s = Builtins.remove(s, "append")
    end
    deep_copy(s)
  end

  # if there was no original section matching the sections we want to
  # recreate, so do prepend or append newly created sections to the list of
  # updated sections
  Builtins.foreach(sections_to_recreate) do |section_name|
    new_section = CreateImageSection(section_name)
    if section_name == "linux"
      updated_sections = Builtins.prepend(updated_sections, new_section)
    else
      updated_sections = Builtins.add(updated_sections, new_section)
    end
  end

  BootCommon.sections = deep_copy(updated_sections)
  Builtins.y2milestone("finished updating sections: %1", updated_sections)
  # End of UpdateSections ();

  # Secondly update global settings of bootloader configuration:
  #
  # - no change of 'activate'
  # - no change of 'timeout'
  # - no change of default section
  # - no change of default initrd
  # - update device names that might have changed in as needed
  # - delete console= parameters as console autodetection now works
  BootCommon.loader_device = BootCommon.UpdateDevice(
    BootCommon.loader_device
  )

  # update device naming of default root and boot_* entries
  Builtins.foreach(
    [
      "root",
      "boot_prep_custom",
      "boot_chrp_custom",
      "boot_iseries_custom",
      "boot_pmac_custom",
      "clone"
    ]
  ) do |key|
    if Builtins.haskey(BootCommon.globals, key)
      Builtins.y2milestone(
        "Updating global %1= setting, currently %2",
        key,
        Ops.get(BootCommon.globals, key, "")
      )
      Ops.set(
        BootCommon.globals,
        key,
        BootCommon.UpdateDevice(Ops.get(BootCommon.globals, key, ""))
      )
    end
  end

  # remove console= entries from globals, console auto detection now works
  if Builtins.haskey(BootCommon.globals, "append")
    append = Ops.get(BootCommon.globals, "append", "")
    append = BootCommon.setKernelParamToLine(append, "console", "false")
    if append != ""
      Ops.set(BootCommon.globals, "append", append)
    else
      BootCommon.globals = Builtins.remove(BootCommon.globals, "append")
    end
  end

  nil
end

- (Object) UpdateGlobalsInAutoInst

bnc #439674 Autoyast install of Cell blades fails to install bootloader The function update global settings for bootloader if there is used autoyast The basic problem is that there is missing boot_* , timeout etc. If there missing necessary information they will be added



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
759
760
761
762
763
764
765
766
# File '../../src/modules/BootPOWERLILO.rb', line 716

def UpdateGlobalsInAutoInst
  if !Builtins.haskey(BootCommon.globals, "timeout")
    Ops.set(BootCommon.globals, "timeout", "8")
  end

  if !Builtins.haskey(BootCommon.globals, "activate")
    Ops.set(BootCommon.globals, "activate", "true")
  end

  # if there missing boot_* -> then propose it
  if !Builtins.haskey(BootCommon.globals, "boot_chrp_custom") &&
      !Builtins.haskey(BootCommon.globals, "boot_prep_custom") &&
      !Builtins.haskey(BootCommon.globals, "boot_pmac_custom") &&
      !Builtins.haskey(BootCommon.globals, "boot_iseries_custom")
    arch = getBoardType
    case arch
      when "prep"
        Ops.set(
          BootCommon.globals,
          "boot_prep_custom",
          BootStorage.BootPartitionDevice
        )
      when "pmac"
        Ops.set(
          BootCommon.globals,
          "boot_pmac_custom",
          BootStorage.BootPartitionDevice
        )
      when "iseries"
        Ops.set(BootCommon.globals, "boot_slot", "B")
        Ops.set(BootCommon.globals, "boot_file", "/tmp/suse_linux_image")

        if BootStorage.BootPartitionDevice != nil &&
            BootStorage.BootPartitionDevice != ""
          Ops.set(
            BootCommon.globals,
            "boot_iseries_custom",
            BootStorage.BootPartitionDevice
          )
        end
      else
        Ops.set(
          BootCommon.globals,
          "boot_chrp_custom",
          BootStorage.BootPartitionDevice
        )
    end
  end

  nil
end

- (Boolean) updatePrepBootPartitions

Update list of 41 PReP boot partitions

Returns:

  • (Boolean)

    true if list changed, false otherwise



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

def updatePrepBootPartitions
  Builtins.y2milestone(
    "Detecting PReP partitions: prep_only_active: %1, prep_only_iseries_vd: %2, prep_only_primary: %3",
    @prep_only_active,
    @prep_only_iseries_vd,
    @prep_only_primary
  )
  targetMap = Storage.GetTargetMap
  Builtins.y2milestone("TargetMap: %1", targetMap)
  old_prep_boot_partitions = deep_copy(@prep_boot_partitions)
  old_install_prep_boot_partitions = deep_copy(
    @install_prep_boot_partitions
  )
  @prep_boot_partitions = []
  @install_prep_boot_partitions = []
  Builtins.y2milestone(
    "old prep_boot_partitions %1",
    old_prep_boot_partitions
  )

  Builtins.foreach(targetMap) do |dname, ddata|
    partitions = Ops.get_list(ddata, "partitions", [])
    Builtins.y2milestone("Partitions: %1", partitions)
    partitions = Builtins.filter(partitions) do |p|
      !Ops.get_boolean(p, "delete", false) &&
        Ops.is_integer?(Ops.get(p, "fsid")) &&
        # both partition types 0x41 and FAT16 can be handled by PPC lilo
        (Ops.get(p, "fsid") == 65 || Ops.get(p, "fsid") == 6) &&
        !Builtins.contains(
          [:lvm, :evms, :sw_raid],
          Ops.get_symbol(p, "type", :primary)
        )
    end
    Builtins.y2milestone("Filtered existing partitions: %1", partitions)
    # prep_only_iseries_vd means: use only partitions on /dev/iseries/vd*
    partitions = Builtins.filter(partitions) do |p|
      Builtins.regexpmatch(
        Ops.get_string(p, "device", ""),
        "/dev/iseries/vd.*"
      )
    end if @prep_only_iseries_vd
    partitions = Builtins.filter(partitions) do |p|
      Ops.get_symbol(p, "type", :primary) == :primary
    end if @prep_only_primary
    Builtins.y2milestone("Finally filtered partitions: %1", partitions)
    @prep_boot_partitions = Convert.convert(
      Builtins.merge(@prep_boot_partitions, Builtins.maplist(partitions) do |p|
        Ops.get_string(p, "device", "")
      end),
      :from => "list",
      :to   => "list <string>"
    )
    partitions = Builtins.filter(partitions) do |p|
      Ops.get_boolean(p, "prep_install", false)
    end
    Builtins.y2milestone(
      "Finally filtered recommended partitions: %1",
      partitions
    )
    @install_prep_boot_partitions = Convert.convert(
      Builtins.merge(
        @install_prep_boot_partitions,
        Builtins.maplist(partitions) { |p| Ops.get_string(p, "device", "") }
      ),
      :from => "list",
      :to   => "list <string>"
    )
  end
  @prep_boot_partitions = Builtins.filter(@prep_boot_partitions) do |p|
    p != ""
  end
  @prep_boot_partitions = Builtins.sort(@prep_boot_partitions)
  Builtins.y2milestone(
    "Detected PReP partitions: %1",
    @prep_boot_partitions
  )
  Builtins.y2milestone(
    "Proposed PReP partitions: %1",
    @install_prep_boot_partitions
  )

  if old_prep_boot_partitions == @prep_boot_partitions &&
      old_install_prep_boot_partitions == @install_prep_boot_partitions
    Builtins.y2milestone("PReP Partitions unchanged")
    return false
  else
    Builtins.y2milestone("PReP Partitions changed")
    return true
  end
end

- (Boolean) Write

Write bootloader settings to disk

Returns:

  • (Boolean)

    true on success



1197
1198
1199
1200
1201
1202
1203
1204
1205
# File '../../src/modules/BootPOWERLILO.rb', line 1197

def Write
  iSeriesWrite if getBoardType == "iseries"

  ret = BootCommon.UpdateBootloader

  ret = ret && BootCommon.InitializeBootloader
  ret = false if ret == nil
  ret
end