Chapter 4. Packages - Managing software

Table of Contents
4.1. Tarballs
4.2. RPM - The Redhat Package Manager
4.3. The Debian way
4.3.1. APT
4.3.2. apt-get: Package management was never so easy!

Like other operating systems, Linux also has pretty well-defined ways of installing software on the system. The software is usually distributed in the form of bundles called ``packages''. The packages themselves come in many different forms, depending on what they contain and what distribution they are designed for. Software is usually distributed as source code, or in the form of ready-to-use binaries, compiled for particular system environments.

4.1. Tarballs

Tarballs are the tarred gzipped files (with extension .tar.gz or.TGZ) that are used to distribute source code. These generally use the GNU Autotools that enable the user to compile the source code on the target system. The GNU Autotools are made of three utilities - autoconf, automake and libtool, which allow developers to create software that can be compiled on the variety of system, using facilities available on the target machine.

  1. First unzip and untar the package in some folder.

          tar -xzf <filename>
          cd <package-directory>
         

Once inside the newly created directory, use the steps listed. These allow an end user to compile the packaged source code without even knowing much about C Programming! Only requirement is that the compiler, relevant libraries and header files should be installed on the system

  1. Use the following command to configure the source code in order to compile correctly on the current system.

    ./configure

    A number of options can be passed to the configure script, which can be used to enable/disable specific parts of the software or to specify alternate libraries, etc. A list of the possible options can be obtained from the script itself:

    ./configure --help

  1. The next two commands are used to compile as well as install the software on the system. Of these, only the second one requires root privileges, since it is going to install files all over the place.

         make
         make install
        

The only problem with this approach is that there is no way to keep track of all the installed files on the system. Also there might not always be an easy way to cleanly uninstall a software from the system. One way is to use the following command to see what files get installed where.

make -n install

4.2. RPM - The Redhat Package Manager

The Redhat Package Manager or ``RPM'' for short is a common way to distribute precompiled binaries as well as source code, used in a few popular distributions like Redhat, SuSE, Mandrake. The binaries are in the form of `*.rpm' files which may be simply called rpm's. RPM maintains a database of all the packages installed on a system along with the services that they provide and require. This database is used to ensure that all the files on the system are accounted for during installation or removal of packages. It is also used to verify all dependencies that may exist among packages. These are manipulated by the rpm command with relevant options, some of which are listed below.

Installing
rpm -ivh <packagename>

This is used to install a new rpm (package) on the system. RPM is responsible to check for all dependencies required for the specified package. It proceeds with the installation only when they are satisfied, else it exits with an error message.

Upgrading
rpm -Uvh <packagename>

This is used to upgrade an existing package or to install it if it does not already exist. In this case too, RPM will do the necessary dependency checking before any packages are modified.

Uninstalling
rpm -e <packagename>

This is used to erase, ie, uninstall existing packages on the system. Again, no action will be take unless all dependencies are satisfied; RPM will erase the package only if it determines that none of the files it provides are needed by any other package.

Querying the database
rpm -q <packagename>

The rpm command can also be used to query installed packages using the -q commandline option. This can be supplemented with other options to request specific information about a package. The rpm manpage provides excellent help on all the different things that can be done with rpm.

Source rpm's

Sometimes packages may be distributed in the form of source inside rpm files, which are now named with an extension of ``.srpm'', simply called as source rpm's. This is way to combine RPM's package management ability with the versatility of source tarballs. The srpm contains the source tarball along with a ``.spec'' file, that specifies all the information that RPM requires to process the tarball. Here's is only one thing that the user can do with the srpm - rebuild it!

rpm --rebuild <srpm-file>

RPM opens the srpm and processes the tarball inside just as a normal user would have used the make commands. At the end, a new rpm binary package is created which can be installed in the system.

You can also use the SRPM to install the source could on your system, by using the normal install options. Everything will be installed somewhere under /usr/src/Redhat/ Now you may use it just like any other source tarball!

NoteMaximum RPM
 

Extensive information about RPM is available in the form of a book called Maximum RPM, published by Redhat. This book describes everything there is to know about RPM right from an introduction to package management, to creating your own packages and even using the RPM library API to create applications that may include package management abilities.

NoteSystem Installation
 

On distributions which use RPM such as Redhat and SuSE, the installer itself is capable of taking care of dependencies. Thus when installing Linux for the first time, in custom mode, the user can just specify what packages are needed. The installer scripts will automatically include packages to satisfy any dependencies and prompt the user to confirm the selected packages.

4.3. The Debian way

Debian uses a package format called "deb" to distribute software. All the package management is done using a set of tools that do dependency checking, remote installs etc very well.

4.3.1. APT

Well, here's what the Debian manpages have to say about APT (Advanced Package Tool:

APT is a management system for software packages. It is still under development; the snazzy front ends are not yet available. In the meantime, please see apt-get(8).

4.3.2. apt-get: Package management was never so easy!

apt-get is the basic tool that you will need the most to maintain packages on your system. It has an entire database of packages available for installation, and based on user commands, it will install, uninstall, upgrade, etc and help to keep the system in a sane condition at all types. Let us look at what all is involved in this process.

Sources

apt-get needs to know a few places from where it can pick up packages for installation. This list is maintained in a file called /etc/apt/sources.list. Here is a sample source list:

Example 4-1. Listing of /etc/apt/sources.list

$ cat /etc/apt/sources.list

# See sources.list(5) for more information, especialy
# Remember that you can only use http, ftp or file URIs
# CDROMs are managed through the apt-cdrom tool.

#deb http://http.us.debian.org/debian stable main contrib non-free
#deb http://non-us.debian.org/debian-non-US stable/non-US main contrib non-free

deb http://http.us.debian.org/debian unstable main contrib non-free
deb http://non-us.debian.org/debian-non-US unstable/non-US main contrib non-free
# Uncomment if you want the apt-get source function to work
#deb-src http://http.us.debian.org/debian stable main contrib non-free
#deb-src http://non-us.debian.org/debian-non-US stable non-US

#deb file:/mnt/woody1/debian unstable contrib main non-free
#deb file:/mnt/woody2/debian unstable contrib main non-free
#deb file:/mnt/woody3/debian unstable contrib main non-free
Cache

As we can see, the system can be configured to take packages from many different locations. Once these are downloaded, they are placed in a cache area - /var/cache/apt/.

Dependency checking

The deb packages maintain a list of dependencies that need to be installed for a particular package to work. When you try to install or even upgrade a package, apt will go about looking for unfulfilled dependencies and then create a list of things that need to be upgraded or installed, before the required package is processed.

Example 4-2. Package Dependencies in Debian

# apt-get install kword

Reading Package Lists... Done
Building Dependency Tree... Done
The following extra packages will be installed:
  kdebase-libs koffice-libs 
The following NEW packages will be installed:
  kdebase-libs koffice-libs kword 
0 packages upgraded, 3 newly installed, 0 to remove and 160  not upgraded.

Since it already has a list of all available packages with it, the system will simply prompt for a confirmation to start fulfilling all the dependencies. The user simply doesn't have to worry about keeping his system up-to-date in terms of those dependencies.

dpkg and dselect

dpkg is a tool that allows the user to work on individual packages, such as quering its contents, checking for version, configuration etc. It can also be used when you need to install an individual deb file you may have. This file will contain all the dependency information, which dpkg will process just like apt-get.

dselect is a text front end for apt-get. It allows the user to configure the sources list, select packages from a list of known packages etc. It is useful when you need to explore the package trees looking for things that may seem interesting to you.