How do you make _topdir relative to the location of the .spec file when building an RPM?

user177800 picture user177800 · Jun 9, 2011 · Viewed 12.5k times · Source

I have a .spec file that relies on a variable called _topdir.

Right now when you checkout the SRPM source from git, you have to go and change where _topdir is pointing to to get the rpmbuild to function correctly.

# We need the following line so that RPM can find the BUILD and SOURCES and RPMS dirs.
%define _topdir /root/projects/my-project/my-project-srpm/

How do you specify that _topdir should be relative to the location of the .spec file so that _topdir isn't hard coded?

Answer

Red Cricket picture Red Cricket · Sep 3, 2011

specify your topdir on the command line like so ...

rpmbuild --define "_topdir \`pwd\`" ...