LWN.net Logo

Sponsored Link
2.6 Embedded Linux Development Kits

Latest Hardware-Optimized 2.6 distributions and Eclipse 3.0-based development tools for ARM, MIPS PowerPC, x86 and more

You are not logged in
Log in now
Create an account
Subscribe to LWN
Summary page
Return to the Development page
Recent Features

LWN.net Weekly Edition for February 24, 2005

LWN.net Weekly Edition for February 17, 2005

The Grumpy Editor plugs in his camera

LWN.net Weekly Edition for February 10, 2005

LWN.net Weekly Edition for February 3, 2005

Thanks to:

Astaro Firewall with Anti-Virus

Printable page

[Rackspace Managed Hosting]

Building Packages From Source With CheckInstall

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 systems administrators. 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.

Developed and maintained by Felipe Eduardo Sánchez Díaz Durán, CheckInstall consists of a collection of shell scripts and a library. With it, you can build an .rpm or .deb or .tgz package that will install using the associated packaging tools.

The easiest way to use CheckInstall is in place of the "make install" portion of a typical build process. Executing CheckInstall will run "make install" using the installwatch script. This script keeps track of the "make install", then feeds the results 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 typical 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, CheckIinstall allows you to edit all of the basic fields that describe a package, in this case an RPM package. The fields are pre-filled with reasonable data, however you can change any of the fields to new values. It's likely that 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 removal scripts.

There are a few things you need to do to get setup for building a package with CheckInstall. First, you'll need a file named "description-pak" which should contain the program name and 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 or script for the software installation. For example, you might find a very good program that is only released in binary format 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. The "--install=yes" option causes CheckInstall to perform the package installation. 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 spec files.

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 named: "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 a command like: "tar xzvf backup-<datetime>-pre-<packagename>-<version>.tgz -C /".

As for the future direction of CheckInstall development, Felipe said this:

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, it will become an even more required tool for systems administrators, along with yum and apt.

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

(Log in to post comments)

  Building Packages From Source With CheckInstall
(Posted Jun 3, 2004 7:42 UTC (Thu) by subscriber snitm) (Post reply)

seems overly rigid to me; Klemmer is easily excited. Silver bullet software packaging tools, while mildly amusing, will always produce packages that fall short of finely crafted rpm or deb packages.

  Building Packages From Source With CheckInstall
(Posted Jun 4, 2004 1:15 UTC (Fri) by subscriber X-Nc) (Post reply)

> seems overly rigid to me; Klemmer is easily excited.

I only touched the surface of the utility. And while it is true that I am easily excited, that doesn't mean checkinstall isn't a great tool to have around. Oh, and call me Joe. :-)

> Silver bullet software packaging tools, while mildly amusing, will always produce
> packages that fall short of finely crafted rpm or deb packages.

If you read the review again you'll see that I never claim this to be a "Silver Bullet". It is a valuable addition to any admins toolbox. You can do anything with checkinstall that you can by hand. And while I agree that the meticulous handcrafting of the configuration for a package has the potential for a more optimized result, checkinstall is far more than just "mildly amusing".

But don't take my word for it. Try it out. Test all of its features. I get the feeling that you have never looked at the utility. Give it a whirl and then make a decision as to it's usefulness for your situation. Who knows? It might not be useful for you at all. But it might be a great tool for someone else. That's what it's all about anyway, right?

  Building Packages From Source With CheckInstall
(Posted Jun 4, 2004 14:06 UTC (Fri) by subscriber pflugstad) (Post reply)

I've been using this for at least a year now for adding packages to my Debian system. It works - it's easy to use, and it makes managing hand-built packages a LOT easier. It's especially useful for managing things that go in /usr/local.

It's not a silver bullet, but it's not meant to be.

Copyright (©) 2004, Eklektix, Inc.
Linux (®) is a registered trademark of Linus Torvalds
Powered by Rackspace Managed Hosting.