RPM Community Forums

Mailing List Message of <rpm-devel>

Re: FYI: migrating the RPM DB between Berkeley-DB and SQLite

From: Mark Hatle <mark.hatle@windriver.com>
Date: Thu 28 Jun 2007 - 17:52:57 CEST
Message-ID: <4683D959.4000905@windriver.com>
I'd have to double check this in the code, but if the __dbabi is "0" (or
maybe it was -1), rpm will work w/ both sqlite and db databases..
basically it'll try to open it as one, if it can't it'll fall back to
the other format.  (I don't remember the order it looks in.)

--Mark

Ralf S. Engelschall wrote:
> 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
> 
> ______________________________________________________________________
> RPM Package Manager                                    http://rpm5.org
> Developer Communication List                        rpm-devel@rpm5.org
Received on Thu Jun 28 17:53:04 2007
Driven by Jeff Johnson and the RPM project team.
Hosted by OpenPKG and Ralf S. Engelschall.
Powered by FreeBSD and OpenPKG.