October 10, 2005

CLI Magic: CheckInstall

Author: Joe Barr

OK, you one-click installers, listen up! In spite of the early dementia no doubt being brought on by living in a GUI cocoon, there's a chance you might learn something from this week's CLI Magic. Here's the thing: given the ease of installing free software apps these days, especially those installed outside your distro's package management, how do you get rid of that great game you installed from scratch last week when you learn it opens your system up to hostile takeover? Think that just removing the executable does the trick? Think again, oh rodent lover. Now you're ready to learn about CheckInstall.All the major package management tools provide easy-on/easy-off program installation and removal, so no big deal. But no matter what your favorite distribution, if you like to sample free software offerings, someday your just-gotta-have-it app is not going to be available as a package in whatever scheme your distro uses. It doesn't matter whether your distro uses Deb, RPM, or another packaging scheme: it's going to happen. You're going to have to install from source code using ./configure, make, and make install, and the app will live outside the confines of your package manager. Such apps -- installed outside the normal package management -- become difficult to remove. Why? Because there just isn't any easy way to know exactly what has to go, and that's exactly what inspired Felipe Eduardo Sánchez Díaz Durán to write CheckInstall.

The magic in CheckInstall is that it learns everything your new app or package will add to your system, and then creates a binary installable package geared to the package manager you use, whether that be Slackware, RPM, or Debian. Optionally, it will also install the newly created package. But whether you install then or later, when the time comes that you want to remove the package from your system, all you need to do is run the appropriate command for your package manager.

CheckInstall is available for download here as a source tarball or as a Slackware, RPM, or Debian package. If you're running Slackware, you can find CheckInstall in the Package Broswer. That's how I installed it on my Slackware box. Here's how I installed from the source code on my SUSE box. Refer to the README for more detailed instructions.

After decompressing the tarball, I entered the checkinstall-1.6.0 subdirectory and from the command line entered the following commands:


make
su
make install

Finally, copy the executable script checkinstall from the installation directory to a directory in root's path. I chose /sbin.

Before using CheckInstall, it's a good idea to make at least a few minimal changes to the checkinstallrc file. If you've installed from a package designed for your distribution, these changes may already be done for you. Edit the checkinstallrc-dist file found in the installation directory, then move it to /usr/local/lib/checkinstall/checkinstallrc.

Find the following text in the checkinstallrc-dist file:

# Default package type. Leave it empty to enable asking everytime
#   S : Slackware
#   R : RPM
#   D : Debian

INSTYPE=""

Then insert the appropriate code (S/R/D) between the "" marks so that the final line reads:


INSTYPE="R"

or whatever is right for you. This will prevent checkinstall from asking you what format package to build each time it's run.

Now let's give it a whirl. I downloaded and decompressed the source code tarball for the beta version of the popular arcade game, LBreakout2. Then, after entering the lbreakout2-2.6beta directory, I executed the first two commands of the familiar free software mantra, ./configure, make, and make install. NOTE: Don't do the make install, just ./configure and make.

The third command is replaced with checkinstall. Run it as root, just as you would normally do make install. Be sure you are still in the installation directory of the application you want to create a package for.

The first time you run checkinstall, the following will appear:

checkinstall 1.6.0, Copyright 2002 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]:

Hit enter to answer yes.

Next, you'll be asked for a description:

Please write a description for the package.
End your description with an empty line or EOF.
>>

I entered "Mission critical - cool arcade game" and hit enter twice.

Then the following screen appeared at my console:

**************************************
**** RPM package creation selected ***
**************************************

This package will be built according to these values:

1 - Summary: [ Mission critical cool arcade game ]
2 - Name: [ lbreakout2 ]
3 - Version: [ 2.6beta ]
4 - Release: [ 1 ]
5 - License: [ GPL ]
6 - Group: [ Applications/System ]
7 - Architecture: [ i386 ]
8 - Source location: [ lbreakout2-2.6beta ]
9 - Alternate source location: [ ]
10 - Requires: [ ]
11 - Provides: [ lbreakout2 ]

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

Again, I simply hit enter to continue. And continue it did, with lines scrolling fast so quickly I couldn't read them all as it created a temporary directory to do it's version of "make install" into to learn the secrets of the installation. Note that the package was not really installed on my system, it merely created an RPM for me to install later. What it told me was:

 Done. The new package has been saved to

/usr/src/packages/RPMS/i386/lbreakout2-2.6beta-1.i386.rpm
You can install it in your system anytime using:

rpm -i lbreakout2-2.6beta-1.i386.rpm

In reality, I found that I had to specify the complete file spec, not just the file name, but the result was the same. Not only was lbreakout2 installed on my system, the package management system was aware of it, and I could easily remove all traces of it with the rpm -e command.

There is a lot more power, and other uses, for CheckInstall. But you'll never learn any of them if you don't get started somewhere, and creating appropriate packages for your distribution is a great way to do that.

Click Here!