Debian – How to manage kernel modules built from source in Debian

broadcomdebiankernel-modulespackage-management

I am installing Debian squeeze on a brand-new Mac Mini, and the Broadcom NIC in it only works with the latest tg3 module from Broadcom. I can build this module easily enough, but performing a manual build and overwriting the tg3.ko that comes with the kernel packages seems like a kludge because:

  • the rather non-trivial steps I performed to build the module are not automated
  • kernel upgrades will break ethernet by overwriting my custom-built module

I've read How do I build debian packages of kernel modules?, but the techniques I've researched so far seem to deal with the case of packaging a module that isn't in the kernel packages. Given that I want to replace a module already provided by the kernel package, rather than add a new module, how can I accomplish this without resorting to fragile kludges?

Best Answer

I was able to get this working with DKMS. There was an additional problem of not clobbering the tg3.ko that already exists in the kernel packages. I learned that there can be an "updates" directory under /lib/modules/$KERNELVERSION. This way, I don't have to worry about overwriting another package's files and there's an easy way to go back to the default version. More here:

http://www.linuxvox.com/2009/10/update-kernel-modules-the-smart-and-safe-way/

And here is a good tutorial on the DKMS process, which also describes some Ubuntu/Debian specific magic when DKMS modules put their modules in /updates:

https://wiki.kubuntu.org/Kernel/Dev/DKMSPackaging

The dkms.conf I used for this particular module:

PACKAGE_NAME="tg3"
PACKAGE_VERSION="3.124c"
BUILT_MODULE_NAME[0]="tg3"
DEST_MODULE_LOCATION[0]="/updates"
MAKE[0]="'make' KVER=$kernelver"
AUTOINSTALL="yes"

The difficult part about this was knowing to quote 'make' in $MAKE, because if it's unquoted, DKMS will append KERNELRELEASE=... to make, and that breaks this particular build system.

I was able to do all the building in a squeeze chroot, run dkms mkdeb, then install the resulting deb package on the Mini for the win.