zfsonlinux/zfs — Issue #535: DKMS support
Author: Rudd-O
Created: 2012-01-15 13:50:26+00:00
State: open

It's getting old having to compile ZFS on every kernel upgrade, and DKMS sounds like the thing to do.

From the dkms man page:

CREATING RPMS WHICH UTILIZE DKMS
See the sample.spec file packaged with DKMS as an example for what your RPM spec file might look like. Creating RPMs which utilize dkms is a fairly straight-forward process. The RPM need only to
install the source into /usr/src/-/ and then employ dkms itself to do all the work of installation. As such, the RPM should first untar the source into this directory. From
here, within the RPM .spec file, a dkms add should be called (remember to use the --rpm_safe_upgrade flag during the add) followed by a dkms build followed by a dkms install. Your dkms.conf file
should be placed within the /usr/src/-/ directory.

Under the removal parts of the .spec file, all that needs to be called is a: dkms remove -m -v --all --rpm_safe_upgrade. Use of the --rpm_safe_upgrade flag is imperative
for making sure DKMS and RPM play nicely together in all scenarios of using the -Uvh flag with RPM to upgrade dkms enabled packages. It will only function if used during both the add and remove
actions within the same RPM spec file. Its use makes sure that when upgrading between different releases of an RPM for the same , DKMS does not do anything dumb (eg. it ensures a
smooth upgrade from megaraid-2.09-5.noarch.rpm to megaraid-2.09-6.noarch.rpm).

It should be noted that a binary RPM which contains source is not a traditional practice. However, given the benefits of dkms it hopefully will become so. As the RPM created which utilizes dkms is
not architecture specific, BuildArch: noarch should be specified in the .spec file to indicate that the package can work regardless of the system architecture. Also note that DKMS RPM upgrades (-U
option) will automatically work because of the structure of the dkms tree.

Lastly, as a matter of convention, you should name your RPM: --dkms.noarch.rpm. The word dkms as part of the rpm-version signifies that the RPM works within the DKMS
framework.

The RPM, of course, would need to contain the header files, programs, man pages, et cetera, along with the source tarball for the sources to include in the /usr/src directory.