从 rpm 包中提取 spec 文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5613954/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
extract the spec file from rpm package
提问by jon
Is there any way to extract the spec file from rpm package ( I have only RPM file )
有没有办法从 rpm 包中提取规范文件(我只有 RPM 文件)
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)
(此语法仅获取来自 rpm 的脚本的规范文件)
回答by Rumple Stiltskin
spec files are usually not in rpm. They are in source rpm.
spec 文件通常不在 rpm 中。它们在源 rpm 中。
回答by dannysauer
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 中,除非打包程序出于某种原因专门包含了它(而且确实没有理由这样做)。您可以从二进制 rpm 获得的唯一信息是rpm -qi <package>
返回的信息和rpm -ql <package>
列出的文件。如果您需要更多,则必须找到源包。如果 Google / 供应商的网站未能为您提供该信息,则应在 Packager 字段中提供任何有能力的人打包的任何内容的联系信息。例如,这里有一个随 RHEL 一起提供的包和一个来自第三方供应商的包:
$ 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.
在那里你分别有一个网站和一个电子邮件地址,你可以在那里询问规范文件或 srpm 文件。
回答by kamal
you could use
你可以用
yumdownloader --source < something.rpm
then:
然后:
rpm2cpio packagename | cpio -ivd
回答by reichhart
Install rpmrebuildand "extract" (actually re-create) the spec file of your rpm fileor your already installed package.
安装rpmrebuild并“提取”(实际上是重新创建)你的 rpm文件或你已经安装的包的规范文件。
Examples:
例子:
rpmrebuild --package --notest-install -e oracle-instantclient-basic-10.2.0.4-1.x86_64.rpm
rpmrebuild -s hercules.spec hercules
回答by esmeagol
rpmrebuildis your friend. Use
rpmrebuild是你的朋友。用
rpmrebuild -e -p <rpm_file>
As it opens up the spec file in an editor, you can also make changes to rpm spec.
当它在编辑器中打开规范文件时,您还可以更改 rpm 规范。
回答by Rick Smith
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:
根据@RumpleStiltskin 的回答,原始规范文件可在可提取的源 rpm 中找到。要获取源 rpm,请运行以下命令:
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.
该.spec
文件将在您的当前目录中。
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
.
如果由于某种原因无法安装 yum-utils,请查看其中的文件/etc/yum.repos.d/
并查找引用源 rpm 存储库的部分。您可以在baseurl
浏览器中输入值并手动搜索源包。提取.spec
仍然需要rpm2cpio
.
回答by Vipin Tripathi
I could get all my .spec, source, Patches by this simple command
我可以通过这个简单的命令获得我所有的 .spec、源代码、补丁
$ rpmbuild --recompile --noclean ./SRPMS/somerpm.src.rpm
Now one can change spec, src and rebuild RPM or SRPM.
现在可以更改规范、src 并重建 RPM 或 SRPM。