Say you have a binary 3rd party .deb package and for some odd reason they messed up the post install Script and the package doesn't install well.
You could either fix the post install (after it being partially installed), or extract the .deb, fix the contents and reassemble it. Here is how to do it:
!!File Ownership might be a problem, consider running this as root!!Extract the data.tar.gz
$ dpkg-deb -x hello_2.4-1_i386.deb hello
Extract the control.tar.gz
$ dpkg-deb -e hello_2.4-1_i386.deb hello/DEBIAN
Now fix whatever you want to fix inside the package Reassemble the .deb again
$ dpkg-deb -b hello myfixed-hello_2.4-1_i386.deb
dpkg-deb: building package `myfixed-hello' in `myfixed-hello_2.4-1_i386.deb'.
Check if it worked
$ dpkg -I myfixed-hello_2.4-1_i386.deb
new debian package, version 2.0.
size 61550 bytes: control archive= 655 bytes.
608 bytes, 16 lines control
103 bytes, 4 lines * postinst #!/bin/sh
74 bytes, 3 lines * prerm #!/bin/sh
Package: myfixed-hello
Version: 2.4-1
Architecture: i386
Maintainer: Santiago Vila
Installed-Size: 656
Depends: libc6 (>= 2.3.4)
Section: devel
Priority: optional
Description: The classic greeting, and a good example
The GNU hello program produces a familiar, friendly greeting. It
allows non-programmers to use a classic computer science tool which
would otherwise be unavailable to them.
.
Seriously, though: this is an example of how to do a Debian package.
It is the Debian version of the GNU Project's `hello world' program
(which is itself an example for the GNU Project).
Enjoy