Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 4 down vote accepted

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.

share|improve this answer
Thank you. This is the least intrusive approach and it works. – greenoldman Apr 2 '11 at 14:58

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

echo NOOP
share|improve this answer
doesn't work, because BUILDROOT is deleted at the beginning of %install - it is part of the initialization of %install. – smcg Sep 16 '14 at 18:58

Just add

    %define __spec_install_pre /bin/true

on top of the .spec file

share|improve this answer
It works for me in RHEL/CentOS 7. – Like Dec 9 '15 at 11:28

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?

share|improve this answer
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. – greenoldman Apr 1 '11 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. – Faheem Mitha Apr 1 '11 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. – greenoldman Apr 2 '11 at 14:59

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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