8

I have an RPM that I built. And I am looking to figure out how to extract the Spec file out of it. I have tried:

rpm --scripts -qp sampleBuild.rpm

That didn't work. Does anyone know the proper command?

2 Answers 2

11

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.

1
  • Download the source-rpm with yumdownloader --source yourpackagename.
    – ILMostro_7
    Commented Jun 30, 2018 at 12:53
8

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

2
  • This works well for RPMs (not SRPMs) where the original spec is missing, as it generates a fake spec. The yum package is rpmrebuild.
    – rjh
    Commented Sep 5, 2018 at 7:47
  • Works fine on CentOS 6.10 provided you've rpmrebuild(available in EPEL repo not in base repo) installed. You may download epel rpm from here: download-ib01.fedoraproject.org/pub/epel/6/i386/…
    – alphaGeek
    Commented Jun 29, 2020 at 6:41

You must log in to answer this question.

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