How to extract RPM or DEB packages

From ::

http://www.g-loaded.eu/2008/01/28/how-to-extract-rpm-or-deb-packages/

RPM and DEB packages are both containers for other files. An RPM is some sort ofcpio archive. On the other hand, a DEB file is a pure ar archive. So, it should be possible to unpack their contents using standard archiving tools, regardless of your distribution’s package format. Under normal conditions, you should use your distribution’s standard package manager, rpm ordpkg and their frontends, to manage those files. But, if you need to be more generic, here is how to do it.

RPM

For RPMs you need two command line utilities,rpm2cpio and cpio. Extracting the contents of the RPM package is aone step process:

rpm2cpio mypackage.rpm | cpio -vid

If you just need to list the contents of the package without extracting them, use the following:

rpm2cpio mypackage.rpm | cpio -vt

The -v option is used in order to get verbose output to the stdout. If you don’t need it, you can safely omit this switch. For more information about thecpio options, please refer to the cpio(1) manual page.


DEB

DEB files are ar archives, which contain three files:

  • debian-binary
  • control.tar.gz
  • data.tar.gz

As you might have already guessed, the needed archived files exist indata.tar.gz. It is also obvious that unpacking this file is a two-step process.

First, extract the aforementioned three files from the DEB file (ar archive):

ar vx mypackage.deb

Then extract the contents ofdata.tar.gz using tar:

tar -xzvf data.tar.gz

Or, if you just need to get alisting of the files:

tar -tzvf data.tar.gz

Again the -v option in bothar and tar is used in order to get verbose output. It is safe not to use it. For more information, read the man pages:tar(1) and ar(1).

If anyone knows aone step process to extract the contents of the data.tar.gz, I’d be very interested in it!

Update

As Jon suggested in the comment area, the contents of data.tar.gz can be extracted from the DEB package in a one step process as shown below:

ar p mypackage.deb data.tar.gz | tar zx

That will do it.



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值