[rpm] Correct way of writing spec file when packaging symlinks

Domen Vrankar domen.vrankar at gmail.com
Sat Oct 18 22:16:58 UTC 2014

I also have one further question.

I was reading this stack overflow thread (
and began to wonder if it is better to write spec file this way:

rm -rf %{buildroot}
mkdir %{buildroot}
ln -sf /foo/bin %{buildroot}/bar/newbin


Or is it better to put symlink creation in %post section:

ln -sf /foo/bin /bar/newbin

The problem that I'm having is that I can not create a relocatable rpm with
either of the above options. If I use --prefix= during installation then
the first option points to an invalid location and the second option fails
with an error during installation but the rpm still gets installed so both
cases fail but make some changes to file system.

Can either of these options be made relocatable?
For e.g. is there a variable that can be used in second case (something
like ln -sf %{foo_prefix}/bin %{bar_prefix}/newbin so %{foo_prefix} and
%{bar_prefix} get changed during rpm installation depending on specified


2014-10-18 23:34 GMT+02:00 Domen Vrankar <domen.vrankar at gmail.com>:

> Hi,
> I was searching the web and couldn't find an answer on how to correctly
> write a spec file when packaging symlinks.
> One option that I found was
> %config /path/symlink
> and the other was simply
> /path/symlink
> Based on Documentation
> http://www.rpm.org/max-rpm/s1-rpm-inside-files-list-directives.html
> am I correct in assuming that the second version (without any % prefix) is
> the correct format?
> Is there any difference in prefix if symlink points to directory or file?
> Thanks,
> Domen Vrankar
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rpm.org/pipermail/rpm-list/attachments/20141019/047a6b28/attachment.html>

More information about the Rpm-list mailing list