Building .deb package from source

Building from source can become annoying. While i don’t mind running through configure and make to get the packages i want it’s not always the best option. You may want to use this package a lot more than once and on other machines so a deb along with a local repo may be the best choice.


root@debian:~$ apt-get install autotools-dev fakeroot dh-make build-essential

Configure the package

Extract the source folder from your chosen directory.

user@debian:~/files/src$ tar -xvzf pkgname-0.5.5.tar.gz

Change directory to extracted source:

user@debian:~/files/src$ cd pkgname-0.5.5

Make the debian control files:

user@debian:~/files/src/pkgname-0.5.5$ dh_make

Follow the prompts and the control file is created.

Edit the debian/control file and replace the placeholder information.

user@debian:~/files/src/pkgname-0.5.5$ gedit ./src/debian/control

Build the package

Run the following:

user@debian:~/files/src/pkgname-0.5.5# dpkg-buildpackage -D -rfakeroot

You now have a working deb package.
If you have an error try it without the -D. (-D checks build dependencies and conflicts.)