Here it is quite well described. The main commands are ...#download the packages that are required for compiling <package>
apt-get build-dep <package>
#download the source and build <package>
apt-get -b source <package>
#or you can download and build separately
apt-get source <package>
cd <package-dir>
dpkg-buildpackage -rfakeroot -uc -us -b
Comments
Update: Making a .deb package from the package sources
dpkg-buildpackage -rfakeroot -uc -us -b, no matter what.I've googled around for quite some time and saw that recently people prefer using
debuildwhich actually callsdpkg-buildpackage. I've given it a try and it worked:debuild -uc -us -bDebuild executed this:
dpkg-buildpackage -rfakeroot -D -us -uc -bBut executing the same command directly results in an error too!
debuildis part of thedevscriptspackage and the package description says this about it: "wrapper to build a package without having to su or worry about how to invoke dpkg to build using fakeroot. Also deals with common environment problems, umask etc. [fakeroot, lintian, gnupg]"Apparently the important part in this is "common environment problems, ...".
So keep in mind: use
debuildall the time! Actually if you take a look at the official Debian FAQ, it now suggestsdebuildtoo.