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

I'm trying to make an rpm that will unpack the source to a custom directory, such as /asdf. When I run it, it always errors out saying "cannot create %sourcedir /usr/src/redhat/SOURCES". Is there something I can put in my .spec file that will make it unpack the source (which is just a .tar.gz file inside the src.rpm) to a custom directory when I do the command "rpm -i xyz.src.rpm"?

share|improve this question
I found the answer. logiqwest.com/TechnicalPapers/rpmScriptInstall.html provides step-by-step instructions for doing what I was trying to do. – sqenixs Dec 1 '11 at 0:17

Yes, you could use -r or --root option of rpm to specify an alternative root path as the top directory.

You also can extract the files from rpm with rpm2cpio command. man rpm2cpio.

share|improve this answer

use rpm2cpio to unpack rpm. Or use alien to convert the rpm to other packages (deb, tar...)

share|improve this answer
up vote 0 down vote accepted

The solution was as simple as calling tar in the spec file and then specifying the path I wanted to untar to.

share|improve this answer
If it was all about making the spec file with what you intended (than a command line option) then use install section in the spec file to just untar the file to a specific directory. – Nikhil Mulley Dec 6 '11 at 19:04
yes, that's exactly what I did. I just didn't understand how the spec file worked in terms of rpmbuild. – sqenixs Dec 8 '11 at 3:42

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.