How do I build debian packages of kernel modules?

Specifically, I want to build a package for debian/lenny using the latest uvc drivers. I can compile and install them, but I want them packaged in the normal debian fashion. I imagine I want to use make-kpkg somehow, but I don't know how. module-assistant seems no good, because that seems to only use sources available in debian.


Solution 1:

There is a better solution than m-a: dkms

It actually makes it easier to distribute external kernel modules and automatically compiles them for newer kernel-versions (think installing a new package of linux-headers).

Solution 2:

There's no easy answer. To create a real Debian package from scratch is not just a matter of sticking files into an archive, you'll need the control file and installation scripts and everything else that makes it a package rather than just a tarball.

To learn about using dh-make and debhelper to create packages, start with the New Maintainers' Guide, then read the Developer's Guide on packaging "best practices".

Then, /usr/share/doc/module-assistant/README.gz and HOWTO-DEVEL.gz covers how to use the packaging tools to create source packages that module-assistant can understand.

I think if you're packaging a module that exists in the default kernel package you'll have more work to prevent conflicts. If you're just doing this for yourself, it would probably be best to build and install a custom kernel package with the "old" driver disabled so that the files don't conflict (note the instructions in README.gz regarding KVERS).