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) checkSecureBoot
-
- (Object) CreateLinuxSection(title)
Create section for linux kernel.
-
- (Object) Dom0MemorySize
Get the size of memory for XEN's domain 0.
-
- (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) 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...
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 705 706 707 |
# File '../../src/modules/BootCommon.rb', line 677 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) checkSecureBoot
1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 |
# File '../../src/modules/BootCommon.rb', line 1074 def checkSecureBoot ret = false sbvar = "/sys/firmware/efi/vars/SecureBoot-8be4df61-93ca-11d2-aa0d-00e098032b8c/data" sbvar_avail = 0 == Convert.to_integer( SCR.Execute(path(".target.bash"), Ops.add("test -e ", sbvar)) ) if sbvar_avail cmd = Builtins.sformat("test `od -An -N1 -t u1 %1` -eq 1", sbvar) ret = 0 == Convert.to_integer(SCR.Execute(path(".target.bash"), cmd)) end ret end |
- (Object) CreateLinuxSection(title)
Create section for linux kernel
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 439 440 441 442 443 444 445 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 |
# File '../../src/modules/BootCommon.rb', line 316 def CreateLinuxSection(title) ret = { "name" => translateSectionTitle(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) Dom0MemorySize
Get the size of memory for XEN's domain 0
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 |
# File '../../src/modules/BootCommon.rb', line 285 def Dom0MemorySize memory = Convert.convert( SCR.Read(path(".probe.memory")), :from => "any", :to => "list <map>" ) Builtins.y2milestone("memory: %1", memory) memory_size = 0 Builtins.foreach(memory) do |info| # internal class, main memory if Ops.get_integer(info, "class_id", 0) == 257 && Ops.get_integer(info, "sub_class_id", 0) == 2 minf = Ops.get_list(info, ["resource", "phys_mem"], []) Builtins.foreach(minf) do |i| memory_size = Ops.add(memory_size, Ops.get_integer(i, "range", 0)) end end end # size in kB lowered 64 MB for XEN itself memory_size = Ops.subtract(Ops.divide(memory_size, 1024), 64 * 1024) Builtins.y2milestone("Memory size for XEN domain 0: %1", memory_size) memory_size end |
- (Object) Export
Export bootloader settings to a map
509 510 511 512 513 514 515 516 517 518 519 520 521 |
# File '../../src/modules/BootCommon.rb', line 509 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, "repl_mbr", @repl_mbr) Ops.set(exp, "activate", @activate) end deep_copy(exp) end |
- (Object) getBootloaders
List bootloaders available for configured architecture
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 |
# File '../../src/modules/BootCommon.rb', line 1131 def getBootloaders if Mode.config return [ "grub", "lilo", "elilo", "zipl", "ppc", "grub2", "grub2-efi", "default", "none" ] end ret = [ getLoaderType(false), Convert.to_string(SCR.Read(path(".probe.boot_arch"))) ] if Arch.i386 || Arch.x86_64 ret = Convert.convert( Builtins.merge(ret, ["lilo", "grub", "grub2"]), :from => "list", :to => "list <string>" ) if Arch.x86_64 ret = Convert.convert( Builtins.merge(ret, ["elilo", "grub2-efi"]), :from => "list", :to => "list <string>" ) end 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
949 950 951 952 953 954 955 956 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 |
# File '../../src/modules/BootCommon.rb', line 949 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 = "zipl" if @loader_type == "s390" @loader_type = "ppc" if @loader_type == "lilo" && Arch.ppc 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 if Mode.update # FIXME: this is extremely broken, no arch specifica here !! if Arch.i386 # no sysconfig variable -> old version installed -> use LILO @loader_type = "lilo" @loader_type = SupportedLoader(@loader_type) setCurrentLoaderAttribs(@loader_type) return @loader_type end end end # detect bootloader @loader_type = Convert.to_string(SCR.Read(path(".probe.boot_arch"))) @loader_type = "zipl" 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" ) # bnc #766283 - opensuse 12.2 pv guests can not start after installation # due to lack of grub2 support in the host # fallback to use grub until grub2 really works on it @loader_type = "grub" if @loader_type == "grub2" end if (Arch.i386 || Arch.x86_64) && Linuxrc.InstallInf("EFI") == "1" # use grub2-efi as default bootloader for x86_64/i386 EFI # previously we use elilo @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)
1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 |
# File '../../src/modules/BootCommon.rb', line 1090 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 != "" @secure_boot = sb == "yes" ? true : false return @secure_boot end end @secure_boot = checkSecureBoot @secure_boot end |
- (Boolean) Import(settings)
Import settings from a map
526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 |
# File '../../src/modules/BootCommon.rb', line 526 def Import(settings) settings = deep_copy(settings) @globals = Ops.get_map(settings, "global", {}) @sections = Ops.get_list(settings, "sections", []) # FIXME: for grub, repl_mbr is replaced by globals["generic_mbr"]; same # for activate; remove the following when no bootloader uses these # variables any more if !(@loader_type == "grub" || @loader_type == "grub2") @repl_mbr = Ops.get_boolean(settings, "repl_mbr", false) @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
266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 |
# File '../../src/modules/BootCommon.rb', line 266 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 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 |
# 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 section options and types for new perl-Bootloader interface @section_options = {} # boolean value indicate if "/" is on logical # and primary /boot doesn't exist @boot_device_on_logical = false # 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 = {} # Option types for different bootloaders @opt_types = {} # device holding MBR for bootloader @mbrDisk = "" # was currently edited section changed (== true) @one_section_changed = false # Backup original MBR before installing bootloader @backup_mbr = false # Activate bootloader partition during installation? @activate = false # FATE #303548 - Grub: limit device.map to devices detected by BIOS # Ask user if he wants to edit again bootloader settings # It is used if device.map is limited and "boot" disk is out of range # The range is the first 8 devices @ask_user = false # Replace MBR with generic code after bootloader installation? @repl_mbr = false # Kernel parameters at previous detection @kernelCmdLine = "" # were settings changed (== true) @changed = false @installed_version = {} @update_version = {} @edited_files = {} # common variables # type of bootloader to configure/being configured # shall be one of "lilo", "grub", "elilo", "ppc", "zipl", "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 # Show verbose summary output @verbose = false # 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 # Has been files edited warning already shown? @files_edited_warned = 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 = [ "lilo", "grub", "elilo", "zipl", "ppc", "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) Propose
Propose bootloader settings
643 644 645 646 647 |
# File '../../src/modules/BootCommon.rb', line 643 def Propose Builtins.y2error("No generic propose function available") nil end |
- (Boolean) Read(reread, avoid_reading_device_map)
Read settings from disk internal data
547 548 549 550 551 552 553 554 555 556 557 558 559 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 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 |
# File '../../src/modules/BootCommon.rb', line 547 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| # if we update from version 9 (SLES9), first convert old-style persistent # device names to new-style persistent device names ("p1" -> "-part1") # NOTE: this is idempotent; but other device name translation # (e.g. libata migration) is not, so it will be done later if Mode.update && Ops.get_integer(@installed_version, "major", 0) == 9 k = Storage.SLES9PersistentDevNames(k) Builtins.y2milestone( "devmap: dev name after SLES9 persistent dev name translation: %1", k ) end { 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$") # see comments above if Mode.update && Ops.get_integer(@installed_version, "major", 0) == 9 v = Storage.SLES9PersistentDevNames(v) Builtins.y2milestone( "globals: dev name after SLES9 persistent dev name translation: %1", v ) end 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", "") # see comments above if Mode.update && Ops.get_integer(@installed_version, "major", 0) == 9 rdev = Storage.SLES9PersistentDevNames(rdev) Builtins.y2milestone( "sections: dev name after SLES9 persistent dev name translation: %1", rdev ) end # 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
654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 |
# File '../../src/modules/BootCommon.rb', line 654 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
628 629 630 631 632 633 634 635 636 637 638 639 640 |
# File '../../src/modules/BootCommon.rb', line 628 def Reset(init) @sections = [] @globals = {} # DetectDisks (); @repl_mbr = false @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 !!!
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 759 760 761 762 763 764 765 766 767 768 769 770 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 |
# File '../../src/modules/BootCommon.rb', line 715 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
1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 |
# File '../../src/modules/BootCommon.rb', line 1173 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
901 902 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 |
# File '../../src/modules/BootCommon.rb', line 901 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
1019 1020 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 |
# File '../../src/modules/BootCommon.rb', line 1019 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" if Builtins.contains(bootloader_packages, "grub") bootloader_packages = Builtins.filter(bootloader_packages) do |key| key != "grub" end end bootloader_packages = Builtins.add(bootloader_packages, "trustedgrub") end 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 pkg_added = false Builtins.foreach(bootloader_packages) do |p| Builtins.y2milestone("Select bootloader package: %1", p) PackagesProposal.AddResolvables("yast2-bootloader", :package, [p]) pkg_added = true 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)
1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 |
# File '../../src/modules/BootCommon.rb', line 1108 def setSystemSecureBootStatus(enable) # if (enable && enable != secure_boot) # { # // don't configure package manager during autoinstallation preparing # if (Mode::normal () && (! (Mode::config () || Mode::repair ()))) # { # y2milestone ("Install shim"); # PackageSystem::InstallAll (["shim"]); # } # else if (Stage::initial () ) # { # y2milestone ("AddResolvables shim"); # PackagesProposal::AddResolvables ("yast2-bootloader", `package, ["shim"]); # } # } Builtins.y2milestone("Set secure boot: %2 => %1", enable, @secure_boot) @secure_boot = enable nil end |
- (Object) Summary
Display bootloader summary
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 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 871 872 873 874 875 |
# File '../../src/modules/BootCommon.rb', line 805 def Summary if getLoaderType(false) == "none" return [ HTML.Colorize(getLoaderName(getLoaderType(false), :summary), "red") ] end targetMap = Storage.GetTargetMap boot_target = Ops.get_map(targetMap, @loader_device, {}) target_name = "" if boot_target == {} target_name = @loader_device if target_name == "mbr_md" mbrs = Builtins.maplist( Md2Partitions(BootStorage.BootPartitionDevice) ) do |d, id| p_dev = Storage.GetDiskPartition(d) Ops.get_string(p_dev, "disk", "") end # summary part, %1 is a list of device names target_name = Builtins.sformat( _("Master boot records of disks %1"), Builtins.mergestring(mbrs, ", ") ) end else target_name = Ops.get_string(boot_target, "name", "disk") end target_name = AddMbrToDescription(target_name, @loader_device) result = [] # summary text, %1 is bootloader name (eg. LILO) result = Builtins.add( result, Builtins.sformat( _("Boot Loader Type: %1"), getLoaderName(getLoaderType(false), :summary) ) ) # summary text, location is location description (eg. /dev/hda) result = Builtins.add( result, Builtins.sformat(_("Location: %1"), target_name) ) sects = [] Builtins.foreach(@sections) do |s| title = Ops.get_string(s, "name", "") # section name "suffix" for default section _def = title == Ops.get(@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>") ) ) if @loader_device == "/dev/null" # summary text result = Builtins.add( result, _("Do not install boot loader; just create \nconfiguration files") ) end deep_copy(result) end |
- (String) SupportedLoader(loader)
Check whether loader with specified name is supported
941 942 943 944 |
# File '../../src/modules/BootCommon.rb', line 941 def SupportedLoader(loader) return loader if Builtins.contains(@bootloaders, loader) "none" end |
- (Object) Update
Update read settings to new version of configuration files
878 879 880 881 882 |
# File '../../src/modules/BootCommon.rb', line 878 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
1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 |
# File '../../src/modules/BootCommon.rb', line 1190 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
886 887 888 889 |
# File '../../src/modules/BootCommon.rb', line 886 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
251 252 253 254 255 256 257 258 259 |
# File '../../src/modules/BootCommon.rb', line 251 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 |