tech_log: How to extract RPM or DEB packages

Friday, January 23, 2009

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 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.


RPM


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


rpm2cpio mypackage.rpm | cpio -vid</pre>
<p>If you just need to list the contents of the package without extracting them, use the following:</p>
<pre class="console">rpm2cpio mypackage.rpm | cpio -vt</pre>
<p>The <strong>-v</strong> 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 <code>cpio</code> options, please refer to the <code>cpio(1)</code> manual page.</p>
<h4>DEB</h4>
<p>DEB files are <em>ar archives</em>, which contain three files:</p>
<ul><li>debian-binary</li><li>control.tar.gz</li><li>data.tar.gz</li></ul>
<p>As you might have already guessed, the needed archived files exist in <code>data.tar.gz</code>. It is also obvious that unpacking this file is a <em>two-step</em> process.</p>
<p>First, extract the aforementioned three files from the DEB file (<strong>ar</strong> archive):</p>
<pre class="console">ar vx mypackage.deb</pre>
<p>Then extract the contents of <code>data.tar.gz</code> using <strong>tar</strong>:</p>
<pre class="console">tar -xzvf data.tar.gz</pre>
<p>Or, if you just need to get a <em>listing</em> of the files:</p>
<pre class="console">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: tar(1) and ar(1).

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home