Class: Yast::BootCommonClass
- Inherits:
-
Module
- Object
- Module
- Yast::BootCommonClass
- Defined in:
- ../../src/modules/BootCommon.rb
Instance Method Summary (collapse)
-
- (Object) checkMemtest
bnc #390659 - autoyast bootloader config: empty settings are ignored (memtest).
-
- (Object) CreateLinuxSection(title)
Create section for linux kernel.
-
- (Object) Export
Export bootloader settings to a map.
-
- (Object) getBootloaders
List bootloaders available for configured architecture.
-
- (String) getLoaderType(recheck)
Get currently used bootloader, detect if not set yet.
- - (Object) getSystemSecureBootStatus(recheck)
-
- (Boolean) Import(settings)
Import settings from a map.
-
- (Boolean) isTrustedGrub
Function check if trusted grub is selected or installed return true if is selected/installed and add trusted_grub to globals.
- - (Object) main
-
- (Object) Md2Partitions(md_device)
FIXME just backward compatible interface, call directly BootStorage.
-
- (Object) Propose
Propose bootloader settings.
-
- (Boolean) Read(reread, avoid_reading_device_map)
Read settings from disk internal data.
-
- (Boolean) removeGFXMenu
bnc# 346576 - Bootloader configuration doesn't work for serial output Function check if settings need to remove gfxmenu.
-
- (Object) Reset(init)
Reset bootloader settings.
-
- (Boolean) Save(clean, init, flush)
Save all bootloader configuration files to the cache of the PlugLib PlugLib must be initialized properly !!!.
-
- (Fixnum) Section2Index(section_name)
Search for section passed.
-
- (Object) setCurrentLoaderAttribs(loader_type)
Set attributes of specified bootloader to variable containing attributes of currently used bootloader, call its initializer.
-
- (Object) setLoaderType(bootloader)
set type of bootloader.
- - (Object) setSystemSecureBootStatus(enable)
-
- (Object) Summary
Display bootloader summary.
-
- (String) SupportedLoader(loader)
Check whether loader with specified name is supported.
-
- (Object) Update
Update read settings to new version of configuration files.
-
- (Boolean) VerifyMDArray
FATE#305008: Failover boot configurations for md arrays with redundancy Verify if proposal includes md array with 2 diferent disks.
-
- (Boolean) Write
Write bootloader settings to disk.
-
- (Boolean) XenPresent
FIXME 2x functions should not be finally here…
Instance Method Details
- (Object) checkMemtest
bnc #390659 - autoyast bootloader config: empty settings are ignored (memtest)
Check if sections inlcude section for memtest if yes delete all unnecessary keys like initrd, vgamode, append…
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 |
# File '../../src/modules/BootCommon.rb', line 579 def checkMemtest out = [] Builtins.foreach(@sections) do |s| if Builtins.search(Ops.get_string(s, "image", ""), "memtest") != nil tmp_s = {} Ops.set(tmp_s, "image", Ops.get_string(s, "image", "")) Ops.set( tmp_s, "original_name", Ops.get_string(s, "original_name", "") ) Ops.set(tmp_s, "name", Ops.get_string(s, "name", "")) Ops.set(tmp_s, "__changed", Ops.get_boolean(s, "__changed", false)) Ops.set(tmp_s, "__auto", Ops.get_boolean(s, "__auto", false)) Ops.set(tmp_s, "type", Ops.get_string(s, "type", "")) Builtins.y2milestone( "Updating memtest section from: %1 to: %2", s, tmp_s ) out = Builtins.add(out, tmp_s) else out = Builtins.add(out, s) end end @sections = deep_copy(out) nil end |
- (Object) CreateLinuxSection(title)
Create section for linux kernel
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 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 434 435 436 437 438 |
# File '../../src/modules/BootCommon.rb', line 251 def CreateLinuxSection(title) ret = { "name" => title, "original_name" => title, "type" => "image", "__auto" => true, "__changed" => true } if title == "memtest86" if MemtestPresent() Ops.set(ret, "image", "/boot/memtest.bin") Ops.set(ret, "__devs", [BootStorage.BootPartitionDevice]) return deep_copy(ret) else return {} end end resume = BootArch.ResumeAvailable ? getLargestSwapPartition : "" # try to use label or udev id for device name... FATE #302219 if resume != "" && resume != nil resume = BootStorage.Dev2MountByDev(resume) end # FIXME: # This only works in the installed system (problem with GetFinalKernel()), # in all other cases we use the symlinks. kernel_fn = "" initrd_fn = "" if Mode.normal # Find out the file names of the "real" kernel and initrd files, with # version etc. pp. whatever (currently version-flavor) attached. # FIXME: also do this for xen and xenpae kernels as found below # # Note: originally, we wanted to find out the kernel file names during # installation proposal when the files are not yet installed. But not # all the necessary interfaces work at that time. Now, this variant is # only run in the "running system", and could as well look at the # installed files. # # First of all, we have to initialize the RPM database Pkg.TargetInit( "/", # installed system false ) # don't create a new RPM database # Then, get the file names in the "selected" kernel package, kernel_package = Kernel.ComputePackage files = Pkg.PkgGetFilelist(kernel_package, :installed) Builtins.y2milestone( "kernel package %1 has these files: %2", kernel_package, files ) # then find the first file that matches the arch-dependent kernel file # name prefix and the initrd filename prefix. kernel_prefix = Ops.add("/boot/", Kernel.GetBinary) initrd_prefix = "/boot/initrd" files_filtered = Builtins.filter(files) do |file| Builtins.substring(file, 0, Builtins.size(kernel_prefix)) == kernel_prefix end # Sort the filtered files, thus the image strings by length, the big ones # at the beginning, the small ones at the end of the list. # So, the first element of the sorted list files_filtered is the image string # containing the version and flavor. files_filtered = Builtins.sort(files_filtered) do |kbig, ksmall| Ops.greater_than(Builtins.size(kbig), Builtins.size(ksmall)) end kernel_fn = Ops.get(files_filtered, 0, "") files_filtered = Builtins.filter(files) do |file| Builtins.substring(file, 0, Builtins.size(initrd_prefix)) == initrd_prefix && !Builtins.regexpmatch(file, "-kdump$") end # Sort the filtered files, thus the initrd strings by length, the big ones # at the beginning, the small ones at the end of the list. # So, the first element of the sorted list files_filtered is the initrd string # containing the version and flavor. files_filtered = Builtins.sort(files_filtered) do |ibig, ismall| Ops.greater_than(Builtins.size(ibig), Builtins.size(ismall)) end initrd_fn = Ops.get(files_filtered, 0, "") kernel_fn = "/boot/vmlinuz" if kernel_fn == "" || kernel_fn == nil initrd_fn = "/boot/initrd" if initrd_fn == "" || initrd_fn == nil # read commandline options for kernel cmd = Convert.convert( SCR.Read(path(".proc.cmdline")), :from => "any", :to => "list <string>" ) vga = nil # trying to find "vga" option Builtins.foreach(cmd) do |key| vga = key if Builtins.issubstring(key, "vga=") Builtins.y2milestone("key: %1", key) end Builtins.y2milestone("vga from command line: %1", vga) mode = [] # split vga=value if vga != nil && vga != "" mode = Builtins.splitstring(Builtins.tostring(vga), "=") end vgamode = nil # take value if exist if Ops.greater_than(Builtins.size(mode), 1) && Ops.get(mode, 0, "") == "vga" vgamode = Ops.get(mode, 1) end # add value of vga into proposal (if exist) if vgamode != nil && vgamode != "" Ops.set(ret, "vgamode", vgamode) Builtins.y2milestone("vga mode: %1", vgamode) end else # the links are shown in the proposal; at the end of an installation, # in bootloader_finish, they will be resolved to the real filenames kernel_fn = Ops.add("/boot/", Kernel.GetBinary) initrd_fn = "/boot/initrd" end # done: kernel_fn and initrd_fn are the results Builtins.y2milestone("kernel_fn: %1 initrd_fn: %2", kernel_fn, initrd_fn) ret = Convert.convert( Builtins.union( ret, { "image" => kernel_fn, "initrd" => initrd_fn, # try to use label or udev id for device name... FATE #302219 "root" => BootStorage.Dev2MountByDev( BootStorage.RootPartitionDevice ), "append" => title == "failsafe" ? BootArch.FailsafeKernelParams : BootArch.DefaultKernelParams(resume), "__devs" => [ BootStorage.BootPartitionDevice, BootStorage.RootPartitionDevice ] } ), :from => "map", :to => "map <string, any>" ) if BootArch.VgaAvailable && Kernel.GetVgaType != "" # B#352020 kokso: - Graphical failsafe mode #if (title == "failsafe") # ret["vga"] = "normal"; #else Ops.set(ret, "vgamode", Kernel.GetVgaType) # B#352020 end end if title == "xen" Ops.set(ret, "type", "xen") Ops.set(ret, "xen_append", "") Ops.set(ret, "xen", "/boot/xen.gz") Ops.set( ret, "image", Ops.add(Ops.add("/boot/", Kernel.GetBinary), "-xen") ) Ops.set(ret, "initrd", "/boot/initrd-xen") end deep_copy(ret) end |
- (Object) Export
Export bootloader settings to a map
444 445 446 447 448 449 450 451 452 453 454 455 |
# File '../../src/modules/BootCommon.rb', line 444 def Export exp = { "global" => remapGlobals(@globals), "sections" => remapSections(@sections), "device_map" => BootStorage.remapDeviceMap(BootStorage.device_mapping) } if !(@loader_type == "grub" || @loader_type == "grub2") Ops.set(exp, "activate", @activate) end deep_copy(exp) end |
- (Object) getBootloaders
List bootloaders available for configured architecture
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 953 954 955 956 957 958 959 960 |
# File '../../src/modules/BootCommon.rb', line 925 def getBootloaders if Mode.config return [ "grub", "grub2", "grub2-efi", "default", "none" ] end ret = [ getLoaderType(false) ] if Arch.i386 || Arch.x86_64 ret = Convert.convert( Builtins.merge(ret, ["grub2"]), :from => "list", :to => "list <string>" ) if Arch.x86_64 ret = Convert.convert( Builtins.merge(ret, ["grub2-efi"]), :from => "list", :to => "list <string>" ) end end if Arch.s390 || Arch.ppc ret = ["grub2"] end # in order not to display it twice when "none" is selected ret = Builtins.filter(ret) { |l| l != "none" } ret = Builtins.toset(ret) ret = Builtins.add(ret, "none") deep_copy(ret) end |
- (String) getLoaderType(recheck)
Get currently used bootloader, detect if not set yet
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 839 840 |
# File '../../src/modules/BootCommon.rb', line 791 def getLoaderType(recheck) return @loader_type if !recheck && @loader_type != nil # read bootloader to use from disk if Mode.update || Mode.normal || Mode.repair @loader_type = Convert.to_string( SCR.Read(path(".sysconfig.bootloader.LOADER_TYPE")) ) if @loader_type != nil && @loader_type != "" @loader_type = "grub2" if @loader_type == "s390" Builtins.y2milestone( "Sysconfig bootloader is %1, using", @loader_type ) @loader_type = SupportedLoader(@loader_type) Builtins.y2milestone( "Sysconfig bootloader is %1, using", @loader_type ) setCurrentLoaderAttribs(@loader_type) return @loader_type end end # detect bootloader @loader_type = Convert.to_string(SCR.Read(path(".probe.boot_arch"))) @loader_type = "grub2" if @loader_type == "s390" # ppc uses grub2 (fate #315753) @loader_type = "grub2" if @loader_type == "ppc" # suppose grub2 should superscede grub .. @loader_type = "grub2" if @loader_type == "grub" Builtins.y2milestone("Bootloader detection returned %1", @loader_type) # lslezak@: Arch::is_xenU() returns true only in PV guest if Arch.is_uml || Arch.is_xenU # y2milestone ("Not installing any bootloader for UML/Xen PV"); # loader_type = "none"; # bnc #380982 - pygrub cannot boot kernel # added installation of bootloader Builtins.y2milestone( "It is XEN domU and the bootloader should be installed" ) end if (Arch.i386 || Arch.x86_64) && Linuxrc.InstallInf("EFI") == "1" # use grub2-efi as default bootloader for x86_64/i386 EFI @loader_type = "grub2-efi" end @loader_type = SupportedLoader(@loader_type) Builtins.y2milestone("Detected bootloader %1", @loader_type) setCurrentLoaderAttribs(@loader_type) @loader_type end |
- (Object) getSystemSecureBootStatus(recheck)
896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 |
# File '../../src/modules/BootCommon.rb', line 896 def getSystemSecureBootStatus(recheck) return @secure_boot if !recheck && @secure_boot != nil if Mode.update || Mode.normal || Mode.repair sb = Convert.to_string( SCR.Read(path(".sysconfig.bootloader.SECURE_BOOT")) ) if sb != nil && !sb.empty? @secure_boot = sb == "yes" return @secure_boot end end # propose secure boot always to true (bnc#872054), otherwise respect user choice @secure_boot = true if @secure_boot.nil? @secure_boot end |
- (Boolean) Import(settings)
Import settings from a map
460 461 462 463 464 465 466 467 468 469 470 |
# File '../../src/modules/BootCommon.rb', line 460 def Import(settings) settings = deep_copy(settings) @globals = Ops.get_map(settings, "global", {}) @sections = Ops.get_list(settings, "sections", []) if !(@loader_type == "grub" || @loader_type == "grub2") @activate = Ops.get_boolean(settings, "activate", false) end BootStorage.device_mapping = Ops.get_map(settings, "device_map", {}) true end |
- (Boolean) isTrustedGrub
Function check if trusted grub is selected or installed return true if is selected/installed and add trusted_grub to globals
232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 |
# File '../../src/modules/BootCommon.rb', line 232 def isTrustedGrub ret = false if Mode.normal if Pkg.IsProvided("trustedgrub") || Package.Installed("trustedgrub") ret = true Ops.set(@globals, "trusted_grub", "true") end else if Pkg.IsSelected("trustedgrub") ret = true Ops.set(@globals, "trusted_grub", "true") end end ret 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 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 |
# File '../../src/modules/BootCommon.rb', line 25 def main Yast.import "Pkg" Yast.import "UI" textdomain "bootloader" Yast.import "Arch" Yast.import "GfxMenu" Yast.import "HTML" Yast.import "Mode" Yast.import "PackageSystem" Yast.import "Storage" Yast.import "String" Yast.import "Popup" Yast.import "Package" Yast.import "PackagesProposal" Yast.import "BootStorage" Yast.import "Linuxrc" # General bootloader settings # map of global options and types for new perl-Bootloader interface @global_options = {} # map of global options and values @globals = {} # list of section @sections = [] # Saved change time from target map - proposal @cached_settings_base_data_change_time = nil # device to save loader stage 1 to # NOTE: this variable is being phased out. The boot_* keys in the globals map # are now used to remember the selected boot location. Thus, we now have a # list of selected loader devices. It can be generated from the information in # the boot_* keys and the global variables (Boot|Root|Extended)PartitionDevice # and mbrDisk by calling GetBootloaderDevices(). #FIXME: need remove to read only loader location from perl-Bootloader @loader_device = nil # proposal helping variables # The kind of bootloader location that the user selected last time he went to # the dialog. Used as a hint next time a proposal is requested, so the # proposal can try to satisfy the user's previous preference. # NOTE: this variable is being phased out. The boot_* keys in the globals map # will be used to remember the last selected location. # Currently, valid values are: mbr, boot, root, floppy, mbr_md, none #FIXME: need remove to read only loader location from perl-Bootloader @selected_location = nil # These global variables and functions are needed in included files # Parameters of currently used bootloader @current_bootloader_attribs = {} # Parameters of all bootloaders @bootloader_attribs = {} # Name of currently edited section @current_section_name = nil # Index of current section, -1 for new created section @current_section_index = -1 # Curtrently edited section -- tmp store @current_section = {} # device holding MBR for bootloader @mbrDisk = "" # Backup original MBR before installing bootloader @backup_mbr = false # Activate bootloader partition during installation? @activate = false # action to do with pbmr flag on boot disk # values are :add, :remove or nil, means do nothing @pmbr_action = nil # Kernel parameters at previous detection @kernelCmdLine = "" # were settings changed (== true) @changed = false # common variables # type of bootloader to configure/being configured # shall be one of "grub", "grub2", "grub2-efi" @loader_type = nil @secure_boot = nil # sysconfig variables # installation proposal help variables # List of partitions deleted in primary proposal @del_parts = [] # variables for storing data # saving mode setting functions # map of save mode settings @write_settings = {} # summary dialog state # ui help variables @additional_failsafe_params = "" # other variables # Settings of other bootloaders used when switching bootloader @other_bl = {} # bootloader installation variables # Was the activate flag changed by user? @activate_changed = false # Save everything, not only changed settings @save_all = false # state variables # was the propose function called (== true) @was_proposed = false # Were module settings read (== true) @was_read = false # Was bootloader location changed? (== true) @location_changed = false # Were configuration files manually edited and chamged? @files_edited = false # time of last change of partitioning @partitioning_last_change = 0 # true if memtest was removed by user (manually) during the installation # proposal #FIXME correct comment @removed_sections = [] # The name of the default section as it was read @read_default_section_name = "" # Types of sections that should be updated (changed device names) # FIXME: see FIXME in lilolike.ycp:899 @update_section_types = ["floppy", "other"] # = [ "linux", "failsafe", "initrd", "floppy" ]; # List of all supported bootloaders @bootloaders = [ "grub", "grub2", "grub2-efi" ] # FATE#305008: Failover boot configurations for md arrays with redundancy # if true enable redundancy for md array @enable_md_array_redundancy = nil # FATE#305557: Enable SELinux for 11.2 # if true create /selinux directory @enable_selinux = false # help message and dscription definitions Yast.include self, "bootloader/routines/popups.rb" Yast.include self, "bootloader/routines/misc.rb" # FIXME: there are other archs than i386, this is not 'commmon' Yast.include self, "bootloader/routines/lilolike.rb" Yast.include self, "bootloader/routines/lib_iface.rb" end |
- (Object) Md2Partitions(md_device)
FIXME just backward compatible interface, call directly BootStorage
997 998 999 |
# File '../../src/modules/BootCommon.rb', line 997 def Md2Partitions(md_device) BootStorage.Md2Partitions(md_device) end |
- (Object) Propose
Propose bootloader settings
545 546 547 548 549 |
# File '../../src/modules/BootCommon.rb', line 545 def Propose Builtins.y2error("No generic propose function available") nil end |
- (Boolean) Read(reread, avoid_reading_device_map)
Read settings from disk internal data
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 |
# File '../../src/modules/BootCommon.rb', line 477 def Read(reread, avoid_reading_device_map) bl = getLoaderType(false) return true if bl == "none" InitializeLibrary(reread, bl) ReadFiles(avoid_reading_device_map) if reread @sections = GetSections() @globals = GetGlobal() isTrustedGrub BootStorage.device_mapping = GetDeviceMap() @read_default_section_name = "" Builtins.foreach(@sections) do |s| if Ops.get_string(s, "original_name", "") == "linux" && @read_default_section_name == "" @read_default_section_name = Ops.get_string(s, "name", "") end end # convert device names in device map to the kernel device names BootStorage.device_mapping = Builtins.mapmap(BootStorage.device_mapping) do |k, v| { BootStorage.Dev2MountByDev(k) => v } end # convert custom boot device names in globals to the kernel device names # also, for legacy bootloaders like LILO that still pass device names, # convert the stage1_dev @globals = Builtins.mapmap(@globals) do |k, v| if k == "stage1_dev" || Builtins.regexpmatch(k, "^boot_.*custom$") next { k => BootStorage.Dev2MountByDev(v) } else next { k => v } end end # convert root device names in sections to kernel device names, if # possible @sections = Builtins.maplist(@sections) do |s| rdev = Ops.get_string(s, "root", "") # bnc#533782 - after changing filesystem label system doesn't boot if Ops.get_string(s, "append", "") != "" Ops.set( s, "append", remapResume(Ops.get_string(s, "append", ""), true) ) end Ops.set(s, "root", BootStorage.Dev2MountByDev(rdev)) deep_copy(s) end true end |
- (Boolean) removeGFXMenu
bnc# 346576 - Bootloader configuration doesn't work for serial output Function check if settings need to remove gfxmenu
556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 |
# File '../../src/modules/BootCommon.rb', line 556 def removeGFXMenu if Ops.get(@globals, "trusted_grub", "") == "true" && Builtins.haskey(@globals, "gfxmenu") Builtins.y2milestone("Remove gfxmenu -> selected trusted grub") return true end if Ops.get(@globals, "serial") != "" && Ops.get(@globals, "serial") != nil Builtins.y2milestone("Remove gfxmenu -> defined serial console") return true end if Ops.get(@globals, "gfxmenu", "") == "none" Builtins.y2milestone("Remove gfxmenu -> disabled gfxmenu") return true end false end |
- (Object) Reset(init)
Reset bootloader settings
531 532 533 534 535 536 537 538 539 540 541 542 |
# File '../../src/modules/BootCommon.rb', line 531 def Reset(init) @sections = [] @globals = {} # DetectDisks (); @activate = false @activate_changed = false @removed_sections = [] @was_proposed = false BootStorage.ProposeDeviceMap if getLoaderType(false) == "grub" if init nil end |
- (Boolean) Save(clean, init, flush)
Save all bootloader configuration files to the cache of the PlugLib PlugLib must be initialized properly !!!
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 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 |
# File '../../src/modules/BootCommon.rb', line 617 def Save(clean, init, flush) if clean RemoveUnexistentSections("", "") UpdateAppend() UpdateGfxMenu() end ret = true bl = getLoaderType(false) InitializeLibrary(init, bl) return true if bl == "none" @globals = Builtins.remove(@globals, "gfxmenu") if removeGFXMenu # bnc#589433 - Install grub into root (/) partition gives error if Ops.get(@globals, "boot_custom") == "" && Builtins.haskey(@globals, "boot_custom") @globals = Builtins.remove(@globals, "boot_custom") end # FIXME: give mountby information to perl-Bootloader (or define some # better interface), so that perl-Bootloader can use mountby device names # for these devices instead. Tracked in bug #248162. # convert XEN section to linux section id running in domU # bnc #436899 # bnc #604401 Xen para-virtualized guest boots native kernel # I have to call it before updating of BootCommon::globals to my_globals # bnc #604401c14 ConvertXENinDomU() # convert custom boot device names in globals to the device names # indicated by "mountby" # also, for legacy bootloaders like LILO that still pass device names, # convert the stage1_dev my_globals = Builtins.mapmap(@globals) do |k, v| if k == "stage1_dev" || Builtins.regexpmatch(k, "^boot_.*custom$") next { k => BootStorage.Dev2MountByDev(v) } else next { k => v } end end # convert device names in device map to the device names indicated by # "mountby" Builtins.y2milestone( "device map before mapping %1", BootStorage.device_mapping ) my_device_mapping = Builtins.mapmap(BootStorage.device_mapping) do |k, v| { BootStorage.Dev2MountByDev(k) => v } end Builtins.y2milestone("device map after mapping %1", my_device_mapping) if VerifyMDArray() if @enable_md_array_redundancy != true && Builtins.haskey(my_globals, "boot_md_mbr") my_globals = Builtins.remove(my_globals, "boot_md_mbr") end if @enable_md_array_redundancy == true && !Builtins.haskey(my_globals, "boot_md_mbr") Ops.set(my_globals, "boot_md_mbr", BootStorage.addMDSettingsToGlobals) end else if Builtins.haskey(@globals, "boot_md_mbr") my_globals = Builtins.remove(my_globals, "boot_md_mbr") end end # add check if there is memtest and delete from memtest section # keys like append, initrd etc... checkMemtest Builtins.y2milestone("SetSecureBoot %1", @secure_boot) ret = ret && SetSecureBoot(@secure_boot) ret = ret && DefineMultipath(BootStorage.multipath_mapping) ret = ret && SetDeviceMap(my_device_mapping) ret = ret && SetSections(@sections) ret = ret && SetGlobal(my_globals) ret = ret && CommitSettings() if flush # write settings to /etc/sysconfig/bootloader WriteToSysconf(false) ret end |
- (Fixnum) Section2Index(section_name)
Search for section passed
965 966 967 968 969 970 971 972 973 974 975 976 |
# File '../../src/modules/BootCommon.rb', line 965 def Section2Index(section_name) index = -1 sectnum = -1 Builtins.foreach(@sections) do |s| index = Ops.add(index, 1) sectnum = index if Ops.get_string(s, "name", "") == section_name end Builtins.y2milestone("ret: %1", sectnum) sectnum end |
- (Object) setCurrentLoaderAttribs(loader_type)
Set attributes of specified bootloader to variable containing attributes of currently used bootloader, call its initializer
743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 |
# File '../../src/modules/BootCommon.rb', line 743 def setCurrentLoaderAttribs(loader_type) Builtins.y2milestone("Setting attributes for bootloader %1", loader_type) # testsuite hack return if Mode.test if loader_type == nil Builtins.y2error("Setting loader type to nil, this is wrong") return end # FIXME: this should be blInitializer in switcher.ycp for code cleanness # and understandability if Ops.get(@bootloader_attribs, [loader_type, "initializer"]) != nil Builtins.y2milestone("Running bootloader initializer") toEval = Convert.convert( Ops.get(@bootloader_attribs, [loader_type, "initializer"]), :from => "any", :to => "void ()" ) toEval.call Builtins.y2milestone("Initializer finished") else Builtins.y2error("No initializer found for >>%1<<", loader_type) @current_bootloader_attribs = {} end @current_bootloader_attribs = Convert.convert( Builtins.union( @current_bootloader_attribs, Builtins.eval(Ops.get(@bootloader_attribs, loader_type, {})) ), :from => "map", :to => "map <string, any>" ) nil end |
- (Object) setLoaderType(bootloader)
set type of bootloader
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 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 |
# File '../../src/modules/BootCommon.rb', line 845 def setLoaderType(bootloader) if bootloader == nil Builtins.y2milestone("Resetting the loader type") @loader_type = nil end Builtins.y2milestone("Setting bootloader to >>%1<<", bootloader) if bootloader != nil && Builtins.contains(@bootloaders, bootloader) && !Mode.test # added kexec-tools fate# 303395 # if kexec option is equal 0 or running live installation # doesn't install kexec-tools bootloader_packages = Ops.get_list( @bootloader_attribs, [bootloader, "required_packages"], [] ) if !Mode.live_installation && Linuxrc.InstallInf("kexec_reboot") != "0" bootloader_packages = Builtins.add(bootloader_packages, "kexec-tools") end # replace grub with trustedgrub if Ops.get(@globals, "trusted_grub", "") == "true" bootloader_packages.delete("grub") bootloader_packages << "trustedgrub" end # we need perl-Bootloader-YAML API to communicate with pbl bootloader_packages << "perl-Bootloader-YAML" Builtins.y2milestone("Bootloader packages: %1", bootloader_packages) # don't configure package manager during autoinstallation preparing if Mode.normal && !(Mode.config || Mode.repair) PackageSystem.InstallAll(bootloader_packages) elsif Stage.initial bootloader_packages.each do |p| Builtins.y2milestone("Select bootloader package: %1", p) PackagesProposal.AddResolvables("yast2-bootloader", :package, [p]) end end elsif !Mode.test Builtins.y2error("Unknown bootloader") end @loader_type = bootloader setCurrentLoaderAttribs(@loader_type) if @loader_type != nil Builtins.y2milestone("Loader type set") nil end |
- (Object) setSystemSecureBootStatus(enable)
915 916 917 918 919 920 921 |
# File '../../src/modules/BootCommon.rb', line 915 def setSystemSecureBootStatus(enable) Builtins.y2milestone("Set secure boot: %2 => %1", enable, @secure_boot) @location_changed = true if @secure_boot != enable # secure boot require reinstall of stage 1 @secure_boot = enable nil end |
- (Object) Summary
Display bootloader summary
707 708 709 710 711 712 713 714 715 716 717 |
# File '../../src/modules/BootCommon.rb', line 707 def Summary bl = getLoaderType(false) if bl == "none" return [ HTML.Colorize(getLoaderName(getLoaderType(false), :summary), "red") ] end # each Boot* should have own summary, that can differ raise "Not implemented for bootloader \"#{bl}\"" end |
- (String) SupportedLoader(loader)
Check whether loader with specified name is supported
783 784 785 786 |
# File '../../src/modules/BootCommon.rb', line 783 def SupportedLoader(loader) return loader if Builtins.contains(@bootloaders, loader) "none" end |
- (Object) Update
Update read settings to new version of configuration files
720 721 722 723 724 |
# File '../../src/modules/BootCommon.rb', line 720 def Update Builtins.y2debug("No generic update function available") nil end |
- (Boolean) VerifyMDArray
FATE#305008: Failover boot configurations for md arrays with redundancy Verify if proposal includes md array with 2 diferent disks
982 983 984 985 986 987 988 989 990 991 992 993 994 |
# File '../../src/modules/BootCommon.rb', line 982 def VerifyMDArray ret = false if Builtins.haskey(@globals, "boot_md_mbr") md_array = Ops.get(@globals, "boot_md_mbr", "") disks = Builtins.splitstring(md_array, ",") disks = Builtins.filter(disks) { |v| v != "" } if Builtins.size(disks) == 2 Builtins.y2milestone("boot_md_mbr includes 2 disks: %1", disks) ret = true end end ret end |
- (Boolean) Write
Write bootloader settings to disk
728 729 730 731 |
# File '../../src/modules/BootCommon.rb', line 728 def Write Builtins.y2error("No generic write function available") false end |
- (Boolean) XenPresent
FIXME 2x functions should not be finally here… Check whether XEN is selected for installation resp. selected
217 218 219 220 221 222 223 224 225 |
# File '../../src/modules/BootCommon.rb', line 217 def XenPresent ret = !Builtins.contains(@removed_sections, "xen") && (Mode.test || Mode.normal && Pkg.IsProvided("xen") && Pkg.IsProvided("kernel-xen") || !Mode.normal && Pkg.IsSelected("xen") && Pkg.IsSelected("kernel-xen")) Builtins.y2milestone("ret: %1", ret) ret end |