How do I extract the contents of an rpm?

2019-01-29 16:39发布

I have an rpm and I want to treat it like a tarball. I want to extract the contents into a directory so I can inspect the contents. I am familiar with the querying commands of an uninstalled package. I do not simply want a list of the contents of the rpm. i.e.

$ rpm -qpl foo.rpm

I want to inspect the contents of several files contained in the rpm. I do not want to install the rpm. I am also aware of the rpms ability to do additional modifictions in the %post sections, and how to check for those. i.e.

$ rpm -qp --scripts foo.rpm

However in this case that is of no concern to me.

13条回答
我欲成王,谁敢阻挡
2楼-- · 2019-01-29 16:55

In OpenSuse at least, the unrpm command comes with the build package.

In a suitable directory (because this is an archive bomb):

unrpm file.rpm
查看更多
孤傲高冷的网名
3楼-- · 2019-01-29 16:56

To debug / inspect your rpm I suggest to use redline which is a java program

Usage :

java -cp redline-1.2.1-jar-with-dependencies.jar org.redline_rpm.Scanner foo.rpm

Download : https://github.com/craigwblake/redline/releases

查看更多
我只想做你的唯一
4楼-- · 2019-01-29 16:59

You can simply do tar -xvf <rpm file> as well!

查看更多
你好瞎i
5楼-- · 2019-01-29 17:02

Copy the .rpm file in a separate folder then run the following command $ yourfile.rpm | cpio -idmv

查看更多
做自己的国王
6楼-- · 2019-01-29 17:03

The powerful text-based file manager mc (Midnight Commander, vaguely reminding the Norton Commander of old DOS times) has the built-in capability of inspecting and unpacking .rpm and .rpms files, just "open" the .rpm(s) file within mc and select CONTENTS.cpio: for an rpm you get access to the install tree, for an rpms you get access to the .spec file and all the source packages.

查看更多
手持菜刀,她持情操
7楼-- · 2019-01-29 17:07
$ mkdir packagecontents; cd packagecontents
$ rpm2cpio ../foo.rpm | cpio -idmv
$ find . 

For Reference: the cpio arguments are

-i = extract
-d = make directories
-m = preserve modification time
-v = verbose

I found the answer over here: lontar's answer

查看更多
登录 后发表回答