2

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"?

1
1

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

The exact syntax for using rpm2cio

rpm2cpio ./package_name-test-1.1-1.x86_64.rpm | cpio -idmv
2
  • Does not answer the question, how to unpack a source package.
    – DustWolf
    Jan 5 at 11:13
  • @DustWolf This is valid for .src.rpm files too Aug 26 at 22:40
0

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.

1
  • Use that option on what?
    – DustWolf
    Jan 5 at 11:12
0

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

2
  • 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. 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 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.