Extract the spec file out of an RPM

Usually, only source rpms have a spec file. You can extract it with

rpm2cpio myrpm.src.rpm | cpio -civ '*.spec'

or you can install the src rpm, as a user, with rpm -i myrpm.src.rpm, when the directory rpmbuild/SPECS/ will get the spec file.


I did some more digging around and while I cannot extract the SPEC file into another file such as text, I can use rpmrebuild to view the SPEC file and edit it. So, with that being said, here is the command I used:

rpmrebuild -e -p sampleBuild.rpm

Tags:

Rpm

Centos