How does the RPM Database typically become corrupt?

We are automating some deploy scripts which uninstall/install RPMs. I've seen on more than one of our hosts that rpm -qa returns something like:

# rpm -qa | grep tcl
tcl-8.5.7-6.el6.x86_64
tcl-8.5.7-6.el6.x86_64
tcl-8.5.7-6.el6.x86_64
tcl-8.5.7-6.el6.x86_64
tcl-8.5.7-6.el6.x86_64
tcl-8.5.7-6.el6.x86_64

How does this happen using rpm -e and rpm -i? And is there a way to prevent this? If I run rpm -e in this case, I get

# rpm -e tcl-8.5.7-6.el6
error: "tcl-8.5.7-6.el6" specifies multiple packages:
  tcl-8.5.7-6.el6.x86_64
  tcl-8.5.7-6.el6.x86_64
  tcl-8.5.7-6.el6.x86_64
  tcl-8.5.7-6.el6.x86_64
  tcl-8.5.7-6.el6.x86_64
  tcl-8.5.7-6.el6.x86_64

So I had to use the -vv --allmatches --nodeps --noscripts --notriggers switches


Solution 1:

Anon,

Are you in a position to try rpm --rebuilddb, if you haven't already?

http://www.rpm.org/max-rpm/rpm.8.html

Alternately, are you in a position to use yum install, instead of rpm? Yum will usually take better care of your database.