Tuesday, March 15, 2022

[SOLVED] How to change RPM's destination when using rpmbuild

Issue

I am building an RPM with rpmbuild from a spec file in a directory foo but whenever I run rpmbuild it creates the rpm in my home directory at ~/rpmbuild/RPMS.

How can I change the destination of the RPM and get the whole rpmbuild directory to be in foo? I tried setting Buildroot to foo but that just changed where the build built temporary files, not the final rpm. Any help would be appreciated. Thanks!


Solution

The information in the (sometimes really dated) Maximum RPM manual is still up-to-date. You need to set the _topdir value to move the entire directory tree:

Apart from changing ~/.rpmmacros, you can also use -D _topdir /path/to/alternate/location to switch the location of the directory tree.

If you want to move specific subdirectories, see rpmrc File Entries and search for topdir references for the other RPM macro names. Note that for some reason, the leading underscore _ is missing from all those variables names.



Answered By - Florian Weimer
Answer Checked By - David Goodson (WPSolving Volunteer)