Class: Yast::ArchClass
- Inherits:
-
Module
- Object
- Module
- Yast::ArchClass
- Defined in:
- library/general/src/modules/Arch.rb
Overview
Representing architecture information yast have.
rubocop:disable Naming/VariableNumber Reason for disable is that API is stable and some method names follows domain conventions
Instance Method Summary collapse
-
#aarch64 ⇒ Object
true for all aarch64 (ARM64) architectures.
-
#alpha ⇒ Object
true for all alpha architectures.
-
#arch_short ⇒ String
Returns general architecture type (one of sparc, ppc, s390, i386, alpha, ia64, x86_64, arm, aarch64).
-
#architecture ⇒ String
Returns full architecture type (one of i386, sparc, sparc64, ppc, ppc64, alpha, s390_32, s390_64, ia64, x86_64, arm, aarch64, risv64).
-
#arm ⇒ Object
true for all 32-bit ARM architectures.
-
#board_chrp ⇒ Object
true for all "CHRP" ppc boards.
-
#board_compatible ⇒ Object
************************************************************ general system board types (initialized in constructor).
-
#board_iseries ⇒ Object
true for all "iSeries" ppc boards.
-
#board_mac ⇒ Object
true for all PPC "MacRISC" boards.
-
#board_mac_new ⇒ Object
true for all "NewWorld" PowerMacs.
-
#board_mac_old ⇒ Object
true for all "OldWorld" powermacs.
-
#board_pegasos ⇒ Object
true for all "Pegasos" and "Efika" ppc boards.
-
#board_powernv ⇒ Object
true for all baremetal Power8 systems https://github.com/open-power/docs.
-
#board_prep ⇒ Object
true for all "PReP" ppc boards.
-
#board_wintel ⇒ Object
true for all "Windows/Intel" compliant boards (x86 based).
-
#has_pcmcia ⇒ Object
true if the system supports PCMCIA But modern notebook computers do not have it.
-
#has_smp ⇒ Object
true if running on multiprocessor board.
-
#has_tpm2 ⇒ Boolean
Whether a TPM2 chip is available or not.
-
#i386 ⇒ Object
true for all x86 compatible architectures.
-
#ia64 ⇒ Object
deprecated
Deprecated.
Itanium is no longer supported
-
#is_kvm ⇒ Object
true if KVM is running.
-
#is_laptop ⇒ Object
true if the system runs on laptop.
- #is_uml ⇒ Object deprecated Deprecated.
-
#is_virtual ⇒ Boolean
Whether the system is running over a virtualized environment.
-
#is_wsl ⇒ Boolean
Determines whether the system is running on WSL.
-
#is_xen ⇒ Boolean
Whether the Xen kernel is running.
-
#is_xen0 ⇒ Boolean
Whether it is a Xen host (dom0).
-
#is_xenU ⇒ Boolean
Whether it is a Xen guest (domU).
-
#is_zkvm ⇒ Object
zKVM means KVM on IBM System z true if zKVM is running.
-
#is_zvm ⇒ Object
zVM means VM on IBM System z true if zVM is running.
- #main ⇒ Object
-
#paravirtualized_xen_guest? ⇒ Boolean
Whether a Xen guest is paravirtualized (PV) or not (HVM).
-
#ppc ⇒ Object
true for all ppc architectures (32 or 64 bit).
-
#ppc32 ⇒ Object
true for all 32bit ppc architectures.
-
#ppc64 ⇒ Object
true for all 64bit ppc architectures.
-
#riscv64 ⇒ Object
true for all riscv64 (RISC-V 64-bit) architectures.
-
#rpm_arch ⇒ String
Returns the architecture expected by SCC.
-
#s390 ⇒ Object
true for all S/390 architectures (32 or 64 bit).
-
#s390_32 ⇒ Object
true for all 32bit S/390 architectures.
-
#s390_64 ⇒ Object
true for all 64bit S/390 architectures.
-
#setSMP(is_smp) ⇒ Object
Set "Arch::has_smp ()".
-
#sparc ⇒ Object
true for all sparc architectures (32 or 64 bit).
-
#sparc32 ⇒ Object
true for all 32bit sparc architectures.
-
#sparc64 ⇒ Object
true for all 64bit sparc architectures.
-
#x11_setup_needed ⇒ Object
run X11 configuration after inital boot this is false in case of: installation on iSeries, installation on S390.
-
#x86_64 ⇒ Object
true for all x86-64 (AMD Hammer) architectures.
-
#xen_capabilities ⇒ String
Convenience method to retrieve the /proc/xen/capabilities content.
Instance Method Details
#aarch64 ⇒ Object
true for all aarch64 (ARM64) architectures
178 179 180 |
# File 'library/general/src/modules/Arch.rb', line 178 def aarch64 architecture == "aarch64" end |
#alpha ⇒ Object
true for all alpha architectures
136 137 138 |
# File 'library/general/src/modules/Arch.rb', line 136 def alpha architecture == "alpha" end |
#arch_short ⇒ String
Returns general architecture type (one of sparc, ppc, s390, i386, alpha, ia64, x86_64, arm, aarch64)
190 191 192 193 194 195 196 197 198 199 200 |
# File 'library/general/src/modules/Arch.rb', line 190 def arch_short if sparc "sparc" elsif ppc "ppc" elsif s390 "s390" else architecture end end |
#architecture ⇒ String
Returns full architecture type (one of i386, sparc, sparc64, ppc, ppc64, alpha, s390_32, s390_64, ia64, x86_64, arm, aarch64, risv64)
79 80 81 82 83 84 85 86 |
# File 'library/general/src/modules/Arch.rb', line 79 def architecture if @_architecture.nil? @_architecture = Convert.to_string( SCR.Read(path(".probe.architecture")) ) end @_architecture end |
#arm ⇒ Object
true for all 32-bit ARM architectures
173 174 175 |
# File 'library/general/src/modules/Arch.rb', line 173 def arm architecture == "arm" end |
#board_chrp ⇒ Object
true for all "CHRP" ppc boards
303 304 305 |
# File 'library/general/src/modules/Arch.rb', line 303 def board_chrp ppc && board_compatible == "CHRP" end |
#board_compatible ⇒ Object
general system board types (initialized in constructor)
205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 |
# File 'library/general/src/modules/Arch.rb', line 205 def board_compatible if @_board_compatible.nil? @_checkgeneration = "" systemProbe = Convert.convert( SCR.Read(path(".probe.system")), from: "any", to: "list <map>" ) systemProbe = [] if systemProbe.nil? Builtins.foreach(systemProbe) do |entry| checksys = Ops.get_string(entry, "system", "") @_checkgeneration = Ops.get_string(entry, "generation", "") @_board_compatible = checksys if checksys != "" end Builtins.y2milestone("_board_compatible '%1' \n", @_board_compatible) @_board_compatible = "wintel" if i386 || x86_64 # hwinfo expects CHRP/PReP/iSeries/MacRISC*/PowerNV in /proc/cpuinfo # there is no standard for the board identification # Cell and Maple based boards have no CHRP in /proc/cpuinfo # Pegasos and Cell do have CHRP in /proc/cpuinfo, but Pegasos2 should no be handled as CHRP # Efika is handled like Pegasos for the time being if ppc && (@_board_compatible.nil? || @_board_compatible == "CHRP") device_type = Convert.to_map( SCR.Execute( path(".target.bash_output"), "/usr/bin/echo -n `/usr/bin/cat /proc/device-tree/device_type`", {} ) ) model = Convert.to_map( SCR.Execute( path(".target.bash_output"), "/usr/bin/echo -n `/usr/bin/cat /proc/device-tree/model`", {} ) ) board = Ops.get_string(model, "stdout", "") Builtins.y2milestone( "model %1 , device_type %2\n", model, device_type ) # catch remaining IBM boards if Builtins.issubstring( Ops.get_string(device_type, "stdout", ""), "chrp" ) @_board_compatible = "CHRP" end # Maple has its own way of pretenting OF1275 compliance @_board_compatible = "CHRP" if ["Momentum,Maple-D", "Momentum,Maple-L", "Momentum,Maple"].include?(board) # Pegasos has CHRP in /proc/cpuinfo and 'chrp' in /proc/device-tree/device_type if board == "Pegasos2" || Builtins.issubstring( Builtins.tolower(Ops.get_string(device_type, "stdout", "")), "pegasos2" ) @_board_compatible = "Pegasos" end # Efika has CHRP in /proc/cpuinfo and 'efika' in /proc/device-tree/device_type if Builtins.issubstring(Builtins.tolower(board), "efika") || Builtins.issubstring( Builtins.tolower(Ops.get_string(device_type, "stdout", "")), "efika" ) @_board_compatible = "Pegasos" end end # avoid future re-probing if probing failed # also avoid passing nil outside the module @_board_compatible = "" if fun_ref(method(:board_compatible), "string ()").nil? end @_board_compatible end |
#board_iseries ⇒ Object
true for all "iSeries" ppc boards
314 315 316 |
# File 'library/general/src/modules/Arch.rb', line 314 def board_iseries ppc && board_compatible == "iSeries" end |
#board_mac ⇒ Object
true for all PPC "MacRISC" boards
283 284 285 286 287 288 |
# File 'library/general/src/modules/Arch.rb', line 283 def board_mac ppc && (board_compatible == "MacRISC" || board_compatible == "MacRISC2" || board_compatible == "MacRISC3" || board_compatible == "MacRISC4") end |
#board_mac_new ⇒ Object
true for all "NewWorld" PowerMacs
291 292 293 294 |
# File 'library/general/src/modules/Arch.rb', line 291 def board_mac_new # board_mac calls board_compatible which initializes _checkgeneration board_mac && @_checkgeneration == "NewWorld" end |
#board_mac_old ⇒ Object
true for all "OldWorld" powermacs
297 298 299 300 |
# File 'library/general/src/modules/Arch.rb', line 297 def board_mac_old # board_mac calls board_compatible which initializes _checkgeneration board_mac && @_checkgeneration == "OldWorld" end |
#board_pegasos ⇒ Object
true for all "Pegasos" and "Efika" ppc boards
324 325 326 |
# File 'library/general/src/modules/Arch.rb', line 324 def board_pegasos ppc && board_compatible == "Pegasos" end |
#board_powernv ⇒ Object
true for all baremetal Power8 systems https://github.com/open-power/docs
309 310 311 |
# File 'library/general/src/modules/Arch.rb', line 309 def board_powernv ppc && board_compatible == "PowerNV" end |
#board_prep ⇒ Object
true for all "PReP" ppc boards
319 320 321 |
# File 'library/general/src/modules/Arch.rb', line 319 def board_prep ppc && board_compatible == "PReP" end |
#board_wintel ⇒ Object
true for all "Windows/Intel" compliant boards (x86 based)
329 330 331 |
# File 'library/general/src/modules/Arch.rb', line 329 def board_wintel board_compatible == "wintel" end |
#has_pcmcia ⇒ Object
true if the system supports PCMCIA But modern notebook computers do not have it. See also Bugzilla #151813#c10
340 341 342 343 |
# File 'library/general/src/modules/Arch.rb', line 340 def has_pcmcia @_has_pcmcia = Convert.to_boolean(SCR.Read(path(".probe.has_pcmcia"))) if @_has_pcmcia.nil? @_has_pcmcia end |
#has_smp ⇒ Object
true if running on multiprocessor board. This only reflects the board, not the actual number of CPUs or the running kernel!
514 515 516 517 518 519 520 521 |
# File 'library/general/src/modules/Arch.rb', line 514 def has_smp @_has_smp = Convert.to_boolean(SCR.Read(path(".probe.has_smp"))) if @_has_smp.nil? if alpha # get smp for alpha from /etc/install.inf setSMP(SCR.Read(path(".etc.install_inf.SMP")) == "1") end @_has_smp end |
#has_tpm2 ⇒ Boolean
Whether a TPM2 chip is available or not.
435 436 437 438 |
# File 'library/general/src/modules/Arch.rb', line 435 def has_tpm2 @_has_tpm2 = SCR.Read(path(".target.string"), "/sys/module/tpm/version")&.strip == "2.0" if @_has_tpm2.nil? @_has_tpm2 end |
#i386 ⇒ Object
true for all x86 compatible architectures
89 90 91 |
# File 'library/general/src/modules/Arch.rb', line 89 def i386 architecture == "i386" end |
#ia64 ⇒ Object
Itanium is no longer supported
true for all IA64 (itanium) architectures
163 164 165 |
# File 'library/general/src/modules/Arch.rb', line 163 def ia64 architecture == "ia64" end |
#is_kvm ⇒ Object
true if KVM is running
453 454 455 456 457 458 459 460 461 462 463 |
# File 'library/general/src/modules/Arch.rb', line 453 def is_kvm if @_is_kvm.nil? # KVM hypervisor has /dev/kvm file stat = Convert.to_map(SCR.Read(path(".target.stat"), "/dev/kvm")) Builtins.y2milestone("stat /dev/kvm: %1", stat) @_is_kvm = Ops.greater_than(Builtins.size(stat), 0) end @_is_kvm end |
#is_laptop ⇒ Object
true if the system runs on laptop
348 349 350 351 352 353 354 355 356 357 358 359 |
# File 'library/general/src/modules/Arch.rb', line 348 def is_laptop if @_is_laptop.nil? system = Convert.convert( SCR.Read(path(".probe.system")), from: "any", to: "list <map>" ) formfactor = Ops.get_string(system, [0, "formfactor"], "") @_is_laptop = formfactor == "laptop" end @_is_laptop end |
#is_uml ⇒ Object
true if UML
377 378 379 380 |
# File 'library/general/src/modules/Arch.rb', line 377 def is_uml @_is_uml = Convert.to_boolean(SCR.Read(path(".probe.is_uml"))) if @_is_uml.nil? @_is_uml end |
#is_virtual ⇒ Boolean
Whether the system is running over a virtualized environment
364 365 366 367 368 369 |
# File 'library/general/src/modules/Arch.rb', line 364 def is_virtual return @_is_virtual unless @_is_virtual.nil? @_is_virtual = SCR.Read(path(".target.string"), "/proc/cpuinfo") .to_s.match?("^flags.*hypervisor.*\n") end |
#is_wsl ⇒ Boolean
Determines whether the system is running on WSL
540 541 542 543 544 545 546 |
# File 'library/general/src/modules/Arch.rb', line 540 def is_wsl # As of 2020-07-24 /proc/sys/kernel/osrelease contains # "4.4.0-19041-Microsoft" on wsl1 and # "4.19.104-microsoft-standard" on wsl2. # Match on lowercase "-microsoft" SCR.Read(path(".target.string"), "/proc/sys/kernel/osrelease").to_s.downcase.include?("-microsoft") end |
#is_xen ⇒ Boolean
Whether the Xen kernel is running
390 391 392 393 394 |
# File 'library/general/src/modules/Arch.rb', line 390 def is_xen return @_is_xen unless @_is_xen.nil? @_is_xen = SCR.Read(path(".target.stat"), "/proc/xen")["isdir"] || false end |
#is_xen0 ⇒ Boolean
Whether it is a Xen host (dom0)
403 404 405 406 407 |
# File 'library/general/src/modules/Arch.rb', line 403 def is_xen0 return @_is_xen0 unless @_is_xen0.nil? @_is_xen0 = is_xen && xen_capabilities.include?("control_d") end |
#is_xenU ⇒ Boolean
Whether it is a Xen guest (domU)
416 417 418 |
# File 'library/general/src/modules/Arch.rb', line 416 def is_xenU is_xen && !is_xen0 end |
#is_zkvm ⇒ Object
zKVM means KVM on IBM System z true if zKVM is running
472 473 474 475 476 477 478 479 |
# File 'library/general/src/modules/Arch.rb', line 472 def is_zkvm if @_is_zkvm.nil? # using different check than on x86 as recommended by IBM @_is_zkvm = s390 && Yast::WFM.Execute(path(".local.bash"), "/usr/bin/grep 'Control Program: KVM' /proc/sysinfo") == 0 end @_is_zkvm end |
#is_zvm ⇒ Object
zVM means VM on IBM System z true if zVM is running
488 489 490 491 492 493 494 495 |
# File 'library/general/src/modules/Arch.rb', line 488 def is_zvm if @_is_zvm.nil? # using different check than on x86 as recommended by IBM @_is_zvm = s390 && Yast::WFM.Execute(path(".local.bash"), "/usr/bin/grep 'Control Program: z\/VM' /proc/sysinfo") == 0 end @_is_zvm end |
#main ⇒ Object
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 |
# File 'library/general/src/modules/Arch.rb', line 37 def main # local variables @_architecture = nil @_board_compatible = nil @_checkgeneration = "" @_has_pcmcia = nil @_has_tpm2 = nil @_is_laptop = nil @_is_uml = nil @_has_smp = nil # Xen domain (dom0 or domU) @_is_xen = nil # Xen dom0 @_is_xen0 = nil # KVM @_is_kvm = nil # zKVM @_is_zkvm = nil # zVM @_is_zvm = nil end |
#paravirtualized_xen_guest? ⇒ Boolean
Whether a Xen guest is paravirtualized (PV) or not (HVM)
426 427 428 429 430 |
# File 'library/general/src/modules/Arch.rb', line 426 def paravirtualized_xen_guest? return false unless is_xenU SCR.Read(path(".target.string"), "/sys/hypervisor/guest_type").strip == "PV" end |
#ppc ⇒ Object
true for all ppc architectures (32 or 64 bit)
131 132 133 |
# File 'library/general/src/modules/Arch.rb', line 131 def ppc ppc32 || ppc64 end |
#ppc32 ⇒ Object
true for all 32bit ppc architectures
117 118 119 |
# File 'library/general/src/modules/Arch.rb', line 117 def ppc32 architecture == "ppc" end |
#ppc64 ⇒ Object
true for all 64bit ppc architectures
124 125 126 |
# File 'library/general/src/modules/Arch.rb', line 124 def ppc64 architecture == "ppc64" end |
#riscv64 ⇒ Object
true for all riscv64 (RISC-V 64-bit) architectures
183 184 185 |
# File 'library/general/src/modules/Arch.rb', line 183 def riscv64 architecture == "riscv64" end |
#rpm_arch ⇒ String
Returns the architecture expected by SCC
560 561 562 |
# File 'library/general/src/modules/Arch.rb', line 560 def rpm_arch RPM_ARCH[architecture] || architecture end |
#s390 ⇒ Object
true for all S/390 architectures (32 or 64 bit)
157 158 159 |
# File 'library/general/src/modules/Arch.rb', line 157 def s390 s390_32 || s390_64 end |
#s390_32 ⇒ Object
true for all 32bit S/390 architectures
143 144 145 |
# File 'library/general/src/modules/Arch.rb', line 143 def s390_32 architecture == "s390_32" end |
#s390_64 ⇒ Object
true for all 64bit S/390 architectures
150 151 152 |
# File 'library/general/src/modules/Arch.rb', line 150 def s390_64 architecture == "s390_64" end |
#setSMP(is_smp) ⇒ Object
Set "Arch::has_smp ()". Since Alpha doesn't reliably probe smp, 'has_smp' must be set later with this function.
504 505 506 507 508 |
# File 'library/general/src/modules/Arch.rb', line 504 def setSMP(is_smp) @_has_smp = is_smp nil end |
#sparc ⇒ Object
true for all sparc architectures (32 or 64 bit)
110 111 112 |
# File 'library/general/src/modules/Arch.rb', line 110 def sparc sparc32 || sparc64 end |
#sparc32 ⇒ Object
true for all 32bit sparc architectures
96 97 98 |
# File 'library/general/src/modules/Arch.rb', line 96 def sparc32 architecture == "sparc" end |
#sparc64 ⇒ Object
true for all 64bit sparc architectures
103 104 105 |
# File 'library/general/src/modules/Arch.rb', line 103 def sparc64 architecture == "sparc64" end |
#x11_setup_needed ⇒ Object
run X11 configuration after inital boot this is false in case of: installation on iSeries, installation on S390
530 531 532 533 534 535 |
# File 'library/general/src/modules/Arch.rb', line 530 def x11_setup_needed # disable X11 setup after initial boot return false if board_iseries || s390 true end |
#x86_64 ⇒ Object
true for all x86-64 (AMD Hammer) architectures
168 169 170 |
# File 'library/general/src/modules/Arch.rb', line 168 def x86_64 architecture == "x86_64" end |
#xen_capabilities ⇒ String
Convenience method to retrieve the /proc/xen/capabilities content
443 444 445 |
# File 'library/general/src/modules/Arch.rb', line 443 def xen_capabilities SCR.Read(path(".target.string"), "/proc/xen/capabilities").to_s end |