PDA

View Full Version : How to install symbolic links via RPM?


gbuergisser
16th May 2011, 03:10 PM
Hi all,

I'm trying to build a RPM package consisting of some .so files and some symbolic links pointing to these .so files. Just like "libxyz-2.9.so -> libxyz-2.9.so.1".

In the .spec file all the files and symbolic links are explicitly listed in the %files section. When manually extracting the files from the RPM with rpm2cpio the symbolic links are extracted correctly. But when I install the RPM using yum the files pointed to by the symbolic link will be installed instead of the symbolic link!

What am I doing wrong?

Thanks for your help!

PabloTwo
16th May 2011, 04:19 PM
Here is what worked for me to make a relative symbolic link (using your example as an example).
In the %install section of the spec file:

ln -s libxyz-2.9.so.1 $RPM_BUILD_ROOT%{_libdir}/libxyz-2.9.so > /dev/null 2>&1 || :

The above assumes the target shared object file (libxyz-2.9.so.1) is in %{_libdir} and puts the symlink (libxyz-2.9.so) to it in that directory.

mschwendt
30th June 2011, 09:10 AM

Show the verbose RPM file list of your built package. Use "rpm -qlvp ..." (possibly just "rpmls -v ...").

Packaging symlinks works for thousands of packages in the Fedora package collection, so don't let us guess what mistake you may have inserted into your spec file.

@ Pablo

ln -s libxyz-2.9.so.1 $RPM_BUILD_ROOT%{_libdir}/libxyz-2.9.so > /dev/null 2>&1 || :

The " > /dev/null 2>&1 || :" is a bad idea, however, since it would be bad packaging practice to hide the output and to ignore the error return value. Just create the softlink and let the build fail if there is an error. Optionally avoid wildcards in the %files section for the library file names, so it will also fail to build if the lib version changes (and the SONAME has changed very likely, too), which forces you to learn about this.