dh_dkms
Build DKMS modules during Debian package creation
SYNOPSIS
dh_dkms [debhelper options] [--dlmod=<MODULE>]
PARAMETERS
--dlmod=<MODULE>
Sets DKMS module name (default: package name minus -dkms or -source suffixes).
--package=<PACKAGE>, -p<PACKAGE>
Operate only on specified package (standard debhelper option).
-v, --verbose
Verbose operation (standard debhelper option).
--no-act, -n
Show what would be done without acting (standard debhelper option).
DESCRIPTION
dh_dkms is a debhelper(7) program that automates packaging of kernel modules using Dynamic Kernel Module Support (DKMS). DKMS ensures modules are automatically rebuilt for new kernels, maintaining compatibility.
Key operations:
During package build, dh_dkms:
- Installs module source to debian/<package>/usr/src/<module>-<version>/.
- Locates dkms.conf from standard paths (debian/<pkg>.dkms/, debian/, source root).
- Generates maintainer scripts for DKMS management: dkms add in postinst, dkms remove in prerm, status checks, etc.
This creates -dkms or -source packages installable via apt, ideal for out-of-tree modules like VirtualBox or NVIDIA.
Integration:
Use in debian/rules via dh $@ --with dkms (requires debhelper >= 9). Module name auto-derives from package (strips -dkms, -source); version from source or dkms.conf.
Supports multi-package builds; skips if no dkms.conf found. Build-Depends: dkms.
CAVEATS
Requires dkms in Build-Depends. Needs valid dkms.conf; version must match upstream_version (no ~ or +). Source must be complete build tree. Not for binary-only modules. Test with dkms mkdeb.
DKMS.CONF SEARCH ORDER
1. debian/<package>.dkms/dkms.conf
2. debian/dkms.conf
3. dkms.conf (source root)
ENVIRONMENT VARIABLES
DH_DKMS_DIRS: Space-separated dirs to copy (default: . or debian/dkms/)
TYPICAL DEBIAN/RULES USAGE
override_dh_auto_build:
make modules
dh $@ --with dkms
HISTORY
Introduced in debhelper 7.4.9 (2009) for standardized DKMS source packaging in Debian. Evolved with debhelper v9+ sequences and multiarch support.


