Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm creating an RPM for an application that doesn't already have one. I've got it building and installing fine in the /opt directory using $RPM_BUILD_ROOT, but I would also like to create a couple symlinks in /usr/bin so that the application is available on the path. All of my attempts to do this have yielded "permission denied" errors because I'm running rpmbuild as a non-root user and it's not allowed to create files in /usr/bin/.

Here's my current .spec file:

Summary: Berkeley UPC
Name: berkeley_upc
Version: 2.8.0
Release: 1
Source0: %{name}-%{version}.tar.gz
License: GPL
Group: Development/Tools
BuildRoot: %{_builddir}/%{name}-root
Prefix: /opt/bupc2.8
Prefix: /usr

Berkeley UPC on the BASS for the comp633 class.

%setup -q

./configure CC=gcc44 CXX=g++44 --disable-aligned-segments --prefix=/opt/bupc2.8
make %{_smp_mflags}


mkdir -p ${RPM_BUILD_ROOT}%{_bindir}
mkdir -p ${RPM_BUILD_ROOT}%{_mandir}/man1

ln -sf /opt/bupc2.8/bin/upcc          ${RPM_BUILD_ROOT}%{_bindir}
ln -sf /opt/bupc2.8/bin/upcc_multi    ${RPM_BUILD_ROOT}%{_bindir}
ln -sf /opt/bupc2.8/bin/ ${RPM_BUILD_ROOT}%{_bindir}
ln -sf /opt/bupc2.8/bin/upcdecl       ${RPM_BUILD_ROOT}%{_bindir}
ln -sf /opt/bupc2.8/bin/upcrun        ${RPM_BUILD_ROOT}%{_bindir}
ln -sf /opt/bupc2.8/bin/upc_trace     ${RPM_BUILD_ROOT}%{_bindir}

ln -sf /opt/bupc2.8/man/man1/upcc.1      ${RPM_BUILD_ROOT}%{_mandir}/man1
ln -sf /opt/bupc2.8/man/man1/upcdecl.1   ${RPM_BUILD_ROOT}%{_mandir}/man1
ln -sf /opt/bupc2.8/man/man1/upcrun.1    ${RPM_BUILD_ROOT}%{_mandir}/man1
ln -sf /opt/bupc2.8/man/man1/upc_trace.1 ${RPM_BUILD_ROOT}%{_mandir}/man1


%config /opt/bupc2.8/etc
%config /opt/bupc2.8/opt/etc


share|improve this question
up vote 4 down vote accepted

ln -sf /opt/bupc2.8/bin/upcc ${RPM_BUILD_ROOT}/%{_bindir}

The link needs to be created where you're building the RPM and it also needs to point where you're installing the RPM.

Before creating the link make sure that the destination directory exists, i.e. ${RPM_BUILD_ROOT}/%{_bindir}. You can use mkdir or install -d for this.

share|improve this answer
I edited my .spec file according to what I think you suggested and I'm getting the following error: + ln -sf /opt/bupc2.8/bin/upcc /home/eddale/src/rpm/tmp/berkeley_upc-root/usr/bin ln: creating symbolic link /home/eddale/src/rpm/tmp/berkeley_upc-root/usr/bin' to /opt/bupc2.8/bin/upcc': No such file or directory – Nov 6 '09 at 20:03
I think that you need to create the destination directory, i.e. /home/.../usr/bin. Here's how I do it:… (line 36). – Cristian Ciupitu Nov 6 '09 at 21:13
That was the problem. I've updated the question to contain the final working version. Thanks! – Nov 8 '09 at 18:34

macro %{__ln_s} is good also

example add symbolic link post install:

%{__ln_s} -f %{_bindir}/exec %{_bindir}/exec2

example remove symbolic link uninstall:

rm -f %{_bindir}/exec2
share|improve this answer
During an rpm -U upgrade, the old rpm will execute the %postun and destroy that file. The new rpm will not have a link, your code is bad. – ljdelight Jan 22 at 3:36

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.