Andrei S
Andrei S

Reputation: 6516

rpm spec call uname -r

When I install my app, I would like to copy some files in /lib/modules/KERNEL_VERSION/extra.

The problem of course is that KERNEL_VERSION is not fixed.

I can find it by calling "uname -r", but how do I do this in a rpm spec file?

Also, if there's a better method, I'm opened to ideas.

Upvotes: 0

Views: 1060

Answers (3)

Aaron D. Marasco
Aaron D. Marasco

Reputation: 6758

This isn't a good idea because you should compile kernel modules on the client machine with a %triggerin so it survives a kernel upgrade.

Upvotes: 0

user318904
user318904

Reputation: 3076

The answer to this question will probably leave you with symbol mismatches when trying to load kernel modules compiled for a different kernel.

To place the kernel modules at compile time, do as Delan answered:

%files
/lib/modules/`uname -r`/extra/*.ko

To place the previously compiled kernel modules in the currently running kernel's path, you will have to do something tricky in the %post section:

%post
cp /lib/modules/known/location/*.ko /lib/modules/`uname -r`/extra/*.ko

%postun
rm /lib/modules/... # hopefully they have not upgraded their current kernel..

%files
/lib/modules/known/location/*.ko

Which will install kernel modules that probably can't be loaded on the running kernel. Usually source RPMs are the solution for this exact problem.

Upvotes: 0

Delan Azabani
Delan Azabani

Reputation: 81502

You could interpolate the result of uname -r into the directory (guessing here):

/lib/modules/`uname -r`/extra/

Upvotes: 2

Related Questions