Packaging symlinks via rpmbuild?

SyBer picture SyBer · Sep 22, 2011 · Viewed 14.8k times · Source

Is it possible to make rpmbuild to preserve symlinks on packaging?

The current behavior is to create copies of files, which I would like to avoid.

Answer

Stan picture Stan · Apr 24, 2012

Sure it supports symlinks. But you actually have to package symlink and not copy the contents to the buildroot. Example spec packaging a symlink to /bin directory called /newbin

Name:           test
Version:        1.0
Release:        1%{?dist}
Summary:        nothing
License:        GPLv2
Source0:        nothing

%description 

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

%files
/newbin

You'll also need nothing file in your SOURCES directory to succesfully build rpm out of this. Tested with rpm 4.9.1.2