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)
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.
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.
spec files are usually not in rpm. They are in source rpm.
you could use
yumdownloader --source < something.rpm
then:
rpm2cpio packagename | cpio -ivd
Per @RumpleStiltskin's answer, the original spec files are found in source rpms which can be extracted. To get the source rpms, run the following:
yum install yum-utils # Only required if yumdownloader is not installed
yumdownloader --source <package name, like 'emacs-nox'>
This will install the package to the current directory. To extract it run:
rpm2cpio <package name>.src.rpm | cpio -civ '*.spec'
The .spec
file will be in your current directory.
If you can't install yum-utils for some reason, look at the files in /etc/yum.repos.d/
and look for sections referring to source rpm repositories. You can type in the values for baseurl
into your browser and manually search for the source package. Extracting the .spec
still requires rpm2cpio
.
rpmrebuild is your friend. Use
rpmrebuild -e -p <rpm_file>
As it opens up the spec file in an editor, you can also make changes to rpm spec.
only src.rpm package , the source package, have the spec file
without src.rpm is difficult or almost impossible rebuild the package , for example rpm package provide by plesk for Linux , you can't extract neither the spec file neither the sources .
nowadays , in Fedora Linux you got rpmdevtools package , you can extract the files of one rpm, easily with rpmdev-extract
I could get all my .spec, source, Patches by this simple command
$ rpmbuild --recompile --noclean ./SRPMS/somerpm.src.rpm
Now one can change spec, src and rebuild RPM or SRPM.
© 2022 - 2024 — McMap. All rights reserved.