[RFC] [PATCH] Automatic driver detection enablement - updated

Michael E Brown Michael_E_Brown at dell.com
Fri Feb 16 12:04:27 CST 2007


Patch attached. (loathe outlook)
--
Michael

On Fri, Feb 16, 2007 at 11:50:08AM -0600, Michael_E_Brown at dell.com wrote:
> Resending without attachment to see if this gets around the spam
> filtering....
> 
> Updated version.
> 
> This version adds version tags to the module provides that match the
> module modinfo version. New output looks like this: 
> 
> [michael_e_brown at mdomsch-pe2850 dkms]$ rpm -qp --provides
> /usr/src/redhat/RPMS/noarch/megaraid_sas-v00.00.03.06-1dkms.noarch.rpm
> kmod-alias(pci:v00001000d00000060sv*sd*bc*sc*i*) = 00.00.03.06
> kmod-alias(pci:v00001000d00000411sv*sd*bc*sc*i*) = 00.00.03.06
> kmod-alias(pci:v00001000d00000413sv*sd*bc*sc*i*) = 00.00.03.06
> kmod-alias(pci:v00001028d00000015sv*sd*bc*sc*i*) = 00.00.03.06
> megaraid_sas = v00.00.03.06-1dkms
> 
> --
> Michael
> 
> > -----Original Message-----
> > From: Brown, Michael E 
> > Sent: Thursday, February 15, 2007 6:07 PM
> > To: dkms-devel-Lists
> > Subject: [RFC] [PATCH] Automatic driver detection enablement
> > 
> > 
> > Problem statement:
> > 	Given PCI/USB ID, it is possible to find out which 
> > installed kernel driver to use using the modalias facility of 
> > udev. But, if the current kernel does not have the 
> > appropriate driver installed already, it is not possible to 
> > find out which possible DKMS, KMP, or other possible package 
> > would be appropriate to install to drive this hardware.
> > 
> > Proposed solution:
> > 	When building a driver package, add "Provides: XXXXX" 
> > that could be used to identify which driver to download and 
> > install. In this case, I have chosen a format for the 
> > Provides info that matches the format of the "alias" line 
> > that is output from the modinfo command. This is the same 
> > information that is used by udev.
> > 
> > Output: 
> > 	When this patch is used, it automatically adds 
> > "Provides:" tags to built DKMS rpms with no required changes 
> > to the spec file. An example of this output is given at the 
> > end of this email.
> > 
> > Use Case:
> > 	To make this useful, I intend to write a small script 
> > that does the equivalent of "yum list all kmod-alias(*)" and 
> > then match each kmod-alias against PCI devices present to 
> > figure out which packages are needed. This work is underway 
> > and will become part of firmware-tools when complete.
> > 
> > TODO:
> > 	-- Need to detect that modinfo is recent enough version.
> > 	-- possibly run original find-provides script, although 
> > I am not sure it is necessary. None of the packages I 
> > examined needed it.
> > --
> > Michael
> > 
> > 
> > [michael_e_brown at mdomsch-pe2850 dkms]$ rpm -qp --provides 
> > /usr/src/redhat/RPMS/noarch/megaraid_sas-v00.00.03.06-1dkms.noarch.rpm
> > kmod-alias(pci:v00001000d00000060sv*sd*bc*sc*i*)
> > kmod-alias(pci:v00001000d00000411sv*sd*bc*sc*i*)
> > kmod-alias(pci:v00001000d00000413sv*sd*bc*sc*i*)
> > kmod-alias(pci:v00001028d00000015sv*sd*bc*sc*i*)
> > megaraid_sas = v00.00.03.06-1dkms
> > 
> > [michael_e_brown at mdomsch-pe2850 dkms]$ modinfo 
> > /var/lib/dkms/megaraid_sas/v00.00.03.06/2.6.19-1.2895.fc6/x86_
> > 64/module/megaraid_sas.ko
> > filename:       
> > /var/lib/dkms/megaraid_sas/v00.00.03.06/2.6.19-1.2895.fc6/x86_
> > 64/module/megaraid_sas.ko
> > description:    LSI Logic MegaRAID SAS Driver
> > author:         sreenivas.bagalkote at lsil.com
> > version:        00.00.03.06
> > license:        GPL
> > srcversion:     20316EF80F8B7E90CF78F6A
> > alias:          pci:v00001028d00000015sv*sd*bc*sc*i*
> > alias:          pci:v00001000d00000413sv*sd*bc*sc*i*
> > alias:          pci:v00001000d00000060sv*sd*bc*sc*i*
> > alias:          pci:v00001000d00000411sv*sd*bc*sc*i*
> > depends:        scsi_mod
> > vermagic:       2.6.19-1.2895.fc6 SMP mod_unload 
> > 
> > 
> >  
> > 
> 
> _______________________________________________
> DKMS-devel mailing list
> DKMS-devel at dell.com
> http://lists.us.dell.com/mailman/listinfo/dkms-devel
-------------- next part --------------
--- /usr/sbin/dkms	2006-06-29 11:12:46.000000000 -0500
+++ ./dkms	2007-02-16 10:13:48.000000000 -0600
@@ -2384,12 +2384,29 @@
 	    fi
 	    echo $"Marking ${kernelver_array[$i]} (${arch_array[$i]}) for RPM..."
 	    mktarball_line="-k ${kernelver_array[$i]} -a ${arch_array[$i]} $mktarball_line"
+
+        # save off module names to generate RPM Provides later
+        set_module_suffix "${kernelver_array[$i]}"
+        local base_dir="$dkms_tree/$module/$module_version/${kernelver_array[0]}/${arch_array[0]}"
+        local kernel_module_name=$base_dir/module/${dest_module_name[$count]}$module_suffix
+        kernel_modules="$kernel_module_name $kernel_modules"
+
 	    i=$(($i + 1))
 	done
     fi
-    RPMS=`invoke_command "rpmbuild --define \"version $module_version\" --define \"module_name $module\" --define \"kernel_versions ${kernelver_array[*]}\" --define \"mktarball_line $mktarball_line\" -ba $SPECFILE 2>&1|grep ^Wrote" "rpmbuild"`
+
+    # generate the RPM Provides:
+    local all_mod_provides=
+    for each_module in $kernel_modules
+    do
+        local kernel_module_version=$(/sbin/modinfo -F version $each_module)
+        local kernel_module_provides=$(/sbin/modinfo -F alias $each_module | perl -p -i -e "s/^(.*)/kmod-alias(\$1) = $kernel_module_version/" | sort | uniq)
+        all_mod_provides="$kernel_module_provides, $all_mod_provides"
+    done
+
+    RPMS=`invoke_command "rpmbuild --define \"version $module_version\" --define \"module_name $module\" --define \"kernel_versions ${kernelver_array[*]}\" --define \"mktarball_line $mktarball_line\" --define \"__find_provides  echo '$all_mod_provides'\" --define \"_use_internal_dependency_generator 0\" -ba $SPECFILE 2>&1|grep ^Wrote " "rpmbuild"`
     if [ "$?" -eq 0 ]; then
-	echo $"" 
+	echo $""
 	echo $"$RPMS"
 	echo $""
         echo $"DKMS: mkrpm Completed."


More information about the DKMS-devel mailing list