X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=source%2Fsysteminfo.py;h=4ade0f118e955f6c45fff9a46c88031f0ed6e421;hb=7d75937a95c1fc13c11aaeea579a47a1377f5ca6;hp=81900ccf4001b84d735c4ec0707b2367241a878b;hpb=e77677bc3720a1733b679399c355abfd4dc58f46;p=bootmanager.git diff --git a/source/systeminfo.py b/source/systeminfo.py index 81900cc..4ade0f1 100755 --- a/source/systeminfo.py +++ b/source/systeminfo.py @@ -222,12 +222,6 @@ class systeminfo: device= parts[3] - # if the last char in device is a number, its - # a partition, and we ignore it - - if device[len(device)-1].isdigit(): - continue - dev_name= "/dev/%s" % device try: @@ -237,6 +231,10 @@ class systeminfo: except ValueError, err: continue + # skip and ignore any partitions + if minor != 0: + continue + gb_size= blocks/self.BLOCKS_PER_GB # parse the output of hdparm to get the readonly flag; @@ -289,18 +287,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 +313,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