Build a DEB file from source file


One of the reasons I love debian distributions and their child distributions is its package management system. All files are packaged up as binary DEB files, which are easy to install. And for a lot of software they have DEB files prebuilt for you. Some dont and some latest software may not have them built yet. This tutorial will walk you through making a DEB file from source code.

As usual I stick to a console for this. It may be possible through GUI applications but this is the tried and true way of doing it. So open a console and switch to root. Some people say you shouldnt but I have always run into hickups and doing it as root by passes any hickups dealing with permissions.


First we have to make sure you have everything you need to build apt-get install autotools-dev fakeroot dh-make build-essential


Then download the source file for any program you wish, for this example I will be making a deb install file for a program called `sample` version 0.3. Extract the source files and then move them to tmp. cp -r sample-0.3 /tmp Then go into the source folder cd /tmp/sample-0.3


Now we have to make the debian control files dh_make. It will prompt you what kind of project this is, be it a single or what not. Select the best one that suits this compile.


Edit the `debian/control` file and change the maintainer and description fields to something appropriate. You can also change anything else you wish but I usually leave it alone.


Now we build the package dpkg-buildpackage -rfakeroot


The building takes a little while. When complete you should have a sample_0.3_i386.deb file in /tmp. You can now use this to do a more simple install on other systems, or if you need to reinstall. You can install the program through dpkg using the command dpkg -i /tmp/sample_0.3_i386.deb