I want to unpack source RPM and apply patches to the upstream source.

What is almost OK for me is

rpm -i mypkg-*.src.rpm
cd ~/rpmbuild
rpmbuild -bp SPECS/mypkg.spec
# frolic in BUILD/mypkg

My problem is that rpm -i always deploys the sources in ~/rpmbuild. And since I want to do it in a middle of automated test (which is running under root), I'd rather do this at least in my own temporary tree.

I have tried --prefix=mypath with RPM, but it seems that RPM ignored that (after hassling me about the path being relative ... nice job ;)).

Other thing that came to my mind was creating a temporary user and su but that's ugly, adds overhead of creating/removing the user and is not non-intrusive anyway.

So what are my other, way better options?


You have to change the topdir value. There are two ways of doing it:

  • Create a ~/.rpmmacros file with the line %_topdir /your/path
  • Invoke rpm (and rpmbuild) with --define "_topdir /your/path"

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.