Using Package Installers

What are packages anyway?

You can think of packages as installers. In Red Hat/Fedora, Red Hat Package Manager (RPM) is the primary tool. Debian-based distributions use the Debian Package Manager, dpkg. Both of these are very low-level tools that install individual applications, but don’t manage whole systems very well.

Higher-level tools monitor entire systems, and manage upgrades and updates. These tools include APT on Debians like Ubuntu, and Yum for Red Hat/Fedora or in fact most distributions.

The basic idea of package management is to group the tens of thousands of installed files on your computer into a manageable set of packages that allow the administrator to easily install and uninstall them from the computer. For the moment we’ll look at the RPM-based system.

 

Checking the Integrity of Packages Using md5 Checksums

You should check the packages you download to make sure you don’t have a download error, and also to confirm the packages haven’t been tampered with.

1. Most packages will have a small associated checksum file. Open the file and note the number.

2. In the shell of your preference, type the command:

md5sum packagename.rpm
or
sum packagename.rpm

3. Compare the calculated checksum that results with the one listed in the checksum file.

4. If the checksums do not match, it may have been caused by an error during downloading, or may indicate that tampering has occurred.

 

RPM

RPM, however, extends this notion substantially. Each RPM package contains all the information needed to install itself on your computer:

what the package does,

what other packages it may depend upon,

what capabilities the package brings to your system, and

where the files should go on your computer.

Your operating system keeps a database of every package installed on your computer and its capabilities and dependencies.

 

Learning to RPM

Before trying graphical “point-and-click” tools for managing packages, look at the RPM command itself.

Documentation for RPM is very thorough – see the man page.

The web site www.rpm.org is a treasure-trove of HOW-TOs.

It includes the excellent book Maximum RPM, the best reference on RPM itself. (And mandatory reading for anyone wanting to build their own RPM packages.)

 

Basic RPM Options

RPM is invoked with the command:

rpm

Followed by options:

-i = Install a package

-b = Build New Package

-q = Query information from installed or uninstalled packages

-U = Upgrade packages on the system

-F = Freshen packages existing on the system

-e = Uninstall packages from the system

-V = Verify the validity of packages on the system, or an uninstalled package

 

Installing RPM Packages

How do I install a new package, or upgrade it if it already exists? Or:

rpm -Uvh package.rpm

This is the most important RPM command to know!

rpm -Fvh *.rpm

rpm -e package

Some applications, like OpenOffice, will download as a whole directory full of rpm files. Trying to install them yourself, in the right order, is tricky if not impossible.

Use the command:

rpm –Uvh *rpm

to perform the rpm-based installation.

 

Querying Package Info

rpm -qa | less

rpm -qi package

rpm -ql package

 

Further Queries

rpm -qilp package.rpm

rpm -qf /usr/bin/weirdo

rpm -qilf /usr/bin/weirdo

 

Verifying Packages

rpm -Va

rpm -Va

rpm -Vv package

rpm -K –nopgp package.rpm

 

Building From a “Source” Package

Sometimes you’ll get an RPM that contains only source code, not compiled binaries for your specific computer.

rpmbuild –rebuild package.src.rpm

then

rpm -Uvh package.rpm

 

Optimizing the rpm Database

If your system has lots of packages installed, your queries may run quite slowly. You should optimize the RPM database periodically:

rpm –rebuilddb

 

GUI Tools for rpms

In Red Hat/Fedora, choose Applications > Add/Remove Software.

 

In SUSE, open YAST > Software > Software Management.

 

Assignment: Installing an rpm

Go to freshrpms.net.

Select the package list for the Fedora version on which you’re currently running.

Browse the packages and select one.

Download it and install it.

 

The Debian Package Manager

Of course, not every system is a Red Hat system. Probably the most popular other package manager is the Debian Package Manager, or dpkg.

The general format of a Debian package file (.deb) is:

packagename_packageversion-debversion.deb

 

dpkg Options

-I Queries Package

-i Installs software

-l Lists installed software (equivalent to rpm -qa)

-r Removes the software from the system

 

Basic dpkg Options

dpkg -i package.deb

dpkg -I package.deb

dpkg -c package.deb

dpkg –l

How do I remove ‘package-name’ from the system (as listed by dpkg -l)?

dpkg -r package-name

 

The Debian dselect GUI Tool

dselect is a simple, menu-driven interface which helps install packages. It takes you through the package installation process in the order of the on-screen menu:

In this menu you choose the method to obtain and install the packages.

dselect reads the Packages database and creates a database of the packages available on your system.

Choose your the package you want and press Enter. To exit the Select screen after all of the selections are complete, press Enter. This returns you to the main screen if there are no problems with your selection. You must resolve those problems first. When you are satisfied with any given screen, press Enter.

Dependency conflicts are quite normal and to be expected.

dselect runs through the entire 800 packages and installs the ones that are selected.

 

Debian Package Priorities

The priority of a package indicates how essential or necessary it is. Debian GNU/Linux classifies all packages into four different priority levels:

Packages must be installed for the system to operate correctly and have been installed as part of the base system.

Important packages are found on almost all UNIX-like operating systems.

Packages that comprise the “standard,” character based, Debian GNU/Linux system. The Standard system includes a fairly complete software development environment and GNU Emacs.

Optional packages comprise a fairly complete system. The Optional system includes TeX and the X Window System.

Extra packages are only useful to a small or select group of people, or are installed for a specific purpose. Extra packages might include such programs as electronics and ham radio applications.

Extra packages are abbreviated in dselect as Xtr.

 

A Word About alien

See http://kitenet.net/programs/alien .

This is a program which converts between package formats. From kitenet.net:

“A program that converts between the rpm, dpkg, stampede slp, and slackware tgz file formats. You can use alien to convert it to your preferred package format and install it.

“Alien should not be used to replace important system packages, like sysvinit, shared libraries, or other things that are essential for the functioning of your system.”

 

Flying Solo: Autoconfiguring Packages (Tarballs)

An autoconfiguring package usually has a filename like: “foo-1.0.tar.gz” where the number is a version number.

To install it, first you have to unpack the package to a directory someplace:

Use the gunzip command to uncompress the package:

gunzip foo-1.0.tar.gz
or
tar –zxvf foo-1.0.tar.gz

If you used gunzip you will now have to use the tar command to extract the package archive:

tar -xf foo-1.0.tar

Now change into the foo directory and look for files like ´README’ or ´INSTALL’. The README or INSTALL files will explain how to configure the package, but the general format is:

cd foo-1.0

./configure

make

make install

su –

make install

 

How To make It

./configure invokes a shell script that is distributed with the package that configures the package for you automatically.

It will probe your system through a set of tests that allow it to automatically generate a makefile from a template stored in a file called ‘makefile.in’.

To install your software, you need to explicitly invoke make again with the target install.

 

Where Files End Up

Executables:

/usr/local/bin or /opt/ (among others)

Libraries:

/usr/local/lib

Header files:

/usr/local/include

Man pages:

/usr/local/man/

Info files

/usr/local/info

 

Installing to Your Home Instead

If you want to install the package to your home directory instead of /usr/local, you would use the ‘prefix’ option:

configure –prefix=/home/foo

 

Assignment: Installing a tarball

Go to www.nagios.org.

Select a download site and download the tar.gz package.

Unpack it in an appropriate place.

Read the INSTALLATION file.

Perform the installation.

Further Study

Learn more about the wave of the future, Yum, at Roderick Smith’s article “Linux Software Management with yum,” at
http://www.linux-mag.com/id/2908/