Usually, rpmbuild related variables are set in
~/.rpmmacros. To change the current working directory, one could simply alter the default settings:
%_topdir %(echo $HOME)/rpmbuild
This would change rpmbuild’s working directory on a per-user basis.
Sometimes it’s quite convenient to keep the default setting and change the working directory on a per-project basis:
$ rpmbuild --define "_topdir workingdir" -ba project.spec
To use the current directory as working directory, one could invoke
rpmbuild as follows:
$ rpmbuild --define "_topdir `pwd`" -ba SPECS/project.spec
Careful: Double quotes are mandatory as well as having a proper subdirectory structure in the new working directory (BUILD, SRPM, RPM, SPECS and SOURCES).