Building Packages From Source With CheckInstall

By Joe Klemmer <>

Most Linux distributions today use some form of package management to deal with dependencies and to make upgrades and installation of software easier for the ever overworked SysAdmins. The most popular formats for packages are Red Hat based RPM files, Debian DEB files, Slackware TGZ files and the build-from-source Ports-like method of distributions such as Gentoo, Lunar Linux, et. al. However, there exist many apps and tools which are only released as source tarballs using the ubiquitous "configure; make; make install" or binary only tarballs. If you want to use these tarballs but also manage them in the same way you do the rest of your OS you had to deal with jumping through the hoops required of the package management systems used by your distribution. That is until now, thanks to a wonderful little utility called CheckInstall [1].

Developed and maintained by Felipe Eduardo Sánchez Díaz Durán, it actually consists of a few shell scripts and a library. With it you can build an .rpm or .deb or .tgz package that will install using their respective packaging tools. The easiest way to use it is in place of the "make install" portion of the above build process. Executing checkinstall will run "make install" using one of the scripts, installwatch. This script keeps track of the "make install" then feeds this info to checkinstall in order for it to build the package. These tools allow for the ability to build and manage any self-made packages as easily as any binary package you might download from the 'Net. They give you great flexibility in how you build the package and even how dependencies are managed. Let's see what a run of checkinstall might look like -

Please choose the packaging method you want to use.
Slackware [S], RPM [R] or Debian [D]? R

This package will be built according to these values: 

1 -  Summary: [ libcgi 1.0 ]
2 -  Name:    [ libcgi ]
3 -  Version: [ 1.0 ]
4 -  Release: [ 1 ]
5 -  License: [ GPL ]
6 -  Group:   [ Applications/System ]
7 -  Architecture: [ i386 ]
8 -  Source location: [ libcgi-1.0 ]
9 -  Alternate source location: [  ]
10 - Provides: [  ]
11 - Requires: [  ]

Enter a number to change any of them or press ENTER to continue: 

As you can see there are all of the basic fields for a package, in this case an RPM package. The fields are filled in with reasonable data. However, you can change any of the fields in brackets. It's likely you'll want to change #6 and possibly #5, #7 and #11. You also have the ability to run pre and post install scripts as well as pre and post remove scripts. There are a few things you need to do to setup for building a package with checkinstall. First, you'll need a file named "description-pak" which should contain the program name & version followed by a description. You should also create a subdirectory named "doc-pak" in which you can put the text files like README, ChangeLog and the like.

One very nice thing you can do with checkinstall is tell it to run a specific program/script for the install part. For an example, you might find a very good program that is only released in binary format[2] with a script called "setup" that's used to install it. You can build a package for it by telling checkinstall to use the "setup" script for the install portion. An example command might look like this -

$ checkinstall -R --install=yes ./setup

This command line will build and install an RPM but using the setup script to do the actual installing. By default checkinstall builds the package but doesn't install it. If you want to build and install a package that's what the "--install=yes" is for. You can also use the switch "--rpmu" to do an upgrade of a package that is already installed. Once a package is made using checkinstall it is virtually impossible to tell it apart from a package built with a hand generated spec file. There's even a nice feature for saving the spec file that checkinstall makes in order to build the packages. This generated spec file is normally deleted after the package has been built but if you pass the switch "--delspec=no" it will leave the spec file behind. With this as a starting point you can easily ramp up your skill at hand building them.

Lastly, whenever you install a package with checkinstall, it will automatically make a backup tarball of the currently installed package, if one exists. You'll find a file name "backup-<datetime>-pre-<packagename>-<version>.tgz" in the directory from which you built the package. Should anything go wrong with the newly created package you can roll back to the previous version using something like "tar xzvf backup-<datetime>-pre-<packagename>-<version>.tgz -C /".

As for the future, Felipe said this for a look into the direction he'd like to see checkinstall go:

"One interesting feature planned for the not-so-distant future is the evolution of checkinstall into a tool that will do the whole software install for you: download the source, configure, compile, install and package it. All in one step."

If he is able to get this functionality into checkinstall I think it will become an even more required tool for SysAdmins, along with yum and apt.

Bottom line: CheckInstall is a fantastic tool that should be on every administrators and developers need-to-have list.

[1] The CheckInstall home page is located at
[2] I have used this method to make RPMS out of various commercial programs and tools that aren't distributed with source.