As it is AFAIK not documented anyhwere and also far away from being
obvious, here is a short tutorial for the RPM hackers on how to migrate
the RPM DB of RPM 5 between Berkeley-DB and SQLite.
The obvious pre-requisite for an in-place migration obviously is that
RPM 5 was built with _both_ Berkeley-DB _and_ SQLite, of course. In our
newer RPM 5 world-order this is just a matter of having SQLite installed
under /path/to/sqlite and then build RPM with the Autoconf option set
"--with-db=internal --with-sqlite=/path/to/sqlite"
After you have this "multi-DB-lingual" RPM available, here is how one
can migrate from Berkeley-DB to SQLite and vice versa:
1. start with a standard Berkeley-DB RPM DB:
| $ /tmp/rpm/bin/rpm --initdb
| $ /tmp/rpm/bin/rpm --import pubkeys/JBJ-GPG-KEY
| $ /tmp/rpm/bin/rpm -qai
| Name : gpg-pubkey Relocations: (not relocatable)
| Version : 2039b291 Vendor: (none)
| Release : 3dbaae72 Build Date: Thu Jun 28 11:20:48 2007
| Install Date: Thu Jun 28 11:20:48 2007 Build Host: localhost
| Group : Public Keys Source RPM: (none)
| Size : 0 License: pubkey
| Signature : (none)
| Summary : gpg(Jeff Johnson (ARS N3NPQ) <jbj@redhat.com>)
| [...]
| $ file /tmp/rpm/var/lib/rpm/*
| /tmp/rpm/var/lib/rpm/Group: Berkeley DB (Btree, version 9, little-endian)
| /tmp/rpm/var/lib/rpm/Installtid: Berkeley DB (Btree, version 9, little-endian)
| /tmp/rpm/var/lib/rpm/Name: Berkeley DB (Btree, version 9, little-endian)
| /tmp/rpm/var/lib/rpm/Packagecolor: Berkeley DB (Hash, version 8, little-endian)
| /tmp/rpm/var/lib/rpm/Packages: Berkeley DB (Btree, version 9, little-endian)
| /tmp/rpm/var/lib/rpm/Providename: Berkeley DB (Btree, version 9, little-endian)
| /tmp/rpm/var/lib/rpm/Provideversion: Berkeley DB (Btree, version 9, little-endian)
| /tmp/rpm/var/lib/rpm/Pubkeys: Berkeley DB (Hash, version 8, little-endian)
2. migrate RPM DB from Berkeley-DB to SQLite:
| $ /tmp/rpm/bin/rpm --rebuilddbapi 4 --rebuilddb
| $ file /tmp/rpm/var/lib/rpm/*
| /tmp/rpm/var/lib/rpm/Group: SQLite 3.x database
| /tmp/rpm/var/lib/rpm/Installtid: SQLite 3.x database
| /tmp/rpm/var/lib/rpm/Name: SQLite 3.x database
| /tmp/rpm/var/lib/rpm/Packagecolor: SQLite 3.x database
| /tmp/rpm/var/lib/rpm/Packages: SQLite 3.x database
| /tmp/rpm/var/lib/rpm/Providename: SQLite 3.x database
| /tmp/rpm/var/lib/rpm/Provideversion: SQLite 3.x database
| /tmp/rpm/var/lib/rpm/Pubkeys: SQLite 3.x database
| $ /tmp/rpm/bin/rpm --dbapi 4 -qai
| Name : gpg-pubkey Relocations: (not relocatable)
| Version : 2039b291 Vendor: (none)
| Release : 3dbaae72 Build Date: Thu Jun 28 11:20:48 2007
| Install Date: Thu Jun 28 11:20:48 2007 Build Host: localhost
| Group : Public Keys Source RPM: (none)
| Size : 0 License: pubkey
| Signature : (none)
| Summary : gpg(Jeff Johnson (ARS N3NPQ) <jbj@redhat.com>)
| [...]
| -----END PGP PUBLIC KEY BLOCK-----
3. migrate RPM DB back from SQLite to Berkeley-DB:
| $ /tmp/rpm/bin/rpm --dbapi 4 --rebuilddbapi 3 --rebuilddb
| $ file /tmp/rpm/var/lib/rpm/*
| /tmp/rpm/var/lib/rpm/Group: Berkeley DB (Btree, version 9, little-endian)
| /tmp/rpm/var/lib/rpm/Installtid: Berkeley DB (Btree, version 9, little-endian)
| /tmp/rpm/var/lib/rpm/Name: Berkeley DB (Btree, version 9, little-endian)
| /tmp/rpm/var/lib/rpm/Packagecolor: Berkeley DB (Hash, version 8, little-endian)
| /tmp/rpm/var/lib/rpm/Packages: Berkeley DB (Btree, version 9, little-endian)
| /tmp/rpm/var/lib/rpm/Providename: Berkeley DB (Btree, version 9, little-endian)
| /tmp/rpm/var/lib/rpm/Provideversion: Berkeley DB (Btree, version 9, little-endian)
| /tmp/rpm/var/lib/rpm/Pubkeys: Berkeley DB (Hash, version 8, little-endian)
| $ /tmp/rpm/bin/rpm -qai
| Name : gpg-pubkey Relocations: (not relocatable)
| Version : 2039b291 Vendor: (none)
| Release : 3dbaae72 Build Date: Thu Jun 28 11:20:48 2007
| Install Date: Thu Jun 28 11:20:48 2007 Build Host: localhost
| Group : Public Keys Source RPM: (none)
| Size : 0 License: pubkey
| Signature : (none)
| Summary : gpg(Jeff Johnson (ARS N3NPQ) <jbj@redhat.com>)
| [...]
Yours,
Ralf S. Engelschall
rse@engelschall.com
www.engelschall.com
Received on Thu Jun 28 11:33:35 2007