Tuesday, August 25, 2009

Create a .deb package from source files

If you are like me, you will find that you need to install a lot of application software from the source code and compile the build for your specific platform. The most common way of installing the program is to download the source (usually it's a file with .tgz or .tar.gz extension to it), unpack the file, go into the directory where the source files are extracted, run the configure tool, followed by the make and finally the make install commands.

wget http://site.com/source/program-1.0.tgz
tar -zxvf program-1.0.tgz
cd program-1.0
./configure
make
sudo make install

This will download, extract, compile and install the program in your Ubuntu eco-system.

If you have to do this to a few machines or need to reinstall your computer ever so often, it would simply be easier if you could create a .deb file and simply install the program when you need to which is faster, and you do not need the installation of compiler, make utility, header and dev libraries.

There is a tool called checkinstall which you can install from the Ubuntu repository. To do that, simply run the command:

sudo apt-get install checkinstall

Once that is installed, when you want to create a .deb file, you do pretty much everything like normal but instead of installing the program with "sudo make install", you create a .deb at this point with the command "sudo checkinstall" which will create the .deb file for you.

You can then copy the .deb file into a safe place, and when you need to install in the future, copy the .deb file to your local directory and issue the command "sudo dpkg -i package.deb" which will install the applictaion for you without the need for the source download, dev libraries, compiler, etc.

Note: These are basic instructions that may not always work. Some packages require additional dependencies and optional parameters to be specified in order to build them successfully.

No comments:

Post a Comment