Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
Already on GitHub? Sign in to your account
Add cpu-microcode detect-plugin. #11
Closed
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
Jump to file or symbol
Failed to load files and symbols.
| @@ -0,0 +1,30 @@ | ||
| +# ubuntu-drivers-common custom detect plugin for x86 CPU microcodes | ||
| +# | ||
| +# Author: Dimitri John Ledkov <dimitri.j.ledkov@intel.com> | ||
| +# | ||
| +# This plugin detects CPU microcode packages based on pattern matching | ||
| +# against the "vendor_id" line in /proc/cpuinfo. | ||
| +# | ||
| +# To add a new microcode family, simply insert a line into the db | ||
| +# variable with the following format: | ||
| +# | ||
| +# '<Pattern from your cpuinfo output>': '<Name of the driver package>', | ||
| +# | ||
| + | ||
| +import logging | ||
| + | ||
| +db = { | ||
| + 'GenuineIntel': 'intel-microcode', | ||
| + 'AuthenticAMD': 'amd64-microcode', | ||
| + } | ||
| + | ||
| +def detect(apt_cache): | ||
| + try: | ||
| + with open('/proc/cpuinfo') as file: | ||
| + for line in file: | ||
| + if line.startswith('vendor_id'): | ||
| + cpu = line.split(':')[1].strip() | ||
| + if cpu in db: | ||
| + return [db.get(cpu)] | ||
| + except IOError as err: | ||
| + logging.debug('could not open /proc/cpuinfo: %s', err) |