[CentOS-devel] kmod packaging guideline

Sun Dec 21 00:08:43 UTC 2008
Ned Slider <ned at unixmail.co.uk>

Farkas Levente wrote:
> hi,
> it'd be nice to write some kind of docs about how to write kmod packages
> for centos. as i wrote in one of my earlier post there are two problems
> currently with the weak-updates kmods:
> kmodtool shouldn't have to add to all packages rather use the
> /usr/lib/rpm/redhat/kmodtool from redhat-rpm-config ie:
> ----------------------------------------------
> @@ -1,7 +1,6 @@
> -Source10: kmodtool
>  Source11: find-requires
>  Source12: find-requires.ksyms
> -%define   kmodtool bash %{SOURCE10}
> +%define   kmodtool bash /usr/lib/rpm/redhat/kmodtool
> ----------------------------------------------
> and add:
> BuildRequires:	redhat-rpm-config

Hi Farkas,

There is some information on building kABI tracking kmod packages in the 
BuildingKernelModules page on the Wiki:


Unless I misunderstand your proposal above, one reason I have found for 
including a custom kmodtool-foo source script with your kmod is for 
satisfying Requires. For example, putting:

Requires: foo-bar >= 1.2.3

in the SPEC file for a kmod doesn't work. The Require needs to be added 
to the kmodtool script:

Requires(post): /sbin/depmod
Requires(postun): /sbin/depmod
*Requires: foo-bar >= 1.2.3*

I came across this problem building some kmods that required a later 
version of lm_sensors. An example can be seen in this kmod package for 
the coretemp module:


I'll admit I'm not an expert kmod packager, but placing the Requires in 
the kmodtool script was the only solution I found (actually either 
Johnny or Karanbir suggested it on IRC IIRC). In my case kmodtool-foo 
was simply a copy of /usr/lib/rpm/redhat/kmodtool with the necessary 
Requires added. If there's a simpler or more elegant solution then 
please do enlighten me :)

My next question would be if Requires: doesn't work in a kmod SPEC file, 

BuildRequires:	redhat-rpm-config