Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Packaging symlinks via rpmbuild?

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.

like image 406
SyBer Avatar asked Sep 22 '11 21:09

SyBer


2 Answers

I know this Q is old, but here's how I do it.

In the %install section, simply touch the file that will be the symlink.

touch %{buildroot}[path to your file]

In the %files section, you specify it as a %ghost file:

%ghost [path to symlink file]

By doing this, it'll be listed as part of the package's files and will also be automatically removed when the package is uninstalled.

Finally, create the symlink in the %post section:

ln -sf [file to link to] [symlink]
like image 141
Alther Avatar answered Sep 20 '22 16:09

Alther


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

like image 44
Stan Avatar answered Sep 21 '22 16:09

Stan