Essential steps to extract a .deb files without installing on Ubuntu linux



There are only three things we need to consider while extracting .deb packages.
    1.    Debian packages are essentially ar archives. So we can use CLI #ar x
    2.    Every .deb file contains three files,
    • debian-binary:  a text file, version of the deb package
    • control.tar.gz: a compressed file with md5sums and control directory for the deb package
    • data.tar.gz: another compressed file, essentially contains all the files .deb package will install
    3.     If host OS is debian (or Ubuntu) then we can also use #deb -x to extract all files in .deb package

We will use below .deb package for our little experiment,
ubuntu@techsutram:~/apache$ wget http://www-us.apache.org/dist//directory/apacheds/dist/2.0.0-M24/apacheds-2.0.0-M24-amd64.deb

Use of CLI dpkg:

We can peek into .deb package using #dpkg -c as below. This will list all files in .deb package.
ubuntu@techsutram:~/apache$ dpkg -c apacheds-2.0.0-M24-amd64.deb
drwxr-xr-x elecharny/staff   0 2017-06-05 08:01 ./
drwxr-xr-x elecharny/staff   0 2017-06-05 08:01 ./DEBIAN/
-rw-r--r-- elecharny/staff 553 2017-06-05 08:01 ./DEBIAN/control
-rwxr-xr-x elecharny/staff 1467 2017-06-05 08:01 ./DEBIAN/postinst
-rwxr-xr-x elecharny/staff 1450 2017-06-05 08:01 ./DEBIAN/prerm
drwxr-xr-x elecharny/staff    0 2017-06-05 08:01 ./etc/
drwxr-xr-x elecharny/staff    0 2017-06-05 08:01 ./etc/init.d/
-rw-r--r-- elecharny/staff 1313 2017-06-05 08:01 ./etc/init.d/apacheds-2.0.0-M24-default
drwxr-xr-x elecharny/staff    0 2017-06-05 08:01 ./opt/
drwxr-xr-x elecharny/staff    0 2017-06-05 08:01 ./opt/apacheds-2.0.0-M24/
drwxr-xr-x elecharny/staff    0 2017-06-05 08:01 ./opt/apacheds-2.0.0-M24/bin/
.
.
.
.
drwxr-xr-x elecharny/staff        0 2017-06-05 08:01 ./var/lib/apacheds-2.0.0-M24/default/run/
ubuntu@techsutram:~/apache$

Next we can extract .deb package using CLI $dpg -x as below,

ubuntu@techsutram:~/apache$ dpkg -x apacheds-2.0.0-M24-amd64.deb ./test
ubuntu@techsutram:~/apache$ ls test/
DEBIAN  etc  opt  var
ubuntu@techsutram:~/apache$

Use of CLI ar:

ubuntu@techsutram:~/apache$ ar vx apacheds-2.0.0-M24-amd64.debx - debian-binary
x - control.tar.gz
x - data.tar.xz
ubuntu@techsutram:~/apache$ ls
apacheds-2.0.0-M24-amd64.deb  control.tar.gz  data.tar.xz  debian-binary
ubuntu@techsutram:~/apache$ xz -d data.tar.xz
ubuntu@techsutram:~/apache$ tar -xf data.tar
ubuntu@techsutram:~/apache$ ls
apacheds-2.0.0-M24-amd64.deb  data.tar  debian-binary  opt   var
control.tar.gz                DEBIAN    etc
ubuntu@techsutram:~/apache$ ls
ubuntu@linux-dev-env:~/apache$ echo "That's it."
That's it.

Note: We at TechSutram take our ethics very seriously. More information about it can be found here.
Mandar Pise Opinions expressed by techsutram contributors are their own. More details

Mandar is a seasoned software professional for more than a decade. He is Cloud, AI, IoT, Blockchain and Fintech enthusiast. He writes to benefit others from his experiences. His overall goal is to help people learn about the Cloud, AI, IoT, Blockchain and Fintech and the effects they will have economically and socially in the future.

No comments:

Post a Comment

    Your valuable comments are welcome. (Moderated)