Skip to content
Advertisement

RPM require kernel-devel package of currently installed kernel

I have written an RPM spec that has a requirement for the kernel-devel package. However, that is satisfied by the installation of any kernel-devel package. How do I specify that the RPM requires the kernel-devel package of the currently running kernel version.

For example, our customer could be running 3.10.0-514, however the latest is 3.10.0-693. If you execute “yum install -y kernel-devel” you get the headers for the latest version, satisfying the “Requires” line in my RPM. I want to ensure that the headers installed are for 3.10.0-514.

Advertisement

Answer

You can’t. I’ve been wrangling with this for years.

You also can’t use triggers to watch when kernel-devel is installed, because when it is installed, it still won’t match the running kernel version.

The solution I have used is to put a custom script into /etc/init.d/ (or the systemd equivalents) that recompiles the driver on demand each time the OS boots with a potentially-new kernel. And it is smart enough to recognize if the sources aren’t there to tell the user to upgrade that as well.

Advertisement