RPM and DEB packages are both containers for other files. An RPM is some sort of cpio 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 or dpkg and their frontends, to manage those files. But, if you need to be more generic, here is how to do it.
For RPMs you need two command line utilities, rpm2cpio and cpio. Extracting the contents of the RPM package is a one 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 the
cpio options, please refer to the
cpio(1) manual page.
DEB files are ar archives, which contain three files:
As you might have already guessed, the needed archived files exist in
data.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 of
data.tar.gz using tar:
tar -xzvf data.tar.gz
Or, if you just need to get a listing of the files:
tar -tzvf data.tar.gz
Again the -v option in both ar and tar is used in order to get verbose output. It is safe not to use it. For more information, read the man pages:
If anyone knows a one step process to extract the contents of the
data.tar.gz, I’d be very interested in it!
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
Update 2 – Debian 8
As Vlad suggested in the comments below, starting with Debian 8,
.deb packages has been replaced with
data.tar.xz (the xz format, which is based on LZMA2 offers better compression). So, if you are using Debian 8 or newer, the one-liner should be updated to something like this:
ar p mypackage.deb data.tar.xz | unxz | tar x
tar is now able to handle
xz compression and decompression (I also confirm tar supports this compression filter on CentOS), so the following one liner would do the trick as well:
ar p mypackage.deb data.tar.xz | tar xJ
That will do it.
Update: As Steve pointed out in the comments below, specifying the decompression filter in the
tar command line arguments is no longer necessary with modern releases of
tar, so the
J switch above could be safely omitted.
How to extract RPM or DEB packages by George Notaras is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
Permissions beyond the scope of this license may be available at Licensing Information.
Copyright © 2008 - Some Rights Reserved