RPM Database Borked

Issues related to applications and software problems
Post Reply
kbocek
Posts: 242
Joined: 2005/05/30 15:40:15
Location: Benicia CA, USA

RPM Database Borked

Post by kbocek » 2018/07/16 15:36:07

Firefox failed to update and I tried to manually fix it. Turns out this was because of the 6.10 update and I didn't realize it.

But now I've managed to breal the RPM DB:

Code: Select all

$rpm -qa
gpg-pubkey-6b8d79e6-3f49313d
gpg-pubkey-849c449f-4cb9df30
gpg-pubkey-66534c2b-4eff56c5
gpg-pubkey-f2ee9d55-560cfc0a
gpg-pubkey-c105b9de-4e0fd3a3
gpg-pubkey-63189046-5392c50e
gpg-pubkey-baadae52-49beffa4
gpg-pubkey-0608b895-4bd22942
No files. I've run rpmdb --rebuilddb several times. How do I fix this?

kbocek
Posts: 242
Joined: 2005/05/30 15:40:15
Location: Benicia CA, USA

Re: RPM Database Borked

Post by kbocek » 2018/07/16 15:42:25

In my messing around I uninstalled sqlite3. Trying to manually reinstall it:

Code: Select all

$rpm -ivh sqlite-3.6.20-1.el6_7.2.x86_64.rpm
error: sqlite-3.6.20-1.el6_7.2.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: BAD
error: sqlite-3.6.20-1.el6_7.2.x86_64.rpm cannot be installed
And with no signature:

Code: Select all

$rpm -ivh --nosignature sqlite-3.6.20-1.el6_7.2.x86_64.rpm
error: sqlite-3.6.20-1.el6_7.2.x86_64.rpm: Header SHA1 digest: BAD
error: sqlite-3.6.20-1.el6_7.2.x86_64.rpm cannot be installed
Any ideas?

User avatar
TrevorH
Site Admin
Posts: 33202
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: RPM Database Borked

Post by TrevorH » 2018/07/16 15:53:56

Your best hope for recovery is to use rpm2cpio sqlite-3.6.20-1.el6_7.2.x86_64.rpm | cpio -idm to unpack the rpm into the current working directory and then manually copy the files to their correct locations (as root) so that they can be found and rpm can access the database again. However, judging by your first output, I am not sure if this will be successful as it may just let you get access to the broken copy of the database you had before. Once you fix rpm then you should/might be able to use rpm to install sqlite again and update the database so it knows it is installed.

If you have a backup of /var/lib/{rpm,yum} then you might be able to recover from those.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

kbocek
Posts: 242
Joined: 2005/05/30 15:40:15
Location: Benicia CA, USA

Re: RPM Database Borked

Post by kbocek » 2018/07/16 16:03:55

I also see this post:

viewtopic.php?p=215132#p215132

But same thing:

Code: Select all

$rpm -i --nodeps --noscripts --notriggers --excludepath / centos-release-6-9.el6.12.3.x86_64.rpm
error: centos-release-6-9.el6.12.3.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: BAD
error: centos-release-6-9.el6.12.3.x86_64.rpm cannot be installed
I'll try the manual CPIO method.

User avatar
avij
Retired Moderator
Posts: 3046
Joined: 2010/12/01 19:25:52
Location: Helsinki, Finland
Contact:

Re: RPM Database Borked

Post by avij » 2018/07/16 16:13:53

kbocek wrote:
2018/07/16 15:36:07
I've run rpmdb --rebuilddb several times.
If you had not done this, there would have been a much bigger chance of getting your RPM database back.

Essentially, what that command did was that it went through the RPM database to find any working entries and wrote out the new database. And because rpm thought that none of the entries were valid (or did not find any due to some system errors), it wrote an empty (but working!) RPM database.

There's a chance that rpm could have been convinced to not treat the entries in the database as invalid, but it's too late now.

Next time this happens, don't use rpmdb --rebuilddb unless you have a backup of your RPM database first.

kbocek
Posts: 242
Joined: 2005/05/30 15:40:15
Location: Benicia CA, USA

Re: RPM Database Borked

Post by kbocek » 2018/07/16 16:20:21

I'm part way there. I extracted sqlite3 as you said:

Code: Select all

rpm2cpio ./sqlite-3.6.20-1.el6_7.2.x86_64.rpm | cpio -idmv
RPM will work now. I tried installing what I thought was the db from the 6.9 distro files:

Code: Select all

rpm -ivh centos-release-6-9.el6.12.3.x86_64.rpm
which works but all files are not recovered:

Code: Select all

$rpm -qa
gpg-pubkey-0608b895-4bd22942
gpg-pubkey-baadae52-49beffa4
gpg-pubkey-63189046-5392c50e
gpg-pubkey-c105b9de-4e0fd3a3
gpg-pubkey-f2ee9d55-560cfc0a
gpg-pubkey-66534c2b-4eff56c5
gpg-pubkey-849c449f-4cb9df30
gpg-pubkey-6b8d79e6-3f49313d
centos-release-6-9.el6.12.3.x86_64
Are you saying there is no way to recover/rebuild the db of installed packages? Even from the distro or update files?

kbocek
Posts: 242
Joined: 2005/05/30 15:40:15
Location: Benicia CA, USA

Re: RPM Database Borked

Post by kbocek » 2018/07/16 16:27:07

The Yum database seems intact. "yum list" gives a full list of the files. "rpm -qa" gives the output above.

kbocek
Posts: 242
Joined: 2005/05/30 15:40:15
Location: Benicia CA, USA

Re: RPM Database Borked

Post by kbocek » 2018/07/16 16:54:53

Tried updating to 6.10. But no, we still need the database to tell yum what to update.

There *has* to be a way to extract or recreate the database file from the distro files!

kbocek
Posts: 242
Joined: 2005/05/30 15:40:15
Location: Benicia CA, USA

Re: RPM Database Borked

Post by kbocek » 2018/07/16 17:22:23

A partial fix. I copied all the /var/lib/rpm files from *another* Centos 6 install. rpm -qa now gives a full list.

Yum needed a "yum clean all" to sync.

Updating from 6.9 to 6.10 right now.

I realize that my third-party repo packages, like EPEL, will be missing.

UPDATE:
6.10 update went through fine. I'll just have to add my non-distro packages manually.

Post Reply