Module: Yast::BootloaderRoutinesMiscInclude
- Defined in:
- src/include/bootloader/routines/misc.rb
Instance Method Summary (collapse)
-
- (Boolean) BootloaderInstallable
Check if the bootloader can be installed at all with current configuration.
-
- (String) buildConsoleValue(unit, speed, parity, word)
FATE #110038: Serial console Function build value for console from:.
-
- (Boolean) CreateBLSysconfigFile(inst)
bnc#511319 Add information about /etc/sysconfig/bootloader to configuration file.
-
- (Object) GetAdditionalFailsafeParams
Get additional kernel parameters.
-
- (Object) getAnyTypeAttrib(attrib, defaultv)
Get value of specified bootloader attribute.
-
- (Boolean) getBooleanAttrib(attrib)
Get value of specified boolean bootloader attribute.
-
- (String) getBootDisk
FATE #303548 - Grub: limit device.map to devices detected by BIOS Int 13 Function select boot device - disk.
-
- (String) GetBootloaderDevice
Get bootloader device for specified location FIXME: this function is being phased out.
-
- (Array) GetBootloaderDevices
Get list of bootloader device names for all selected or specified locations.
-
- (String) getBootPartition
Function return boot device it means return boot partition or root partition if boot partition deosn't exist function return “” if boot partition or root partition is not defined (autoyast).
-
- (String) getConsoleValue
FATE #110038: Serial console Function check value from globals (serial and terminal) after that build value of console append for kernel if it is possible.
-
- (String) getKernelParamFromLine(line, key)
get kernel parameter from kernel command line.
- - (Object) getKeyValue(key)
-
- (String) getLoaderName(bootloader, mode)
return printable name of bootloader.
-
- (Object) getMbrsToRewrite
Get the list of MBR disks that should be rewritten by generic code if user wants to do so.
-
- (Object) getPartitionsToActivate
Get a list of partitions to activate if user wants to activate boot partition.
-
- (Object) getPartitionToActivate(boot_partition, loader_device)
Get partition which should be activated if doing it during bl inst.
-
- (Object) GetSerialFromAppend
This function gets bootloader's serial settings from append (bnc#862388).
-
- (Object) getSwapPartitions
Get map of swap partitions.
-
- (Object) HandleConsole2
FATE #110038: Serial console Add console arg for kernel if there is defined serial console.
- - (Object) initialize_bootloader_routines_misc(include_target)
- - (Object) kernel_param_key(value)
-
- (Object) myToInteger(num_any)
convert any value to an integer and return 0 for nonsense.
-
- (Boolean) PartitionInstallable
Check if the bootloader can be installed on partition boot record.
-
- (Hash{String => String}) remapGlobals(globals_set)
Function remap globals settings “boot_custom” device name (/dev/sda) or to label (ufo_partition).
-
- (Boolean) restoreMBR(device)
Rewrite current MBR with /var/lib/YaST2/backup_boot_sectors/%device Warning!!! don't use for bootsectors, 440 bytes of sector are written.
-
- (String) setKernelParamToLine(line, key, value)
set kernel parameter to GRUB command line.
-
- (Object) UpdateInstallationKernelParameters
Update the Kernel::vgaType value to the saved one if not defined.
-
- (Object) WriteOptionToSysconfig(inst, file_path, option, value, comment)
bnc#511319 Add information about /etc/sysconfig/bootloader to configuration file.
-
- (Object) WriteToSysconf(inst_bootloader)
FATE #302245 save kernel args etc to /etc/sysconfig/bootloader Function write/update info in /etc/sysconfig/bootloader.
Instance Method Details
- (Boolean) BootloaderInstallable
Check if the bootloader can be installed at all with current configuration
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 |
# File 'src/include/bootloader/routines/misc.rb', line 445 def BootloaderInstallable return true if Mode.config if Arch.i386 || Arch.x86_64 # the only relevant is the partition holding the /boot filesystem DetectDisks() Builtins.y2milestone( "Boot partition device: %1", BootStorage.BootPartitionDevice ) dev = Storage.GetDiskPartition(BootStorage.BootPartitionDevice) Builtins.y2milestone("Disk info: %1", dev) # MD, but not mirroring is OK # FIXME: type detection by name deprecated if Ops.get_string(dev, "disk", "") == "/dev/md" tm = Storage.GetTargetMap md = Ops.get_map(tm, "/dev/md", {}) parts = Ops.get_list(md, "partitions", []) info = {} Builtins.foreach(parts) do |p| if Ops.get_string(p, "device", "") == BootStorage.BootPartitionDevice info = deep_copy(p) end end if Builtins.tolower(Ops.get_string(info, "raid_type", "")) != "raid1" Builtins.y2milestone( "Cannot install bootloader on RAID (not mirror)" ) return false end # EVMS # FIXME: type detection by name deprecated elsif Builtins.search(getBootPartition, "/dev/evms/") == 0 Builtins.y2milestone("Cannot install bootloader on EVMS") return false end return true else return true end end |
- (String) buildConsoleValue(unit, speed, parity, word)
FATE #110038: Serial console Function build value for console from:
692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 |
# File 'src/include/bootloader/routines/misc.rb', line 692 def buildConsoleValue(unit, speed, parity, word) ret = "" if unit != "" && speed != "" # add number of serial console ret = Ops.add("ttyS", unit) # add speed ret = Ops.add(Ops.add(ret, ","), speed) if parity != "" # add parity case parity when "no" ret = Ops.add(ret, "n") when "odd" ret = Ops.add(ret, "o") when "even" ret = Ops.add(ret, "e") else ret = Ops.add(ret, "n") end # add word ret = Ops.add(ret, word) if word != "" end Builtins.y2milestone("console value for kernel: %1", ret) else Builtins.y2error( "Wrong values unit: %1 , speed: %2 , parity: %3 , word: %4", unit, speed, parity, word ) end ret end |
- (Boolean) CreateBLSysconfigFile(inst)
bnc#511319 Add information about /etc/sysconfig/bootloader to configuration file. Create /etc/sysconfig/bootloader it is configuration file for bootloader
552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 |
# File 'src/include/bootloader/routines/misc.rb', line 552 def CreateBLSysconfigFile(inst) if inst if !FileUtils.Exists(Ops.add(Installation.destdir, "/etc/sysconfig")) WFM.Execute( path(".local.mkdir"), Ops.add(Installation.destdir, "/etc/sysconfig") ) WFM.Execute( path(".local.bash"), Builtins.sformat( "touch %1/etc/sysconfig/bootloader", Installation.destdir ) ) end #string target_sysconfig_path = Installation::destdir + "/etc/sysconfig/bootloader"; return true end true end |
- (Object) GetAdditionalFailsafeParams
Get additional kernel parameters
423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 |
# File 'src/include/bootloader/routines/misc.rb', line 423 def GetAdditionalFailsafeParams if Stage.initial @additional_failsafe_params = SCR.Read( path(".etc.install_inf.NoPCMCIA") ) == "1" ? " NOPCMCIA " : "" else saved_params = Convert.convert( SCR.Read(path(".target.ycp"), "/var/lib/YaST2/bootloader.ycp"), :from => "any", :to => "map <string, any>" ) @additional_failsafe_params = Ops.get_string( saved_params, "additional_failsafe_params", "" ) end @additional_failsafe_params end |
- (Object) getAnyTypeAttrib(attrib, defaultv)
Get value of specified bootloader attribute
86 87 88 89 |
# File 'src/include/bootloader/routines/misc.rb', line 86 def getAnyTypeAttrib(attrib, defaultv) defaultv = deep_copy(defaultv) Ops.get(@current_bootloader_attribs, attrib, defaultv) end |
- (Boolean) getBooleanAttrib(attrib)
Get value of specified boolean bootloader attribute
78 79 80 |
# File 'src/include/bootloader/routines/misc.rb', line 78 def getBooleanAttrib(attrib) Ops.get_boolean(@current_bootloader_attribs, attrib, false) end |
- (String) getBootDisk
FATE #303548 - Grub: limit device.map to devices detected by BIOS Int 13 Function select boot device - disk
663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 |
# File 'src/include/bootloader/routines/misc.rb', line 663 def getBootDisk boot_device = getBootPartition if boot_device == "" Builtins.y2milestone( "BootPartitionDevice and RootPartitionDevice are empty" ) return boot_device end p_dev = Storage.GetDiskPartition(boot_device) boot_disk_device = Ops.get_string(p_dev, "disk", "") if boot_disk_device != "" && boot_disk_device != nil Builtins.y2milestone("Boot device - disk: %1", boot_disk_device) return boot_disk_device end Builtins.y2milestone("Finding boot disk failed!") "" end |
- (String) GetBootloaderDevice
Get bootloader device for specified location FIXME: this function is being phased out. Keeping it around until selected_location and loader_device can be dropped for all bootloader types.
119 120 121 122 123 124 125 126 |
# File 'src/include/bootloader/routines/misc.rb', line 119 def GetBootloaderDevice return @mbrDisk if @selected_location == "mbr" return BootStorage.BootPartitionDevice if @selected_location == "boot" return BootStorage.RootPartitionDevice if @selected_location == "root" return "mbr_md" if @selected_location == "mbr_md" return "/dev/null" if @selected_location == "none" @loader_device end |
- (Array) GetBootloaderDevices
Get list of bootloader device names for all selected or specified locations
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
# File 'src/include/bootloader/routines/misc.rb', line 131 def GetBootloaderDevices ret = [] if @globals["boot_boot"] == "true" ret << BootStorage.BootPartitionDevice end if @globals["boot_root"] == "true" ret << BootStorage.RootPartitionDevice end if @globals["boot_mbr"] == "true" ret << @mbrDisk end if @globals["boot_extended"] == "true" ret << BootStorage.ExtendedPartitionDevice end if @globals["boot_custom"] ret << @globals["boot_custom"] end return ret unless ret.empty? # FIXME: find out what the best value is here: nil, [] or ["/dev/null"] ["/dev/null"] end |
- (String) getBootPartition
Function return boot device it means return boot partition or root partition if boot partition deosn't exist function return “” if boot partition or root partition is not defined (autoyast)
647 648 649 650 651 652 653 654 655 656 |
# File 'src/include/bootloader/routines/misc.rb', line 647 def getBootPartition boot_device = "" if BootStorage.BootPartitionDevice != "" boot_device = BootStorage.BootPartitionDevice elsif BootStorage.RootPartitionDevice != "" boot_device = BootStorage.RootPartitionDevice end boot_device end |
- (String) getConsoleValue
FATE #110038: Serial console Function check value from globals (serial and terminal) after that build value of console append for kernel if it is possible
754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 |
# File 'src/include/bootloader/routines/misc.rb', line 754 def getConsoleValue ret = "" if Ops.get(@globals, "serial", "") != "" && Ops.get(@globals, "terminal", "") != "" list_serial = Builtins.splitstring(Ops.get(@globals, "serial", ""), " ") Builtins.y2milestone("list of serial args: %1", list_serial) unit = "" speed = "" parity = "" word = "" Builtins.foreach(list_serial) do |key| unit = getKeyValue(key) if Builtins.search(key, "--unit") != nil speed = getKeyValue(key) if Builtins.search(key, "--speed") != nil parity = getKeyValue(key) if Builtins.search(key, "--parity") != nil word = getKeyValue(key) if Builtins.search(key, "--word") != nil end # build value ret = buildConsoleValue(unit, speed, parity, word) end ret end |
- (String) getKernelParamFromLine(line, key)
get kernel parameter from kernel command line
158 159 160 161 162 163 164 165 166 167 168 169 |
# File 'src/include/bootloader/routines/misc.rb', line 158 def getKernelParamFromLine(line, key) # FIXME this doesn't work with quotes and spaces res = "false" # we can get nil if params is not yet proposed, so return not there (bnc#902397) return res unless line params = line.split(" ").reject(&:empty?) params.each do |p| l = p.split("=") res = l[1] || "true" if l[0] == key end res end |
- (Object) getKeyValue(key)
736 737 738 739 740 741 742 743 744 745 746 |
# File 'src/include/bootloader/routines/misc.rb', line 736 def getKeyValue(key) ret = "" value = [] if key != "" value = Builtins.splitstring(key, "=") ret = Ops.get(value, 1, "") if Ops.get(value, 1, "") != "" end Builtins.y2debug("parse: %1 and return value: %2", key, ret) ret end |
- (String) getLoaderName(bootloader, mode)
return printable name of bootloader
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 |
# File 'src/include/bootloader/routines/misc.rb', line 47 def getLoaderName(bootloader, mode) if bootloader == "none" return mode == :summary ? # summary string _("Do not install any boot loader") : # combo box item _("Do Not Install Any Boot Loader") end if bootloader == "default" return mode == :summary ? # summary string _("Install the default boot loader") : # combo box item _("Install Default Boot Loader") end fallback_name = mode == :summary ? # summary string _("Boot loader") : # combo box item _("Boot Loader") # fallback bootloader name, keep short Ops.get_string( @bootloader_attribs, [bootloader, "loader_name"], fallback_name ) end |
- (Object) getMbrsToRewrite
Get the list of MBR disks that should be rewritten by generic code if user wants to do so
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 |
# File 'src/include/bootloader/routines/misc.rb', line 326 def getMbrsToRewrite ret = [@mbrDisk] md = {} if @loader_device == "mbr_md" md = Md2Partitions(BootStorage.BootPartitionDevice) else md = Md2Partitions(@loader_device) end mbrs = Builtins.maplist(md) do |d, b| d = Ops.get_string( getPartitionToActivate(BootStorage.BootPartitionDevice, d), "mbr", @mbrDisk ) d end if Builtins.contains(mbrs, @mbrDisk) ret = Convert.convert( Builtins.merge(ret, mbrs), :from => "list", :to => "list <string>" ) end Builtins.toset(ret) end |
- (Object) getPartitionsToActivate
Get a list of partitions to activate if user wants to activate boot partition
308 309 310 311 312 313 314 315 316 317 318 319 320 321 |
# File 'src/include/bootloader/routines/misc.rb', line 308 def getPartitionsToActivate md = {} if @loader_device == "mbr_md" md = Md2Partitions(BootStorage.BootPartitionDevice) else md = Md2Partitions(@loader_device) end partitions = Builtins.maplist(md) { |k, v| k } partitions = [@loader_device] if Builtins.size(partitions) == 0 ret = Builtins.maplist(partitions) do |partition| getPartitionToActivate(BootStorage.BootPartitionDevice, partition) end Builtins.toset(ret) end |
- (Object) getPartitionToActivate(boot_partition, loader_device)
Get partition which should be activated if doing it during bl inst.
245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 |
# File 'src/include/bootloader/routines/misc.rb', line 245 def getPartitionToActivate(boot_partition, loader_device) p_dev = Storage.GetDiskPartition(loader_device) num = myToInteger(Ops.get(p_dev, "nr")) mbr_dev = Ops.get_string(p_dev, "disk", "") # if bootloader is installed to /dev/md* # FIXME: use ::storage to detect md devices, not by name! if Builtins.substring(loader_device, 0, 7) == "/dev/md" md = Md2Partitions(loader_device) min = 256 # max. is 255; 256 means "no bios_id found" device = "" Builtins.foreach(md) do |d, id| if Ops.less_than(id, min) min = id device = d end end if device != "" p_dev2 = Storage.GetDiskPartition(device) num = myToInteger(Ops.get(p_dev2, "nr")) mbr_dev = Ops.get_string(p_dev2, "disk", "") end # if bootloader in MBR, activate /boot partition # (partiall fix of #20637) elsif num == 0 p_dev = Storage.GetDiskPartition(boot_partition) num = myToInteger(Ops.get(p_dev, "nr")) mbr_dev = Ops.get_string(p_dev, "disk", "") if Ops.greater_than(Builtins.size(Md2Partitions(boot_partition)), 1) Builtins.foreach(Md2Partitions(boot_partition)) do |k, v| if Builtins.search(k, loader_device) == 0 p_dev = Storage.GetDiskPartition(k) num = myToInteger(Ops.get(p_dev, "nr")) mbr_dev = Ops.get_string(p_dev, "disk", "") end end end end if num != 0 if Ops.greater_than(num, 4) Builtins.y2milestone("Bootloader partition type is logical") tm = Storage.GetTargetMap partitions = Ops.get_list(tm, [mbr_dev, "partitions"], []) Builtins.foreach(partitions) do |p| if Ops.get(p, "type") == :extended num = Ops.get_integer(p, "nr", num) Builtins.y2milestone("Using extended partition %1 instead", num) end end end end ret = { "num" => num, "mbr" => mbr_dev, "dev" => Storage.GetDeviceName(mbr_dev, num) } deep_copy(ret) end |
- (Object) GetSerialFromAppend
This function gets bootloader's serial settings from append (bnc#862388)
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 |
# File 'src/include/bootloader/routines/misc.rb', line 778 def GetSerialFromAppend () append = @globals["append"] || "" type = Builtins.regexpsub(append, "^.*console=([[:alpha:]]+)[[:digit:]]*,*[[:digit:]]*[noe]*[[:digit:]]*.*[[:space:]]*.*$", "\\1") args = Builtins.regexpsub(append, "^.*console=[[:alpha:]]+([[:digit:]]*,*[[:digit:]]*[noe]*[[:digit:]]*).*[[:space:]]*.*$", "\\1") Builtins.y2milestone("BuildSerialFromAppend: %1, %2", type, args) return "" if type != "ttyS" || args.empty? unit = Builtins.regexpsub(args, "([[:digit:]]+),*[[:digit:]]*[noe]*[[:digit:]]*", "\\1") return "" if unit == "" ret = "serial --unit=#{unit}" speed = Builtins.regexpsub(args, "[[:digit:]]+,*([[:digit:]]*)[noe]*[[:digit:]]*", "\\1") speed = "9600" if speed.empty? ret << " --speed=#{speed}" parity = Builtins.regexpsub(args, "[[:digit:]]+,*[[:digit:]]*([noe]*)[[:digit:]]*", "\\1") case parity when "n" ret << " --parity=no" when "o" ret << " --parity=odd" when "e" ret << " --parity=even" when "" # no parity, do nothing else raise "unknown parity flag #{parity}" end word = Builtins.regexpsub(args, "[[:digit:]]+,*[[:digit:]]*[noe]*([[:digit:]]*)", "\\1") if !word.empty? ret << " --word=#{word}" end ret end |
- (Object) getSwapPartitions
Get map of swap partitions
368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 |
# File 'src/include/bootloader/routines/misc.rb', line 368 def getSwapPartitions # FIXME move to boot storage tm = Storage.GetTargetMap ret = {} tm.each do |k, v| cyl_size = v["cyl_size"] || 0 partitions = v["partitions"] || [] partitions = partitions.select do |p| p["mount"] == "swap" && !p["delete"] end partitions.each do |s| # bnc#577127 - Encrypted swap is not properly set up as resume device if s["crypt_device"] && !s["crypt_device"].empty? dev = s["crypt_device"] else dev = s["device"] end ret[dev] = Ops.get_integer(s, ["region", 1], 0) * cyl_size end end Builtins.y2milestone("Available swap partitions: %1", ret) ret end |
- (Object) HandleConsole2
FATE #110038: Serial console Add console arg for kernel if there is defined serial console
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 |
# File 'src/include/bootloader/routines/misc.rb', line 820 def HandleConsole2 if @globals["terminal"] != "serial" # if bootloader is not set to serial console, we should leave the # kernel append as is to allow it's serial console be enabled # for debugging output and so on (bnc#866710) return end if !@globals["serial"] || @globals["serial"].empty? # http://www.gnu.org/software/grub/manual/grub.html#serial # https://www.kernel.org/doc/Documentation/serial-console.txt # default settings is the same, we should at least tell kernel the # port (aka unit) to use and grub2 defaults to 0. # speed is also required by builkConsoleValue @globals["serial"] = "serial --unit=0 --speed=9600" end console_value = getConsoleValue if Ops.get(@globals, "append") != nil updated_append = "" if console_value != "" || console_value != nil updated_append = UpdateSerialConsole( Ops.get(@globals, "append", ""), console_value ) else updated_append = UpdateSerialConsole( Ops.get(@globals, "append", ""), "" ) end Ops.set(@globals, "append", updated_append) if updated_append != nil end nil end |
- (Object) initialize_bootloader_routines_misc(include_target)
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'src/include/bootloader/routines/misc.rb', line 26 def initialize_bootloader_routines_misc(include_target) textdomain "bootloader" Yast.import "Mode" Yast.import "Stage" Yast.import "Storage" Yast.import "StorageDevices" Yast.import "Report" Yast.import "Kernel" Yast.import "Misc" Yast.import "ProductFeatures" Yast.import "Directory" Yast.import "Installation" Yast.import "FileUtils" Yast.import "String" end |
- (Object) kernel_param_key(value)
172 173 174 |
# File 'src/include/bootloader/routines/misc.rb', line 172 def kernel_param_key(value) value.split("=").first end |
- (Object) myToInteger(num_any)
convert any value to an integer and return 0 for nonsense
224 225 226 227 228 229 230 231 232 233 234 235 236 |
# File 'src/include/bootloader/routines/misc.rb', line 224 def myToInteger(num_any) num_any = deep_copy(num_any) return 0 if num_any == nil return Convert.to_integer(num_any) if Ops.is_integer?(num_any) if Ops.is_string?(num_any) return num_any == "" ? 0 : Builtins.tointeger(Convert.to_string(num_any)) == nil ? 0 : Builtins.tointeger(Convert.to_string(num_any)) end 0 end |
- (Boolean) PartitionInstallable
Check if the bootloader can be installed on partition boot record
491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 |
# File 'src/include/bootloader/routines/misc.rb', line 491 def PartitionInstallable lt = getLoaderType(false) return true if lt != "grub2" && lt != "grub2-efi" if Arch.i386 || Arch.x86_64 DetectDisks() dev = Storage.GetDiskPartition(BootStorage.BootPartitionDevice) Builtins.y2milestone("Disk info: %1", dev) if Ops.get_string(dev, "disk", "") == "/dev/md" return false elsif !Ops.is_integer?(Ops.get(dev, "nr", 0)) return false end end true end |
- (Hash{String => String}) remapGlobals(globals_set)
Function remap globals settings “boot_custom” device name (/dev/sda) or to label (ufo_partition)
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'src/include/bootloader/routines/misc.rb', line 98 def remapGlobals(globals_set) globals_set = deep_copy(globals_set) if Arch.ppc by_mount = :id else by_mount = Storage.GetDefaultMountBy end return globals_set if by_mount == :label globals_set["boot_custom"] &&= ::Bootloader::DeviceMapping.to_kernel_device(globals_set["boot_custom"]) globals_set end |
- (Boolean) restoreMBR(device)
Rewrite current MBR with /var/lib/YaST2/backup_boot_sectors/%device Warning!!! don't use for bootsectors, 440 bytes of sector are written
356 357 358 359 360 361 362 363 364 |
# File 'src/include/bootloader/routines/misc.rb', line 356 def restoreMBR(device) backup = ::Bootloader::BootRecordBackup.new(device) begin backup.restore rescue ::Bootloader::BootRecordBackup::Missing Report.Error("Can't restore MBR. No saved MBR found") return false end end |
- (String) setKernelParamToLine(line, key, value)
set kernel parameter to GRUB command line
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 |
# File 'src/include/bootloader/routines/misc.rb', line 182 def setKernelParamToLine(line, key, value) line ||= "" # FIXME this doesn't work with quotes and spaces params = line.split(" ").reject(&:empty?) # count occurences of every parameter, initial value is 0 occurences = Hash.new { |k| 0 } params.each do |param| k = kernel_param_key(param) occurences[k] += 1 end done = false params = params.reduce([]) do |res, param| k = kernel_param_key(param) if k != key # not our param res << param elsif value == "false" # do nothing as we want to remove this param elsif occurences[k] == 1 # last parameter with given key done = true if value == "true" res << key elsif value != "false" res << Builtins.sformat("%1=%2", key, value) end else occurences[k] -= 1 res << param end res end if !done if value == "true" params << key elsif value != "false" params << Builtins.sformat("%1=%2", key, value) end end params.join(" ") end |
- (Object) UpdateInstallationKernelParameters
Update the Kernel::vgaType value to the saved one if not defined
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 |
# File 'src/include/bootloader/routines/misc.rb', line 395 def UpdateInstallationKernelParameters saved_params = {} if !Stage.initial saved_params = Convert.convert( SCR.Read(path(".target.ycp"), "/var/lib/YaST2/bootloader.ycp"), :from => "any", :to => "map <string, any>" ) end if Kernel.GetVgaType == "" vgaType = Ops.get_string(saved_params, "vgamode", "") Kernel.SetVgaType(vgaType) if vgaType != nil && vgaType != "" end if !Stage.initial Kernel.SetCmdLine( Ops.get_string(saved_params, "installation_kernel_params", "") ) else if SCR.Read(path(".etc.install_inf.NoPCMCIA")) == "1" Kernel.SetCmdLine(Ops.add(Kernel.GetCmdLine, " NOPCMCIA")) end end nil end |
- (Object) WriteOptionToSysconfig(inst, file_path, option, value, comment)
bnc#511319 Add information about /etc/sysconfig/bootloader to configuration file. Write option with value and comment to sysconfig file
521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 |
# File 'src/include/bootloader/routines/misc.rb', line 521 def WriteOptionToSysconfig(inst, file_path, option, value, comment) ret = false if !inst && !FileUtils.Exists("/etc/sysconfig/bootloader") Builtins.y2milestone( "Skip writting configuration to /etc/sysconfig/bootloader -> file missing" ) return ret end file_path_option = Builtins.add(file_path, option) comment_exist = SCR.Read(Builtins.add(file_path_option, path(".comment"))) == nil # write value of option ret = SCR.Write(file_path_option, value) # write comment of option if it is necessary if !comment_exist ret = ret && SCR.Write(Builtins.add(file_path_option, path(".comment")), comment) end SCR.Write(file_path, nil) ret end |
- (Object) WriteToSysconf(inst_bootloader)
FATE #302245 save kernel args etc to /etc/sysconfig/bootloader Function write/update info in /etc/sysconfig/bootloader
577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 |
# File 'src/include/bootloader/routines/misc.rb', line 577 def WriteToSysconf(inst_bootloader) lt = getLoaderType(false) Builtins.y2milestone("Saving /etc/sysconfig/bootloader for %1", lt) # save some sysconfig variables # register new agent pointing into the mounted filesystem sys_agent = path(".sysconfig.bootloader") if inst_bootloader sys_agent = Builtins.add(path(".target"), sys_agent) target_sysconfig_path = Ops.add( Installation.destdir, "/etc/sysconfig/bootloader" ) SCR.RegisterAgent( sys_agent, term(:ag_ini, term(:SysConfigFile, target_sysconfig_path)) ) end CreateBLSysconfigFile(inst_bootloader) comment = "" comment = "\n" + "## Path:\tSystem/Bootloader\n" + "## Description:\tBootloader configuration\n" + "## Type:\tlist(grub,grub2,grub2-efi,none)\n" + "## Default:\tgrub2\n" + "#\n" + "# Type of bootloader in use.\n" + "# For making the change effect run bootloader configuration tool\n" + "# and configure newly selected bootloader\n" + "#\n" + "#\n" WriteOptionToSysconfig( inst_bootloader, sys_agent, path(".LOADER_TYPE"), lt, comment ) comment = "\n" + "## Path:\tSystem/Bootloader\n" + "## Description:\tBootloader configuration\n" + "## Type:\tyesno\n" + "## Default:\t\"no\"\n" + "#\n" + "# Enable UEFI Secure Boot support\n" + "# This setting is only relevant to UEFI which supports UEFI. It won't\n" + "# take effect on any other firmware type.\n" + "#\n" + "#\n" sb = getSystemSecureBootStatus(false) ? "yes" : "no" WriteOptionToSysconfig( inst_bootloader, sys_agent, path(".SECURE_BOOT"), sb, comment ) nil end |