extract the spec file from rpm package
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-releaseRed Hat, Inc. <http://bugzilla.redhat.com/bugzilla>$ rpm --qf '%{Packager}\n' -q cfengine-communityCFEngine AS (packager@cfengine.com)
There you have a website and an email address, respectively, where you could ask about a spec file or srpm file.