LinuxDevCenter.com
oreilly.comSafari Books Online.Conferences.

advertisement


Red Hat and Debian GNU/Linux Package Managers
Pages: 1, 2, 3, 4, 5, 6, 7, 8, 9

When you want to install applications on your Linux system, most often you'll find a binary or a source package containing the application you want, instead of (or in addition to) a .tar.gz file. A package is a file containing the files necessary to install an application. But note that while the package contains the files you need for installation, the application might require the presence of other files or packages that are not included, such as particular libraries (and even specific versions of the libraries), in order to be able to run. Such requirements are known as dependencies.



Package management systems offer many benefits. As a user, you may find you want to query the package database to find out what packages are installed on the system and their versions. As a system administrator, you need tools to install and manage the packages on your system. And, if you are also a developer, you need to know how to build a package for distribution.

Among other things, package managers:

  • Provide tools for installing, updating, removing, and managing the software on your system.

  • Let you install new or upgraded software directly across a network.

  • Tell you what software package a particular file belongs to or what files a package contains.

  • Maintain a database of packages on the system and their state, so you can find out what packages or versions are installed on your system.

  • Provide dependency checking, so you don't mess up your system with incompatible software.

  • Provide PGP, MD5, or other signature verification tools.

  • Provide tools for building packages.

Any user can list or query packages. However, installing, upgrading, or removing packages generally requires superuser privileges. This is because the packages normally are installed in systemwide directories that are writable only by root. Sometimes you can specify an alternate directory, to install, for example, a package into your home directory or into a project directory where you have write permission.

Both RPM and the Debian Package Manager back up old files before installing an updated package. Not only does this let you go back if there is a problem, but also if you've made changes (to configuration files, for example), they aren't completely lost.

The Red Hat Package Manager

The Red Hat Package Manager (RPM) is a freely available packaging system for software distribution and installation. In addition to Red Hat and Red Hat-based distributions, both SuSE and Caldera are among the Linux distributions that use RPM.

Using RPM is straightforward. A single command, rpm, has options to perform all the package functions. For example, to find out if the Emacs editor is installed on your system, you could say:

% rpm -q emacs
emacs-20.4-4

In addition, the GNOME-RPM program provides an X-based graphical frontend to RPM (that can be run even if you are not running GNOME). This section describes the rpm command and then the gnorpm command that runs GNOME-RPM.

The rpm Command

RPM packages are built, installed, and queried with the rpm command. RPM package names usually end with a .rpm extension. rpm has a set of modes, each with its own options. The format of the rpm command is:

rpm [options] [packages]
With a few exceptions, as noted in the lists of options that follow, the first option specifies the rpm mode (e.g., install, query, update, build, etc.), and any remaining options affect that mode.

In the option descriptions that refer to packages, you'll sometimes see them specified as package-name and sometimes as package-file. The package name is the name of the program or application, such as gif2png. The package file is the name of the RPM file: gif2png-2.2.5-1.i386.rpm.

RPM provides a configuration file for specifying frequently used options. The system configuration file is usually /etc/rpmrc, and users can set up their own $HOME/.rpmrc file. You can use the --showrc option to show the values RPM will use for all the options that may be set in an rpmrc file:

rpm --showrc

The rpm command includes FTP and HTTP clients, so you can specify an ftp:// or http:// URL to install or query a package across the Internet. You can use an FTP or HTTP URL wherever package-file is specified in the commands presented here.

Any user can query the RPM database. Most of the other functions require superuser privileges.

General options

The following options can be used with all modes:

--dbpath path

Use path as the path to the RPM database.

--ftpport port

Use port as the FTP port.

--ftpproxy host

Use host as a proxy server for all transfers. Specified if you are FTPing through a firewall system that uses a proxy.

--help

Print a long usage message (running rpm with no options gives a shorter usage message).

--justdb

Update only the database; don't change any files.

--pipe command

Pipe the rpm output to command.

--quiet

Display only error messages.

--rcfile filename

Use filename as the configuration file instead of the system configuration file /etc/rpmrc or $HOME/.rpmrc.

--root dir

Perform all operations within directory dir.

--version

Print the version number of rpm.

-vv

Print debugging information.

Install, upgrade, and freshen options

Install or upgrade an RPM package. The syntax of the install command is:

rpm -i [install-options] package_file ... 
rpm --install [install-options] package_file ... 

To install a new version of a package and remove an existing version at the same time, use the upgrade command instead:

rpm -U [install-options] package_file ... 
rpm --upgrade [install-options] package_file ... 

One feature of -U is that if the package doesn't already exist on the system, it acts like -i and installs it. To prevent that behavior, you can freshen a package instead; in that case, rpm upgrades the package only if an earlier version is already installed. The freshen syntax is:

rpm -F [install-options] package_file ...
rpm --freshen [install-options] package_file ...

Installation and upgrade options are:

--allfiles

Install or upgrade all files.

--badreloc

Used with --relocate to force relocation even if the package is not relocatable.

--excludedocs

Don't install any documentation files.

--excludepath path

Don't install any file whose filename begins with path.

--force

Force the installation. Equivalent to using --replacepkgs, --replacefiles, and --oldpackage.

-h, --hash

Print 50 hash marks as the package archive is unpacked. Use with --version for a nicer display.

--ignorearch

Install even if the binary package is intended for a different architecture.

--ignoreos

Install binary package even if the operating systems don't match.

--ignoresize

Don't check disk space availability before installing.

--includedocs

Install documentation files. This is needed only if excludedocs: 1 is specified in an rpmrc file.

--nodeps

Don't check whether this package depends on the presence of other packages.

--noorder

Don't reorder packages to satisfy dependencies before installing.

--noscripts

Don't execute any preinstall or postinstall scripts.

--notriggers

Don't execute any scripts triggered by package installation.

--oldpackage

Allow an upgrade to replace a newer package with an older one.

--percent

Print percent-completion messages as files are unpacked.

--prefix path

Set the installation prefix to path for relocatable packages.

--replacefiles

Install the packages even if they replace files from other installed packages.

--replacepkgs

Install the packages even if some of them are already installed.

--test

Go through the installation to see what it would do, but don't actually install the package.

Query options

The syntax for the query command is:

rpm -q[information-options] [package-options]
rpm --query[information-options] [package-options]

There are two subsets of query options: package selection options that determine what packages to query and information selection options that determine what information to provide.

Package selection options

package_name

Query the installed package package_name.

-a, --all

Query all installed packages.

-f file, --file file

Find out what package owns file.

-g group, --group group

Find out what packages have group group.

-p package_file

Query the uninstalled package package_file.

--querybynumber num

Query the numth database entry. Primarily useful for debugging.

-qf, --queryformat num

Specify the format for displaying the query output, using tags to represent different types of data (e.g., NAME, FILENAME, DISTRIBUTION). The format specification is a variation of the standard printf formatting. (Use --querytags in the section "Miscellaneous options" to view a list of available tags.

--specfile specfile

Query specfile as if it were a package.

--triggeredby pkg

List packages that trigger installation of package pkg.

--whatrequires capability

List packages that require the given capability to function.

--whatprovides capability

List packages that provide the given capability.

Pages: 1, 2, 3, 4, 5, 6, 7, 8, 9

Next Pagearrow




Linux Online Certification

Linux/Unix System Administration Certificate Series
Linux/Unix System Administration Certificate Series — This course series targets both beginning and intermediate Linux/Unix users who want to acquire advanced system administration skills, and to back those skills up with a Certificate from the University of Illinois Office of Continuing Education.

Enroll today!


Linux Resources
  • Linux Online
  • The Linux FAQ
  • linux.java.net
  • Linux Kernel Archives
  • Kernel Traffic
  • DistroWatch.com


  • Sponsored by: