rpm spec call uname -r

1k Views Asked by At

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.

3

There are 3 best solutions below

0
On BEST ANSWER

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

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

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.

0
On

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.