Posted by Steve on Fri 27 May 2005 at 16:23
The majority of applicatications you'll wish to use upon your system are already available as Debian packages, or as backports if you're running Woody. But there may be a few applications you need to install from source. Rather than fully Debianising the package yourself you can integrate it into your system with checkinstall.
checkinstall is a simple program which monitors the installation of files, and creates a Debian package from them.
There are two primary benefits to using checkinstall instead of running make install:
It's also a good way to install arbitary files to a Debian system, such as configuration files - you merely need to create a Makefile which will install packages, without needing to create a full Debian package.
(Although it should be noted that building Debian packages of perl modules, and rebuilding Debian packages are both relatively straightforward jobs).
To get started with checkinstall you will need to install it. As root run:
apt-get install checkinstall
Once it is installed you can use it the next time you need to install a package from source code.
As an example of using it we'll investigate using it with the package htpd which is a software tool for synchronising your clock against time responses received from HTTP servers. (Note that we've covered keeping your clock current previously).
At the time of writing this software is not available as a Debian package, so it is a perfect example to start with.
First of all we need to download the source code and unpack it:
skx@lappy:~$ mkdir tmp skx@lappy:~$ cd tmp skx@lappy:~/tmp$ wget http://www.clevervest.com/htp/archive/c/htpdate-0.8.0.tar.gz skx@lappy:~/tmp$ tar -zxf htpdate-0.8.0.tar.gz skx@lappy:~/tmp$ cd htpdate-0.8.0/ skx@lappy:~/tmp/htpdate-0.8.0$
Now we can build the software as we normally would. In this case, assuming you have a compiler installed, etc, then you can build the software by typing "make":
skx@lappy:~/tmp/htpdate-0.8.0$ make gcc -Wall -ansi -Os -o htpdate htpdate.c
This gives us the binary, normally we'd proceed to install the created binary by executing "make install". Instead we're going to use checkinstall to monitor the installation process, and create a Debian package for us.
As root run:
checkinstall -D make install
(The '-D' flag means "Build a Debian package").
This will ask you if you wish to create some documentation:
root@lappy:~/tmp/htpdate-0.8.0# checkinstall -D make install
checkinstall 1.5.3, Copyright 2001 Felipe Eduardo Sanchez Diaz Duran
This software is released under the GNU GPL.
The package documentation directory ./doc-pak does not exist.
Should I create a default set of package docs? [y]:
If you say "yes" then you will find the binary will have some documentation installed in /usr/share/doc/$packagename.
After that you'll be asked to give a description for the package:
Please write a description for the package. End your description with an empty line or EOF. >> HTTP Time Protocol
After that you'll see a summery :
This package will be built according to these values: 0 - Maintainer: [ root@localhost.localdomain ] 1 - Summary: [ HTTP Time Protocol ] 2 - Name: [ htpdate-0.8.0 ] 3 - Version: [ 0.8.0 ] 4 - Release: [ 1 ] 5 - License: [ GPL ] 6 - Group: [ checkinstall ] 7 - Architecture: [ i386 ] 8 - Source location: [ htpdate-0.8.0 ] 9 - Alternate source location: [ ] Enter a number to change any of them or press ENTER to continue:
I choose "0" to change the email address of the package maintainer to my own, then entered "enter" to continue.
Once this last step has been completed the package will be installed, and the binary .deb file produced:
**********************************************************************
Done. The new package has been installed and saved to
/home/skx/tmp/htpdate-0.8.0/htpdate-0.8.0_0.8.0-1_i386.deb
You can remove it from your system anytime using:
dpkg -r htpdate-0.8.0
**********************************************************************
We can see which files are included by examining the built .deb file:
root@lappy:~/htp/htpdate-0.8.0# dpkg --contents htpdate-0.8.0_0.8.0-1_i386.deb drwxr-xr-x root/root 0 2005-05-27 17:15:28 ./ drwxr-xr-x root/root 0 2005-05-27 17:13:43 ./bin/ -rwxr-xr-x root/root 9532 2005-05-27 17:13:43 ./bin/htpdate drwxr-xr-x root/root 0 2005-05-27 17:13:43 ./usr/ drwxr-xr-x root/root 0 2005-05-27 17:13:43 ./usr/local/ drwxr-xr-x root/root 0 2005-05-27 17:13:43 ./usr/local/share/ drwxr-xr-x root/root 0 2005-05-27 17:13:43 ./usr/local/share/man/ drwxr-xr-x root/root 0 2005-05-27 17:13:43 ./usr/local/share/man/man8/ -rw-r--r-- root/staff 1372 2005-05-27 17:13:43 ./usr/local/share/man/man8/htpdate.8.gz drwxr-xr-x root/root 0 2005-05-27 17:13:43 ./usr/share/ drwxr-xr-x root/root 0 2005-05-27 17:13:43 ./usr/share/doc/ drwxr-xr-x root/root 0 2005-05-27 17:13:43 ./usr/share/doc/htpdate-0.8.0/ -rw-r--r-- root/root 2835 2005-05-26 22:32:18 ./usr/share/doc/htpdate-0.8.0/CHANGES -rw-r--r-- root/root 1824 2005-05-26 22:32:18 ./usr/share/doc/htpdate-0.8.0/README
In this case the files beneath /usr/share/doc/htpdate-0.8.0/ are only included because we answered "yes" when asked if we wished to create the documentation directory - if we'd said "no" they would have been ignored.
Because the package has no notion of dependencies we could install it on any machine - depending upon your point of view this is either a bug, or a feature!
For more options please see the manpage:
man checkinstall
This article can be found online at the Debian Administration website at the following bookmarkable URL (along with associated comments):
This article is copyright 2005 Steve - please ask for permission to republish or translate.