Skip to content

Commit 269a51c

Browse files
authored
Merge pull request #63 from desultory/nokmod
normalize kmod names
2 parents 1b1f3f2 + 0c5a52c commit 269a51c

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/ugrd/kmod/kmod.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
__author__ = 'desultory'
2-
__version__ = '2.12.3'
2+
__version__ = '2.13.0'
33

44
from pathlib import Path
55
from subprocess import run
6+
from typing import Union
67

78
from zenlib.util import contains, unset
89

@@ -52,11 +53,20 @@ def _process__kmod_auto_multi(self, module: str) -> None:
5253
self['_kmod_auto'].append(module)
5354

5455

56+
def _normalize_kmod_name(module: Union[str, list]) -> str:
57+
""" Replaces -'s with _'s in a kernel module name. """
58+
if isinstance(module, list) and not isinstance(module, str):
59+
return [_normalize_kmod_name(m) for m in module]
60+
return module.replace('-', '_')
61+
62+
5563
def _get_kmod_info(self, module: str):
5664
"""
5765
Runs modinfo on a kernel module, parses the output and stored the results in self['_kmod_modinfo'].
5866
!!! Should be run after metadata is processed so the kver is set properly !!!
5967
"""
68+
module = _normalize_kmod_name(module)
69+
6070
if module in self['_kmod_modinfo']:
6171
return self.logger.debug("[%s] Module info already exists." % module)
6272
args = ['modinfo', module, '--set-version', self['kernel_version']]
@@ -77,9 +87,9 @@ def _get_kmod_info(self, module: str):
7787
module_info['filename'] = line.split()[1]
7888
elif line.startswith('depends:') and line != 'depends:':
7989
if ',' in line:
80-
module_info['depends'] = line.split(':')[1].lstrip().split(',')
90+
module_info['depends'] = _normalize_kmod_name(line.split(':')[1].lstrip().split(','))
8191
else:
82-
module_info['depends'] = [line.split()[1]]
92+
module_info['depends'] = _normalize_kmod_name([line.split()[1]])
8393
elif line.startswith('softdep:'):
8494
module_info['softdep'] = line.split()[2::2]
8595
elif line.startswith('firmware:'):

0 commit comments

Comments
 (0)