[initcpiocfg] Refactor CPU-characteristics determination
The code is still over-wrought, but the API for cpuinfo now exposes the interesting thing (is it Intel?) in a useful -- more readable -- way.
This commit is contained in:
parent
ee4da8fcc7
commit
45daebd989
@ -28,7 +28,29 @@ def pretty_name():
|
|||||||
return _("Configuring mkinitcpio.")
|
return _("Configuring mkinitcpio.")
|
||||||
|
|
||||||
|
|
||||||
def cpuinfo():
|
class cpuinfo(object):
|
||||||
|
"""
|
||||||
|
Object describing the current CPU's characteristics. It may be
|
||||||
|
be considered a named tuple, there's no behavior here.
|
||||||
|
|
||||||
|
Fields in the object:
|
||||||
|
- is_intel (if it's definitely an Intel CPU)
|
||||||
|
- is_amd (if it's definitely an AMD CPU)
|
||||||
|
- number_of_cores
|
||||||
|
It is possible for both is_* fields to be False.
|
||||||
|
"""
|
||||||
|
def __init__(self):
|
||||||
|
self.is_intel = False
|
||||||
|
self.is_amd = False
|
||||||
|
self.number_of_cores = 0
|
||||||
|
|
||||||
|
cpu = self._cpuinfo()
|
||||||
|
self.is_intel = cpu['proc0']['vendor_id'].lower() == "genuineintel"
|
||||||
|
self.is_amd = cpu['proc0']['vendor_id'].lower() == "authenticamd"
|
||||||
|
self.number_of_cores = len(cpu)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _cpuinfo():
|
||||||
"""
|
"""
|
||||||
Return the information in /proc/cpuinfo as a dictionary in the following
|
Return the information in /proc/cpuinfo as a dictionary in the following
|
||||||
format:
|
format:
|
||||||
@ -172,10 +194,9 @@ def modify_mkinitcpio_conf(partitions, root_mount_point):
|
|||||||
else:
|
else:
|
||||||
hooks.extend(["filesystems"])
|
hooks.extend(["filesystems"])
|
||||||
|
|
||||||
if btrfs == "yes" and cpu['proc0']['vendor_id'].lower() != "genuineintel":
|
if btrfs == "yes" and not cpu.is_intel:
|
||||||
modules.append("crc32c")
|
modules.append("crc32c")
|
||||||
elif (btrfs == "yes"
|
elif (btrfs == "yes" and cpu.is_intel):
|
||||||
and cpu['proc0']['vendor_id'].lower() == "genuineintel"):
|
|
||||||
modules.append("crc32c-intel")
|
modules.append("crc32c-intel")
|
||||||
else:
|
else:
|
||||||
hooks.append("fsck")
|
hooks.append("fsck")
|
||||||
|
Loading…
Reference in New Issue
Block a user