Wednesday, April 13, 2022

[SOLVED] rpmbuild - /usr/sbin Symlink not installing

Issue

I'm setting up a Redis RPM for a local, unnetworked box. I'm trying to create a symlink: /usr/sbin/redis-server -> /opt/redis/redis-server

However, when I do an rpm -Uvh redis-3.2.7-1.rpm, it installed fine to /opt/redis/redis-server but never creates the symlink. Here's the relevant part of my spec file:

%build
# Empty section.

%install
rm -rf %{buildroot}
rm -f /usr/sbin/redis-server

mkdir -p  %{buildroot}

# in builddir
cp -a * %{buildroot}

ln -sf /opt/redis/redis-server /usr/sbin/redis-server

%clean
rm -rf %{buildroot}

%files
/opt/redis/*
/etc/init.d/redis

Solution

ln -sf /opt/redis/redis-server /usr/sbin/redis-server needs to be ln -sf /opt/redis/redis-server %{buildroot}/usr/sbin/redis-server and then /usr/sbin/redis-server needs to be added to the %files section. Also remove that rm in %install.

The fact that the ln did not fail tells me you really made the symlink, and you're building RPMs as root which is a spectacularly bad idea.

I'm assuming that the tarball expands with opt at the top level; if not your cp is incorrect as well.



Answered By - Aaron D. Marasco
Answer Checked By - Pedro (WPSolving Volunteer)