DKMS packaging works great for building out of tree kernel modules. However,
what do you do when you need to install to a machine without a compiler? You
can accompish this by using DKMS’s mkdriverdisk
functionality.
First follow the steps here for setting up a proper DKMS package.
After you’ve built the module successfully, you can use the following bash
script to extract the .deb installer from the driverdisk. This way you can copy
the deb file to the target machine and install. You must ensure that $(uname -rm)
on the target machine matches the build machine.
NAME=hello
VERSION=0.1
# Build in a temp dir
TMPDIR=$(mktemp -d)
cd $TMPDIR
sudo dkms mkdriverdisk $NAME/$VERSION -d ubuntu --media tar | tee build.log
TARBALL_PATH=$(grep "Disk image location" build.log | cut -d':' -f2)
echo $TARBALL_PATH
tar -xf $TARBALL_PATH
cd -
# Extract the build
mv $TMPDIR/ubuntu-drivers/*/*.deb .