The good old rpm while building package in steps simply kept the content of the BuildRoot -- it was very useful for me, because if some piece of software was difficult to create, I could check BuildRoot if everything is OK.

Now, with all "improved" rpm -- the content of BuildRoot is deleted automatically, so I cannot really dive into it (installing step is not that long).

One hack I know of would be adding some kind of sleep at the end of install stage to rpm spec. But this is ugly.

So -- QUESTION -- how to keep the content of BuildRoot in nice way -- in other words, how to disable auto delete once and for good?

4 Answers 4


Have you tried using rpmbuild -bi in testing, so that the you get everything built up through the %install phase? That should show you what's going on without automatically cleaning afterwards.

Then when you're satisfied, build as normal.

  • Thank you. This is the least intrusive approach and it works. Apr 2, 2011 at 14:58

Just add

    %define __spec_install_pre /bin/true

on top of the .spec file

  • 1
    It works for me in RHEL/CentOS 7.
    – Like
    Dec 9, 2015 at 11:28
  • This works in Fedora 27. Dec 14, 2017 at 1:02
  • And if someone is building from .src.rpm, there is a way to do this via CLI: rpmbuild --define '__spec_install_pre /bin/true' --rebuild *.src.rpm. Thanks a lot!
    – saulius2
    Jul 8, 2021 at 15:47

Try adding a dummy %clean to the spec file. Something like:

echo NOOP
  • doesn't work, because BUILDROOT is deleted at the beginning of %install - it is part of the initialization of %install.
    – smcg
    Sep 16, 2014 at 18:58
  • If the goal is to keep buildroot after the build, for investigation, then it does work.
    – ederag
    Jan 29, 2018 at 8:35

This is annoying, I agree. If you don't mind modifying your rpm, I suggest going into the rpm source and finding out where the BuildRoot is deleted, disable that line (it is probably only one line), and recompile. The other thing I would suggest is filing a wishlist bug to restore the old behaviour, which I believe was configurable.

Question: in what version of rpm did this behavior change?

  • I don't know about the version, but change in official rpm would be tough: lists.rpm.org/pipermail/rpm-list/2008-December/000040.html The explanation indicates that idelogy play a huge role. Patching rpm would be possible though, thank you for the hint. Maybe I would manage revert automatic BuildRoot creating too. Apr 1, 2011 at 10:11
  • @macias: I looked at the rpm sources on Debian (4.9.0-2), but didn't find out anything useful. However, even if the developers are not willing to change it, I expect they are willing to tell you how to do it for yourself. Apr 1, 2011 at 10:35
  • luckily the -bi switch works for this case, so I skip patching if I can -- the software list with regressions are getting longer anyway. Apr 2, 2011 at 14:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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