The Debian rebuilding tools are installed with
apt-get install devscripts build-essential fakeroot
The following command will get the source package foo
apt-get source foo
We must also install the packages required to rebuild the package foo as follows
apt-get build-dep foo
We next go into the source directory of foo and use debuild to make the package:
cd foo/ debuild -us -uc
Finally, the directory above will contain the dpkg package.