开发者

extract the spec file from rpm package

开发者 https://www.devze.com 2023-02-23 18:28 出处:网络
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

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 no开发者_开发技巧t 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 (packager@cfengine.com)

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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号