Installing and Maintaining Software

yum and apt-get

Most all modern distributions of Linux and even commercial Unix systems support the distribution of application software in the form of packages. A package is a compressed file archive containing all of the files that come with a particular application. The files are usually stored in the package according to their relative installation paths on your system. Most packages also contain installation instructions for the OS, as well as a list of any other packages that are dependencies (prerequisites required for installation).

Common types of Linux packages include .deb, .rpm, and .tgz. Since Linux packages do not usually contain the dependencies necessary to install them, many Linux distributions use package managers that automatically read dependencies files and download the packages needed before proceeding with the installation. Some examples of package managers are yum and apt. Yum is the tool used to install and update software on Red Hat based systems. Some other distributions also use yum. Systems based off the Debian distribution, which includes Ubuntu, use apt and the apt-get command. Package management may be done either from a graphical user interface or from the command line. The command line tools allow automated maintenance of many systems.

Package managers maintain database files to track the installed packages. Thus, despite the files for applications being mixed in directories with files from other applications, it is not difficult to update or remove packages. Systems may be updated manually or may periodically check for updates and automatically download updated packages.

Repositories

Collections of packages available for download are stored on servers called repositories. Each Linux distribution maintains repositories for commonly used packages. There are also some third party repositories of lesser used applications. The third party repositories are usually maintained by enthusiasts. Some are very good, but one should verify the reputation of the repository before using it. Companies that provide free versions of certain non-open source applications often also maintain a repository. Adobe is an example of a company that does this. Instructions for adding new repositories to your package manager vary with distributions, version and repository, but can generally be found by searching the Internet.

Compiling Programs

Most applications are distributed as packages, but there are still cases where an application needs to be manually compiled and installed. After downloading the source code of a application, one should read the README file for installation instructions. The instructions vary by application, but in most cases a simple three step procedure is suggested. These steps are briefly described below and an additional installation tool is described to give better organization to the set of manually installed programs.

Configure

Most distribution of Linux applications as source code include a shell script called configure. This shell is created by the developers of the application using a tool called autoconf. Although each configure script checks for different things, the result is fairly consistent. Configure exams the system to verify that the needed tools and libraries to compile the application are available. It also prepares two files (config.h and Makefile) that are used when compiling the application.

Dependency Hell

If the configure does not find the needed libraries, it will report what is still needed. If this occurs, make note of the missing libraries and install those and then run configure again. Check if the missing libraries can be installed with yum or apt-get. If they are not available, then they must be manually compiled and installed. In some cases, a system will not have the libraries needed to compile the needed libraries, so additional libraries must be installed first.

Make

Compiling the program is usually accomplished by simply typing the make command. Make is a very useful tool for developing and compiling applications. Not only will it invoke the compiler (usually gcc) for each file and the linker to build the executable file; but as the program is being developed, it can shorten the compilation time by only compiling files affected by changes to the source code since the last compile.

Make Install

The make command is also used move the needed files into their installation directory. It is suggested to first run make with no options to make sure it compiles and then run make install to install the files.

The default action of running configure, make followed by make install is usually to install everything under the directory /usr/local/. However, the files would then be mixed with files from other manually installed programs. Without the aide of an external tool or a package manager, this could lead to a big mess that is difficult to maintain. Updating or removing programs is especially difficult in this scenario.

INSTALL Tool

Here is a simple tool to help bring organization to manually compiled and installed applications. It consists of a perl script and a few shell scripts. The concept of the tool is that all of the files for each installed application should be in one directory tree and then the tool can be used to create or delete symbolic links under /usr/local/ to the actual files. Thus applications can be easily removed or updated as needed.

To use the tool, first create a /usr/local/programs/ directory. Then install the following compressed tar archive in /usr/local/programs/. You may want to manually create a symbolic from the /usr/local/bin/ directory to the inst perl script. I usually copy the shell scripts into the /usr/local/programs directory.

Download the Install program INST.tgz

After downloading the source code for a program to be compiled and installed, create a new directory under /usr/local/programs/ to install the program to. The prefix option to configure sets the Makefile so that make install will install the files to the desired location. The example command lines below show how to compile and install a program called foo-1.5.

Note

The 1.5 for foo-1.5 is the version of the application. It is a idea to track the version number for future reference.

# mkdir /usr/local/programs/foo-1.5
# ./configure --prefix=/usr/local/programs/foo-1.5
# make
# make install
# cd /usr/local/programs
# ./INSTALL foo-1.5

A simple test program to use for this experiment is the hello sample program from GNU. Find it on the GNU Web site