Class: Yast::KernelClass
- Inherits:
-
Module
- Object
- Module
- Yast::KernelClass
- Defined in:
- ../../src/modules/Kernel.rb
Instance Method Summary (collapse)
-
- (Object) AddCmdLine(name, arg)
AddCmdLine () add “name=args” to kernel boot parameters add just “name” if args = “”.
-
- (Object) AddModuleToLoad(name)
Add a kernel module to the list of modules to load after boot add the module name to sysconfig variable.
-
- (String) ComputePackage
Compute kernel package.
-
- (Array) ComputePackages
Compute kernel packages.
-
- (Object) ComputePackagesForBase(base, check_avail)
Compute kernel package for the specified base kernel package.
-
- (void) ExtractCmdlineParameters(line)
Filters out yast2 specific boot parameters and sets Parameters to the important cmdline parts.
-
- (String) GetBinary
Het the name of kernel binary under /boot.
-
- (String) GetCmdLine
Get the kernel command line.
- - (Object) GetFinalKernel
-
- (Object) GetInformAboutKernelChange
Get inform_about_kernel_change.
-
- (Object) GetPackages
Get the list of kernel packages.
-
- (Boolean) GetSuSEUpdate
Check if suse_update kernel command line argument was passed.
-
- (String) GetVgaType
Get the vga= kernel parameter.
-
- (String) HidePasswords(_in)
Hide passwords in command line option string.
-
- (Object) InformAboutKernelChange
Display popup about new kernel that was installed.
-
- (Object) IsGraphicalDesktop
Simple check any graphical desktop was selected.
- - (Object) main
- - (Object) ParseInstallationKernelCmdline
-
- (void) ProbeKernel
select kernel depending on architecture and system type.
-
- (Object) RemoveModuleToLoad(name)
Remove a kernel module from the list of modules to load after boot.
-
- (Boolean) SaveModulesToLoad
SaveModuleToLoad () save the sysconfig variable to the file.
-
- (Object) SetCmdLine(new_cmd_line)
Set the kernel command line FIXME is heer because of bootloader module, should be removed.
-
- (Object) SetInformAboutKernelChange(b)
Set inform_about_kernel_change.
-
- (Object) SetPackages(custom_kernels)
Set a custom kernel.
-
- (Object) SetVgaType(new_vga)
Set the vga= kernel argument FIXME is heer because of bootloader module, should be removed.
Instance Method Details
- (Object) AddCmdLine(name, arg)
AddCmdLine () add "name=args" to kernel boot parameters add just "name" if args = ""
148 149 150 151 152 153 154 |
# File '../../src/modules/Kernel.rb', line 148 def AddCmdLine(name, arg) ParseInstallationKernelCmdline() if !@cmdline_parsed @cmdLine = Ops.add(Ops.add(@cmdLine, " "), name) @cmdLine = Ops.add(Ops.add(@cmdLine, "="), arg) if arg != "" Builtins.y2milestone("cmdLine '%1'", HidePasswords(@cmdLine)) nil end |
- (Object) AddModuleToLoad(name)
Add a kernel module to the list of modules to load after boot add the module name to sysconfig variable
553 554 555 556 557 558 559 560 561 |
# File '../../src/modules/Kernel.rb', line 553 def AddModuleToLoad(name) Builtins.y2milestone("Adding module to be loaded at boot: %1", name) @kernel_modules_to_load = Builtins.add( @kernel_modules_to_load, { "operation" => "add", "name" => name } ) nil end |
- (String) ComputePackage
Compute kernel package
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 |
# File '../../src/modules/Kernel.rb', line 465 def ComputePackage packages = GetPackages() the_kernel = Ops.get(packages, 0, "") Builtins.y2milestone("Selecting '%1' as kernel package", the_kernel) # Check for provided kernel packages in installed system if Mode.normal || Mode.repair while the_kernel != "" && !Pkg.PkgInstalled(the_kernel) the_kernel = Ops.get(@fallbacks, the_kernel, "") Builtins.y2milestone("Not provided, falling back to '%1'", the_kernel) end else while the_kernel != "" && !Pkg.PkgAvailable(the_kernel) the_kernel = Ops.get(@fallbacks, the_kernel, "") Builtins.y2milestone( "Not available, falling back to '%1'", the_kernel ) end end if the_kernel != "" @final_kernel = the_kernel else Builtins.y2warning( "%1 not available, using kernel-default", @kernel_packages ) @final_kernel = "kernel-default" end @final_kernel end |
- (Array) ComputePackages
Compute kernel packages
520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 |
# File '../../src/modules/Kernel.rb', line 520 def ComputePackages kernel = ComputePackage() ret = ComputePackagesForBase(kernel, true) if Ops.greater_than(Builtins.size(@kernel_packages), 1) # get the extra packages extra_pkgs = Builtins.remove(@kernel_packages, 0) # add available extra packages Builtins.foreach(extra_pkgs) do |pkg| if Pkg.IsAvailable(pkg) ret = Builtins.add(ret, pkg) Builtins.y2milestone("Added extra kernel package: %1", pkg) else Builtins.y2warning( "Extra kernel package '%1' is not available", pkg ) end end end Builtins.y2milestone("Computed kernel packages: %1", ret) deep_copy(ret) end |
- (Object) ComputePackagesForBase(base, check_avail)
Compute kernel package for the specified base kernel package
510 511 512 513 514 515 516 |
# File '../../src/modules/Kernel.rb', line 510 def ComputePackagesForBase(base, check_avail) # Note: kernel-*-nongpl packages have been dropped, use base only ret = [base] Builtins.y2milestone("Packages for base %1: %2", base, ret) deep_copy(ret) end |
- (void) ExtractCmdlineParameters(line)
This method returns an undefined value.
Filters out yast2 specific boot parameters and sets Parameters to the important cmdline parts.
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 |
# File '../../src/modules/Kernel.rb', line 161 def ExtractCmdlineParameters(line) # discard \n line = Builtins.deletechars(line, "\n") # list of parameters to be discarded (yast internals) discardlist = [] cmdlist = [] parse_index = 0 in_quotes = false after_backslash = false current_param = "" while Ops.less_than(parse_index, Builtins.size(line)) current_char = Builtins.substring(line, parse_index, 1) in_quotes = !in_quotes if current_char == "\"" && !after_backslash if current_char == " " && !in_quotes cmdlist = Builtins.add(cmdlist, current_param) current_param = "" else current_param = Ops.add(current_param, current_char) end if current_char == "\\" after_backslash = true else after_backslash = false end parse_index = Ops.add(parse_index, 1) end cmdlist = Builtins.add(cmdlist, current_param) # this is wrong because of eg. >>o="p a r a m"<<, see bugzilla 26147 # list cmdlist = splitstring (line, " "); # some systems (pseries) can autodetect the serial console if Builtins.contains(cmdlist, "AUTOCONSOLE") discardlist = Builtins.add(discardlist, "console") discardlist = Builtins.add(discardlist, "AUTOCONSOLE") end # add special key filtering for s390 # bnc#462276 Extraneous parameters in /etc/zipl.conf from the installer if Arch.s390 discardlist = Builtins.add(discardlist, "User") discardlist = Builtins.add(discardlist, "init") discardlist = Builtins.add(discardlist, "ramdisk_size") end # backdoor to re-enable update on UL/SLES if Builtins.contains(cmdlist, "suse_update") discardlist = Builtins.add(discardlist, "suse_update") @suse_update = true end Builtins.foreach(cmdlist) do |parameter| # split "key=value" to ["key", "value"] param_value_list = Builtins.splitstring(parameter, "=") key = Ops.get(param_value_list, 0, "") value = Ops.get(param_value_list, 1, "") # now only collect keys not in discardlist if Ops.greater_than(Builtins.size(param_value_list), 0) if !Builtins.contains(discardlist, key) if Ops.get(param_value_list, 0, "") == "vga" if Builtins.regexpmatch(value, "^(0x)?[0-9a-fA-F]+$") || Builtins.contains(["normal", "ext", "ask"], value) @vgaType = value else Builtins.y2warning("Incorrect VGA kernel parameter: %1", value) end else AddCmdLine(key, value) end end end end nil end |
- (String) GetBinary
Het the name of kernel binary under /boot
451 452 453 454 |
# File '../../src/modules/Kernel.rb', line 451 def GetBinary ProbeKernel() if !@kernel_probed @binary end |
- (String) GetCmdLine
Get the kernel command line
282 283 284 285 |
# File '../../src/modules/Kernel.rb', line 282 def GetCmdLine ParseInstallationKernelCmdline() if !@cmdline_parsed @cmdLine end |
- (Object) GetFinalKernel
499 500 501 502 |
# File '../../src/modules/Kernel.rb', line 499 def GetFinalKernel ComputePackage() if @final_kernel == "" @final_kernel end |
- (Object) GetInformAboutKernelChange
Get inform_about_kernel_change.
630 631 632 |
# File '../../src/modules/Kernel.rb', line 630 def GetInformAboutKernelChange @inform_about_kernel_change end |
- (Object) GetPackages
Get the list of kernel packages
458 459 460 461 |
# File '../../src/modules/Kernel.rb', line 458 def GetPackages ProbeKernel() if !@kernel_probed deep_copy(@kernel_packages) end |
- (Boolean) GetSuSEUpdate
Check if suse_update kernel command line argument was passed
275 276 277 278 |
# File '../../src/modules/Kernel.rb', line 275 def GetSuSEUpdate ParseInstallationKernelCmdline() if !@cmdline_parsed @suse_update end |
- (String) GetVgaType
Get the vga= kernel parameter
259 260 261 262 |
# File '../../src/modules/Kernel.rb', line 259 def GetVgaType ParseInstallationKernelCmdline() if !@cmdline_parsed @vgaType end |
- (String) HidePasswords(_in)
Hide passwords in command line option string
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 |
# File '../../src/modules/Kernel.rb', line 113 def HidePasswords(_in) ret = "" if _in != nil parts = Builtins.splitstring(_in, " ") first = true Builtins.foreach(parts) do |p| cmdopt = p if Builtins.regexpmatch(p, "^INST_PASSWORD=") cmdopt = "INST_PASSWORD=******" elsif Builtins.regexpmatch(p, "^FTPPASSWORD=") cmdopt = "FTPPASSWORD=********" end if first first = false else ret = Ops.add(ret, " ") end ret = Ops.add(ret, cmdopt) end else ret = nil end ret end |
- (Object) InformAboutKernelChange
Display popup about new kernel that was installed
635 636 637 638 639 640 641 |
# File '../../src/modules/Kernel.rb', line 635 def InformAboutKernelChange if GetInformAboutKernelChange() # inform the user that he/she has to reboot to activate new kernel Popup.Message(_("Reboot your system\nto activate the new kernel.\n")) end @inform_about_kernel_change end |
- (Object) IsGraphicalDesktop
Simple check any graphical desktop was selected
297 298 299 300 301 302 |
# File '../../src/modules/Kernel.rb', line 297 def IsGraphicalDesktop # Get patterns set for installation during desktop selection # (see DefaultDesktop::packages_proposal_ID_patterns for the first argument) pt = PackagesProposal.GetResolvables("DefaultDesktopPatterns", :pattern) Builtins.contains(pt, "x11") end |
- (Object) main
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 |
# File '../../src/modules/Kernel.rb', line 41 def main Yast.import "Pkg" Yast.import "Arch" Yast.import "Mode" Yast.import "Linuxrc" Yast.import "PackagesProposal" Yast.import "Popup" Yast.import "Stage" textdomain "base" # kernel packages and binary @kernel_probed = false # the name of the kernel binary below '/boot'. @binary = "vmlinuz" # a list kernels to be installed. @kernel_packages = [] # the final kernel to be installed after verification and # availability checking @final_kernel = "" # kernel commandline @cmdline_parsed = false # string the kernel vga paramter @vgaType = "" # if "suse_update" given in cmdline @suse_update = false # string the kernel command line # Don't write it directly, @see: AddCmdLine() @cmdLine = "" # modules loaded on boot # List of changes in /etc/sysconfig/kernel:MODULES_LOADED_ON_BOOT # Needs to be stored as a list of changes due to the fact that some RPMs # change the variable during installation # list member is a map with keys "operation" (value "add" or "detete") and # "name" (name of the module) @kernel_modules_to_load = [] # kernel was reinstalled # A flag to indicate if a popup informing about the kernel change should be displayed @inform_about_kernel_change = false # other variables # fallback map for kernel @fallbacks = { "kernel-pae" => "kernel-default", "kernel-desktop" => "kernel-default", # fallback for PPC (#302246) "kernel-iseries64" => "kernel-ppc64" } end |
- (Object) ParseInstallationKernelCmdline
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 |
# File '../../src/modules/Kernel.rb', line 240 def ParseInstallationKernelCmdline @cmdline_parsed = true return if !(Stage.initial || Stage.cont) tmp = Convert.to_string(SCR.Read(path(".etc.install_inf.Cmdline"))) Builtins.y2milestone( "cmdline from install.inf is: %1", HidePasswords(tmp) ) if tmp != nil # extract extra boot parameters given in installation ExtractCmdlineParameters(tmp) end nil end |
- (void) ProbeKernel
This method returns an undefined value.
select kernel depending on architecture and system type.
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 |
# File '../../src/modules/Kernel.rb', line 309 def ProbeKernel kernel_desktop_exists = (Mode.normal || Mode.repair) && Pkg.PkgInstalled("kernel-desktop") || Pkg.PkgAvailable("kernel-desktop") Builtins.y2milestone( "Desktop kernel available: %1", kernel_desktop_exists ) @kernel_packages = ["kernel-default"] # add Xen paravirtualized drivers to a full virtualized host xen = Convert.to_boolean(SCR.Read(path(".probe.is_xen"))) if xen == nil Builtins.y2warning("XEN detection failed, assuming XEN is NOT running") xen = false end Builtins.y2milestone("Detected XEN: %1", xen) if Arch.is_uml Builtins.y2milestone("ProbeKernel: UML") @kernel_packages = ["kernel-um"] elsif Arch.is_xen # kernel-xen contains PAE kernel (since oS11.0) @kernel_packages = ["kernel-xen"] elsif Arch.i386 # get flags from WFM /proc/cpuinfo (for pae and tsc tests below) cpuinfo_flags = Convert.to_string( SCR.Read(path(".proc.cpuinfo.value.\"0\".\"flags\"")) ) # check only first processor cpuflags = [] # bugzilla #303842 if cpuflags != nil cpuflags = Ops.greater_than(Builtins.size(cpuinfo_flags), 0) ? Builtins.splitstring(cpuinfo_flags, " ") : [] else Builtins.y2error("Cannot read cpuflags") Builtins.y2milestone( "Mounted: %1", SCR.Execute(path(".target.bash_output"), "mount -l") ) end # check for "roughly" >= 4GB memory (see bug #40729) memories = Convert.to_list(SCR.Read(path(".probe.memory"))) memsize = Ops.get_integer( memories, [0, "resource", "phys_mem", 0, "range"], 0 ) fourGB = 3221225472 Builtins.y2milestone("Physical memory %1", memsize) # for memory > 4GB and PAE support we install kernel-pae, # PAE kernel is needed if NX flag exists as well (bnc#467328) if (Ops.greater_or_equal(memsize, fourGB) || Builtins.contains(cpuflags, "nx")) && Builtins.contains(cpuflags, "pae") Builtins.y2milestone("Kernel switch: PAE detected") if kernel_desktop_exists && IsGraphicalDesktop() @kernel_packages = ["kernel-desktop"] # add PV drivers if xen Builtins.y2milestone("Adding Xen PV drivers: xen-kmp-desktop") @kernel_packages = Builtins.add( @kernel_packages, "xen-kmp-desktop" ) end else @kernel_packages = ["kernel-pae"] # add PV drivers if xen Builtins.y2milestone("Adding Xen PV drivers: xen-kmp-pae") @kernel_packages = Builtins.add(@kernel_packages, "xen-kmp-pae") end end else # add PV drivers if xen Builtins.y2milestone("Adding Xen PV drivers: xen-kmp-default") @kernel_packages = Builtins.add(@kernel_packages, "xen-kmp-default") end end elsif Arch.x86_64 if kernel_desktop_exists && IsGraphicalDesktop() @kernel_packages = ["kernel-desktop"] if xen Builtins.y2milestone("Adding Xen PV drivers: xen-kmp-desktop") @kernel_packages = Builtins.add(@kernel_packages, "xen-kmp-desktop") end else if xen Builtins.y2milestone("Adding Xen PV drivers: xen-kmp-default") @kernel_packages = Builtins.add(@kernel_packages, "xen-kmp-default") end end elsif Arch.ppc @binary = "vmlinux" if Arch.board_iseries @kernel_packages = ["kernel-iseries64"] elsif Arch.ppc32 @kernel_packages = ["kernel-default"] else @kernel_packages = ["kernel-ppc64"] end elsif Arch.ia64 @kernel_packages = ["kernel-default"] elsif Arch.s390 @kernel_packages = ["kernel-default"] @binary = "image" end @kernel_probed = true Builtins.y2milestone("ProbeKernel determined: %1", @kernel_packages) nil end |
- (Object) RemoveModuleToLoad(name)
Remove a kernel module from the list of modules to load after boot
565 566 567 568 569 570 571 572 573 |
# File '../../src/modules/Kernel.rb', line 565 def RemoveModuleToLoad(name) Builtins.y2milestone("Removing module to be loaded at boot: %1", name) @kernel_modules_to_load = Builtins.add( @kernel_modules_to_load, { "operation" => "remove", "name" => name } ) nil end |
- (Boolean) SaveModulesToLoad
SaveModuleToLoad () save the sysconfig variable to the file
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 |
# File '../../src/modules/Kernel.rb', line 578 def SaveModulesToLoad # if nothing changed, just return success return true if Builtins.size(@kernel_modules_to_load) == 0 # first read current status modules_to_load_str = Convert.to_string( SCR.Read(path(".sysconfig.kernel.MODULES_LOADED_ON_BOOT")) ) modules_to_load_str = "" if modules_to_load_str == nil modules_to_load = Builtins.splitstring(modules_to_load_str, " ") modules_to_load = Builtins.filter(modules_to_load) { |s| s != "" } Builtins.y2milestone( "Read modules to be loaded at boot: %1", modules_to_load ) # apply operations on the list Builtins.foreach(@kernel_modules_to_load) do |op_desc| op = Ops.get(op_desc, "operation", "") name = Ops.get(op_desc, "name", "") if op == "remove" modules_to_load = Builtins.filter(modules_to_load) { |m| m != name } elsif op == "add" if !Builtins.contains(modules_to_load, name) modules_to_load = Builtins.add(modules_to_load, name) end end end # and sabe the list Builtins.y2milestone( "Saving modules to be loaded at boot: %1", modules_to_load ) modules_to_load_str = Builtins.mergestring(modules_to_load, " ") SCR.Write( path(".sysconfig.kernel.MODULES_LOADED_ON_BOOT"), modules_to_load_str ) SCR.Write(path(".sysconfig.kernel"), nil) end |
- (Object) SetCmdLine(new_cmd_line)
Set the kernel command line FIXME is heer because of bootloader module, should be removed
289 290 291 292 293 294 |
# File '../../src/modules/Kernel.rb', line 289 def SetCmdLine(new_cmd_line) ParseInstallationKernelCmdline() if !@cmdline_parsed @cmdLine = new_cmd_line nil end |
- (Object) SetInformAboutKernelChange(b)
Set inform_about_kernel_change.
623 624 625 626 627 |
# File '../../src/modules/Kernel.rb', line 623 def SetInformAboutKernelChange(b) @inform_about_kernel_change = b nil end |
- (Object) SetPackages(custom_kernels)
Set a custom kernel.
437 438 439 440 441 442 443 444 |
# File '../../src/modules/Kernel.rb', line 437 def SetPackages(custom_kernels) custom_kernels = deep_copy(custom_kernels) # probe to avoid later probing ProbeKernel() if !@kernel_probed @kernel_packages = deep_copy(custom_kernels) nil end |
- (Object) SetVgaType(new_vga)
Set the vga= kernel argument FIXME is heer because of bootloader module, should be removed
266 267 268 269 270 271 |
# File '../../src/modules/Kernel.rb', line 266 def SetVgaType(new_vga) ParseInstallationKernelCmdline() if !@cmdline_parsed @vgaType = new_vga nil end |