Today it happened again. So I think to myself "There must be a better way." It turns out there is: It is called DKMS, the "Dynamic Kernel Module Support". Essentially it works by registering the module for rebuild whenever the kernel is upgraded.
Here's what I did:
- Copy the source code to /usr/src/r8168-8.023.00 - the directory name must be MODULE-VERSION
- Create a dkms.conf:
PACKAGE_NAME="r8168" PACKAGE_VERSION="8.023.00" AUTOINSTALL="yes" MAKE="'make' modules" BUILT_MODULE_NAME="r8168" BUILT_MODULE_LOCATION="src" DEST_MODULE_LOCATION="/kernel/drivers/net"
- Tell DKMS about the module: sudo dkms add -m r8168 -v 8.023.00
- Build it: sudo dkms build -m r8168 -v 8.023.00
- And finally install it: sudo dkms install -m r8168 -v 8.023.00
- At this point, you can use DKMS to build a deb package if you wish. In any case, further kernel upgrades will magically build and install the module.