-->

Previous | Table of Contents | Next

Page 37

Chapter 3

Using RPM to Erase
Packages

Page 38

Table 3.1. Erase-mode command syntax and options.

rpm -e (or --erase) Options pkg1...pkgN
Parameters
pkg1...pkgN One or more installed packages
Erase-Specific Options Section
--test Perform erase tests only 3.3.1
--noscripts Do not execute pre- and postuninstall scripts 3.3.3
--nodeps Do not check dependencies 3.3.2
General Options Section
-vv Display debugging information 3.2.1
--root <path> Set alternate root to <path> 3.3.5
--rcfile <rcfile> Set alternate rpmrc file to <rcfile> 3.3.4
--dbpath <path> Use <path> to find the RPM database 3.3.6

3.1. rpm -e: What Does It Do?

The rpm -e command (--erase is equivalent) removes, or erases, one or more packages from the system. RPM performs a series of steps whenever it erases a package:

  1. It checks the RPM database to make sure that no other packages depend on the package being erased.
  2. It executes a preuninstall script (if one exists).
  3. It checks whether any of the package's config files have been modified. If so, it saves copies of them.
  4. It reviews the RPM database to find every file listed as being part of the package, and if a file does not belong to another package, deletes the file.
  5. It executes a postuninstall script (if one exists).
  6. It removes all traces of the package (and the files belonging to it) from the RPM database.

That's quite a bit of activity for a single command. No wonder RPM can be such a time-saver!

3.2. Erasing a Package

The most basic erase command is


# rpm -e eject

#

Page 39

In this case, the eject package was erased. There isn't much in the way of feedback, is there? Could we get more if we added -v?


# rpm -ev eject

#

Still nothing. However, another option can be counted on to give a wealth of information. You'll learn about it in the next section.

3.2.1. Getting More Information with -vv

By adding -vv to the command line, we can often get a better feel for what's going on inside RPM. The -vv option was really meant for the RPM developers, and its output may change, but it is a great way to gain insight into RPM's inner workings. Let's try it with rpm -e:


# rpm -evv eject

D: uninstalling record number 286040

D: running preuninstall script (if any)

D: removing files test = 0

D: /usr/man/man1/eject.1 - removing

D: /usr/bin/eject - removing

D: running postuninstall script (if any)

D: removing database entry

D: removing name index

D: removing group index

D: removing file index for /usr/bin/eject

D: removing file index for /usr/man/man1/eject.1

#

Although -v had no effect on RPM's output, -vv gave us a torrent of output. But what does it tell us?

First, RPM displays the package's record number. The number is normally of use only to people that work on RPM's database code.

Next, RPM executes a preuninstall script, if one exists. This script can execute any commands required to remove the package before any files are actually deleted.

The files test = 0 line indicates that RPM is to actually erase the package. If the number had been nonzero, RPM would only be performing a test of the package erasure. This happens when the --test option is used. Refer to section 3.3.1 for more information on the use of the --test option with rpm -e.

The next two lines log the actual removal of the files comprising the package. Packages with many files can result in a lot of output when using -vv!

Next, RPM executes a postuninstall script, if one exists. Like the preuninstall script, this script is used to perform any processing required to cleanly erase the package. Unlike the preuninstall script, however, the postuninstall script runs after all the package's files have been removed.

Page 40

Finally, the last five lines show the process RPM uses to remove every trace of the package from its database. From the messages, we can see that the database contains some per-package data, followed by information on every file installed by the package.

3.3. Additional Options

If you're interested in a complex command with lots of options, rpm -e is not the place to look. There just aren't that many different ways to erase a package! But there are a few options you should know about.

3.3.1. --test: Go Through the Process of Erasing the Package, But Do Not Erase It

If you're a bit gun-shy about erasing a package, you can use the --test option first to see what rpm -e would do:


# rpm -e --test bother

removing these packages would break dependencies:

bother >= 3.1 is needed by blather-7.9-1

#

It's pretty easy to see that the blather package wouldn't work very well if bother were erased. To be fair, however, RPM wouldn't have erased the package in this example unless we used the --nodeps option, which we'll discuss shortly.

However, if there are no problems erasing the package, you won't see very much:


# rpm -e --test eject

#

We know, based on previous experience, that -v doesn't give us any additional output with rpm -e. However, we do know that -vv works wonders. Let's see what it has to say:


# rpm -evv --test eject

D: uninstalling record number 286040

D: running preuninstall script (if any)

D: would remove files test = 1

D: /usr/man/man1/eject.1 - would remove

D: /usr/bin/eject - would remove

D: running postuninstall script (if any)

D: would remove database entry

#



As you can see, the output is similar to that of a regular erase command using the -vv option, with the following exceptions:

Previous | Table of Contents | Next