• Home
  • Blog
  • Converting new rpm databases to old format

Converting new rpm databases to old format

Vincent Danen

January 30, 2009

I better post this before I forget about it. One of the issues I had today was getting corp3/x86_64 installed in a chroot with Mandriva 2009.0 as the host. Of course, the db4 version had changed, so I had to take advantage of some conversion tools. urpmi is supposed to do this magically, but it doesn't seem consistent. Anyways, the problem lies with 2009.0's rpm using a newer version of the database than the older version. For instance:

# file /var/lib/rpm/Packages 
/var/lib/rpm/Packages: Berkeley DB (Hash, version 9, native byte-order)
# file /chroots/64/cs3/var/lib/rpm/Packages
/chroots/64/cs3/var/lib/rpm/Packages: Berkeley DB (Hash, version 8, native byte-order)

So the trick is to convert them from the new format to the old format, which is easy enough to do once you know what to do. On the host (Mandriva 2009 in this case), make sure you have db46_utils and db42_utils installed:

# rpm -qa|grep "db.*\-utils"
db46-utils-4.6.21-9mdv2009.0
db42-utils-4.2.52-24mdv2009.0

Then you can use this rough-n-dirty script I wrote to convert them:

#!/bin/sh
#
# script to dump and reload the rpm db to convert from hash format 9 to format 8
# for older distribs (think cs3)

for i in $(ls -1); do
    if [ "`file ${i} | grep 9`" != "" ]; then
        db_dump ${i} >${i}.db46
        db42_load ${i}.db42 < ${i}.db46
        mv -f ${i} ${i}.org
        mv -f ${i}.db42 ${i}
    fi
done

That should fix the errors you would see in the chroot, plus make it so that rpm -qa and friends actually work.

Leave a Comment

Comments use MarkDown. Need help? MarkDown Cheatsheet