Add cpu-microcode detect-plugin. #11

Closed
wants to merge 2 commits into
from
Jump to file or symbol
Failed to load files and symbols.
+31 −1
Split
@@ -426,7 +426,7 @@ def auto_install_filter(packages):
KMS).
'''
# any package which matches any of those globs will be accepted
- whitelist = ['bcmwl*', 'pvr-omap*', 'virtualbox-guest*', 'nvidia-*']
+ whitelist = ['bcmwl*', 'pvr-omap*', 'virtualbox-guest*', 'nvidia-*', '*-microcode']
allow = []
for pattern in whitelist:
allow.extend(fnmatch.filter(packages, pattern))
@@ -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)