From: Mark Huang Date: Thu, 22 Sep 2005 22:25:13 +0000 (+0000) Subject: - get_system_modules: allow kernel_version to be passed in X-Git-Tag: bootmanager-3_1_9~8 X-Git-Url: http://git.onelab.eu/?p=bootmanager.git;a=commitdiff_plain;h=19337358503d546533071f19edd716a1654eebe7 - get_system_modules: allow kernel_version to be passed in --- diff --git a/source/systeminfo.py b/source/systeminfo.py index 81900cc..8170ba2 100755 --- a/source/systeminfo.py +++ b/source/systeminfo.py @@ -289,18 +289,18 @@ class systeminfo: - def get_system_modules( self, install_root ): + def get_system_modules( self, install_root, kernel_version= None ): """ Return a list of kernel modules that this system requires. This requires access to the installed system's root directory, as the following files must exist and are used: /usr/share/hwdata/pcitable - /lib/modules/(first entry)/modules.pcimap - /lib/modules/(first entry)/modules.dep + /lib/modules/(first entry if kernel_version unspecified)/modules.pcimap + /lib/modules/(first entry if kernel version unspecified)/modules.dep - Note, that this assumes there is only one kernel - that is installed. If there are more than one, then - only the first one in a directory listing is used. + If there are more than one kernels installed, and the kernel + version is not specified, then only the first one in + /lib/modules is used. Returns a dictionary, keys being the type of module: - scsi MODULE_CLASS_SCSI @@ -315,18 +315,20 @@ class systeminfo: """ # get the kernel version we are assuming - try: - kernel_version= os.listdir( "%s/lib/modules/" % install_root ) - except OSError, e: - return + if kernel_version is None: + try: + kernel_version= os.listdir( "%s/lib/modules/" % install_root ) + except OSError, e: + return - if len(kernel_version) == 0: - return + if len(kernel_version) == 0: + return + + if len(kernel_version) > 1: + print( "WARNING: We may be returning modules for the wrong kernel." ) - if len(kernel_version) > 1: - print( "WARNING: We may be returning modules for the wrong kernel." ) + kernel_version= kernel_version[0] - kernel_version= kernel_version[0] print( "Using kernel version %s" % kernel_version ) # test to make sure the three files we need are present