Installing Upgrading and Removing Packages

The most important package management features enable installing, upgrading, and removing packages. With rpm, you can install packages using either the -i or-U operation. As Table 11.1 reveals, -i installs a package only if a package of the same name isn't already installed, whereas -U will install a package or upgrade an existing package. These operations are often combined with the -v and -h options to produce a series of hash marks as a progress indicator:

Fixing a Corrupt RPM Database

If you kill rpm or the system crashes while it's working, the result can be a lock on the RPM database file and corruption of the database itself. The symptom is that you can no longer use rpm to upgrade, install, or remove packages. GUI tools may also complain or fail to run. In most cases, you can correct the matter by typing the following commands:

# rpm -vv -rebuilddb

If this procedure fails to work, you may need to engage in a more lengthy recovery process, which is outlined at http://www.rpm.org/hintskinks/repairdb/.

If rpm responds to an installation attempt with a complaint of a dependency problem, you have several options for how to proceed, including:

Abandon the Installation The simplest, but least productive, solution is to abandon the attempt to install the program. This will leave the package uninstalled.

Fix the Dependency Problem You can attempt to correct the problem by installing additional packages, upgrading too-old packages, or uninstalling packages that hold conflicting files. Doing this will likely involve tracking down new packages and installing them. Particularly when your system has old versions of packages, you may find yourself in a nasty cycle of upgradesā€”upgrading a depended-upon package may require upgrading a package upon which it depends, and so on for several layers. These upgrades may break some already-installed packages. Installing new packages is usually easier, but you must locate them first.

Tip If you can't figure out what package to install to meet a dependency, go to the RPM Find database (http://www.rpmfind.net or http://rpmfind.net). Enter the name of the depended-upon package or file, as reported by rpm, in the search field. You can download a matching file directly or try to find a package of the specified name on your distribution's installation media.

Override the Complaint The -nodeps option disables dependency checks. You should use this option cautiously, if at all, and only when you're sure the dependency isn't critical or is met in a way that isn't reflected in the RPM database. The -force option enables you to install a package even if it means overwriting existing files. Doing so can cause problems down the line if and when you want to uninstall one package. It can also break the already-installed package if the new files aren't compatible.

Rebuild the Package Some dependency problems can be fixed by rebuilding a package. Specifically, if your system has an older version of a depended-upon package than the one a binary package requires, rebuilding the package from source code may fix the problem. This isn't a guaranteed solution, though, and even if it works, it may require installing additional development packages. Consult the upcoming section, "Rebuilding a Package," for more details.

If you install a package and subsequently decide you don't want to use it, you can remove it with the -e operation, as in:

Note that this command takes a package name, not a package filename, as an option. Package filenames are needed for installation and upgrade operations because rpm must know where to look to find the package files; however, the original package filename is unimportant after it's installed, so the package name is used for uninstallation operations.

As with installation and upgrades, uninstallation can run into dependency problems. If you plan to uninstall depended-upon packages, you may as well add them to the list of packages and try again; rpm will check all dependencies and complain only if a package you didn't list depends on one you're trying to remove.

0 0

Post a comment