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?

1 Answer 1


I have never heard of a RPM that would pull down a source code. Maybe there are some which do that, but I would say they are rare. srpm packages include source code and instructions to build rpm packages. rpm packages have compiled code, which you can run and they do not include sources. There are exceptions. For instance: Perl, python, PHP, etc. are not compiled to binary as C or C++ programs are. For these rpm packages source files are included, because they are interpreted or compiled just in time (JIT). So there are no compiled binaries, but sources are used directly.

When you want to build rpm packages you would typically download a srpm and install it. Then you go to rpmbuild/SPECS directory where spec file is installed. Then you run:

rpmbuild -bb <package>.spec

That would build rpm(s). It is very common that one srpm specs produce more rpm packages:


Built rpm packages are stored in rpmbuild/RPMS. Then you can install rpm packages, which install actual program that you can run.

Unpacking files from rpm package is very much different that installing a rpm package. With unpacking files you get the package files. You may try to run a program from extracted package files, but there is great chance that it will not work. Installing rpm package means, that rpm makes sure, that also all libraries needed for that program are installed, too. If there are any other actions needed before or right after installation, scripts in rpm package will make sure they will be executed. Some program might need a database, that needs to be created on installation, another might need to rerun ldconfig to update libraries cache, another might need to build manuals, etc. If you just extract files from rpm, these scripts will not be executed.

  • Great explanation. I thought that I misunderstood srpms but actually I misunderstood RPMs!
    – the_endian
    May 21, 2020 at 6:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .