Skip to content

Commit 5bf9481

Browse files
committed
improve kmod logging, optimize lspci kmod loading
Signed-off-by: Zen <[email protected]>
1 parent 807c1c6 commit 5bf9481

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/ugrd/kmod/kmod.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
__author__ = 'desultory'
2-
__version__ = '2.14.2'
2+
__version__ = '2.15.0'
33

44
from pathlib import Path
55
from subprocess import run
@@ -114,6 +114,7 @@ def _autodetect_modules_lspci(self) -> None:
114114
cmd = self._run(['lspci', '-k'])
115115
except RuntimeError as e:
116116
raise DependencyResolutionError("Failed to get list of kernel modules") from e
117+
lspci_kmods = set()
117118
# Iterate over all output lines
118119
for line in cmd.stdout.decode('utf-8').split('\n'):
119120
# If the line contains the string 'Kernel modules:' or 'Kernel driver in use:', it contains the name of a kernel module
@@ -122,10 +123,11 @@ def _autodetect_modules_lspci(self) -> None:
122123
if ',' in module:
123124
# If there are multiple modules, split them and add them to the module set
124125
for module in module.split(','):
125-
self['_kmod_auto'] = module.strip()
126+
lspci_kmods.add(module.strip())
126127
else:
127-
# Add the single module to the module set
128-
self['_kmod_auto'] = module.strip()
128+
lspci_kmods.add(module.strip())
129+
130+
self['_kmod_auto'] = list(lspci_kmods)
129131

130132

131133
@contains('kmod_autodetect_lsmod', "kmod_autodetect_lsmod is not enabled, skipping.")
@@ -306,7 +308,10 @@ def process_modules(self) -> None:
306308
try:
307309
_process_kmod_dependencies(self, kmod)
308310
continue
309-
except (IgnoredModuleError, BuiltinModuleError) as e:
311+
except BuiltinModuleError as e:
312+
self.logger.debug(e)
313+
continue # Don't add built-in modules to the ignore list
314+
except IgnoredModuleError as e:
310315
self.logger.info(e)
311316
except DependencyResolutionError as e:
312317
if kmod in self['kmod_init']:

0 commit comments

Comments
 (0)