Monday, August 26, 2013

How to extract deb file without having dpkg

.deb files are regular ar archives. You can manipulate the file by using ar command.

For example, I have a package called lynx_2.8.8dev.15-2_all.deb in a centos box.

$ cat /etc/issue
CentOS release 6.4 (Final)
Kernel \r on an \m

$ ls -lh
total 4.0K
-rw-rw-r--. 1 foo foo 3.9K Jan 18  2013 lynx_2.8.8dev.15-2_all.deb

To extract the file, just run ar x <.deb.filename>
$ ar x lynx_2.8.8dev.15-2_all.deb
You will see 3 files being extracted, control.tar.gz, data.tar.gz and debian binary.
$ ls
control.tar.gz  data.tar.gz  debian-binary  lynx_2.8.8dev.15-2_all.deb

debian-binary is a text file containing deb packaging version number.
$ cat debian-binary 
2.0

control.tar.gz contained control, preinst and md5sums.
$ tar -tf control.tar.gz ./
./md5sums
./control
./preinst

data.tar.gz is a compressed file containing the files which are going to be installed on the system.
$ tar -tf data.tar.gz ./
./usr/
./usr/share/
./usr/share/doc/
./usr/share/doc/lynx/
./usr/share/doc/lynx/copyright
./usr/share/doc/lynx/changelog.Debian.gz

No comments: