Sunday, January 18, 2009

Create .deb or .rpm from .tar.gz with checkinstall


tar logoCheckinstall is extremely useful utility to create .deb packages for Debian, Ubuntu (or .rpm packages for Fedora, RedHat, CentOs) from .tar.gz (or .tgz) source tarball after it’s compiled at your Linux box. In other words you can prepare binary package for later usage without need to compile software from sources every time you need to get it installed on certain Linux box.

Another application of checkinstall is software deinstallation that was compiled and installed from sources. As you might already noticed, not every programmer adds “uninstall” rule to Makefile and thus command “make uninstall” would fail. The nice solution is to use checkinstall to prepare binary package from sources and then install or uninstall it with dpkg command (or rpm in RedHat based distributions).

Here is the short algorithm on how to prepare .deb package from clamav source tarball:

1. Install checkinstall:
sudo aptitude -y install checkinstall (Ubuntu, Debian and related distributions)
or
sudo yum install -y checkinstall
(for rpm based distributions, please note that checkinstall usually isn’t included to standard Fedora/RedHat repositories, so you will need to link up third party repo like DAG)
or
compile checkinstall from sources

2. Get clamav sources:
wget http://mesh.dl.sourceforge.net/sourceforge/clamav/clamav-0.81.tar.gz (as an example)

3. Install libraries that might be necessary for clamav compilation:
sudo aptitude install libgmp3 libgmp3-dev
(this command is applicable for Debian and certainly will be different for Fedora or RedHat)

4. Compile clamav:
tar xvfz clamav-0.81.tar.gz
cd clamav-0.81/
./configure --sysconfdir=/etc
make

5. Run checkinstall and follow its intuitive instructions (enter package description etc.):
sudo checkinstall -D make install

6. When finished you’ll get clamav-0.81_0.81-1_i386.deb (or rpm package if you use Fedora/RedHat/CentOs) you may want to install with sudo dpkg -i clamav-0.81_0.81-1_i386.deb (or sudo rpm -i ...) or move to another PC for later installation.

No comments: