Is there any way to extract the spec file from rpm package ( I have only RPM file )
not by
rpm --scripts -qp my-great-app-1.1.2.rpm
( this syntax not get the spec file only the scripts from the rpm)
Install rpmrebuild and "extract" (actually re-create) the spec file of your rpm file or your already installed package. Looking at rpmrebuild's code and then actually testing it, it doesn't "extract" the spec file; it regenerates most of a spec file (header, log, pre/post scripts).
If you want to save a copy of the package as currently installed before upgrading or removing it, use rpm --repackage -- it'll save the RPMs in /var/tmp or /var/spool/repackage or elsewhere, depending on your configuration. Otherwise, there exists rpmrebuild , which does exactly what you ask for.
You can use the repoquery command which is part of the yum-utils to list files installed on a CentOS/RHEL system from a given package. Important: In Fedora 22+ version, the repoquery command is integrated with dnf package manager for RPM based distribution to list files installed from a package as shown above.
Install rpmrebuild and "extract" (actually re-create) the spec file of your rpm file or your already installed package.
Examples:
rpmrebuild --package --notest-install -e oracle-instantclient-basic-10.2.0.4-1.x86_64.rpm rpmrebuild -s hercules.spec hercules
The spec file is not stored in binary rpms unless the packager specifically included it for some reason (and there's really no reason to do that). The only information you can get from a binary rpm is the information that rpm -qi <package>
returns, and the files that rpm -ql <package>
lists. If you need more than that, you have to find the source package. If Google / the vendor's web site fails to provide that for you, there should be contact information provided in the Packager field for anything packaged by anyone competent. For example, here's a package that ships with RHEL and a package from a third party vendor:
$ rpm --qf '%{Packager}\n' -q redhat-release Red Hat, Inc. <http://bugzilla.redhat.com/bugzilla> $ rpm --qf '%{Packager}\n' -q cfengine-community CFEngine AS ([email protected])
There you have a website and an email address, respectively, where you could ask about a spec file or srpm file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With