How is a source RPM different from unpacking an RPM with rpm2cpio and cpio?

I am attempting to understand the use of a .srpm aka “source rpm” Red Hat Package Manager package. From what I understand so far, a .srpm is different from a standard .rpm in that it provides the source code and is commonly used during development. I am puzzled on why this is useful because if I run rpm2cpio ./myrpm-1.1-1.x86_64.rpm | cpio -idmv, I can still view the source code. As I understand, even standard RPMs pull down a .tar.gz/bz file which contains the source, and eventually builds this. Could you please clarify how source RPMs are different and why I would want to use one?

Go to Source
Author: the_endian


As I remember RPM files that end with extensions of .srpm or .src.rpm (I see this more often if I recall correctly) are copies of software source code including the build/compile scripts and instructions. Normally these are archived in tar format, before then being packaged further as RPM.

Because it is packaged as RPM, source RPMs can very well be installed the same way as any other RPM. The source files will go to a default folder on your Linux.

So there is the RPM mostly and mainly for binary or compiled software. Then the Source RPM that contains the source code of that software. These were distinctly packaged with the proper file extensions. Rightfully so people don’t get confused. Perhaps some RPM packagers also include the software’s source code in RPM, but I have not seen that yet.

On a side not, back in the days I used to build RPMs for myself a lot. It became sort of a hobby. This was circa 2006-2009.

There were a few reasons I did this.

  • Software I want to install on my Linux doesn’t have RPM, only tarballs.
  • I could install software via – .configure + make + make install – terminal kung fu, but it’s easier to track and manage via RPM.
  • Lastly. For fun, and wanted to think I’m cool. (j/k) On a serious note, for learning purposes.

My memory is a bit foggy on this now. But there was this really cool GUI utility tool that created RPMs for you. I just forgot the name of this little app. You just needed to supply it a copy of the tarball, some other info, then press the button. Magic. This was after I got tired doing it by hand on the Linux terminal, and as soon as I found out about this handy GUI tool, I mostly did it this way.