How does --rebuilddb work when the db is completely unreadable?
pmatilai at laiskiainen.org
Sat Jan 21 08:18:02 UTC 2017
On 01/20/2017 08:21 PM, John Walker wrote:
>>> If anyone can give me any insight about how rpm rebuilds its database, or point me to
>>> relevant portions of the source, I would appreciate it. ?
>> It reads the data records, ignoring any indexes, and creates a new
>> database from scratch. While reading the data records, it discards
>> those that fail basic sanity checks.
> I'm new to rpm internals. When you say it reads the data records, which
> data records do you mean? Records from the berkley database named
> "Packages?" Records from several of the databases in the rpm database
> directory? Something else entirely?
> I feel like I'm misunderstanding something here, because if a rebuild
> must be able to read records from the current database, it wouldn't do
> much good if the current database is unreadable, however, I have found
> that rpm --rebuilddb does work when the current database is unreadable,
> at least in one limited situation. (db5-based version of rpm trying to
> use files from a db4-based version of rpm.)
BDB is backwards compatible, a new version can always read data written
by older ones but not vice versa.
What is NOT compatible between different versions is the shared BDB
environment, ie the __db.* files you see in /var/lib/rpm. The trick with
--rebuilddb is that uses a private environment to avoid those
incompatibility, flagged PANIC'ed etc problems.
Other than that, it doesn't do anything special (no special mode to read
raw records), it just executes a 'rpm -qa' equivalent and generates a
new database with fresh indexes and all from all valid headers.
- Panu -
More information about the Rpm-list