>> 
>> BTW, if you want to try a parallel install of rpm-5.4.16 to system rpm, do 
>> this
>>      1) add configure ... --with-paths-versioned
>>      2) instead of doing "make install", do "make DESTDIR=/var/tmp/rpm-root" 
>> and copy the tree to /
>>              The issue is libtool relinking necessitates the versions being 
>> added after install -c ... which
>>              just clobbered /usr/bin/rpm ...
>> 
>> Cloning the data base --with-paths-versioned SHOULD be as simple as doing
>>      cp /var/lib/rpm{,-5.4.16}
>>      rpm-5.4.16 --rebuilddb
>> but YMMV.
>> 

I should be a little bit more careful about context here.

For distros already using RPM5, cloning an rpmdb SHOULD be as simple
as copying /var/lib/rpm/Packages and doing a —rebuild.

If using rpm from rpm.org, then the conversion is slightly more complicated
to perform 2 actions:
        1) byte swapping (from native -> network order) the int32_t  key into 
Packages
        2) switching from DB_HASH -> DB_BTREE

The manual procedure isn’t too hard. The snippet (from tests/Makefile.am) that
I use with “make test” should describe the steps needed to write a conversion
script.

The actual conversion is essentially performed with sed, something like

        dbXY_dump olddb/Packages \
                  | sed \
                    -e 's/^type=hash$$/type=btree/' \
                    -e '/^h_nelem=/d' \
                    -e 's/^ \(..\)\(..\)\(..\)\(..\)$$/ \4\3\2\1/' \
                  | dbXY_load newdb/Packages;

substituting as appropriate “dbXY_dump”, “dbXY_load” (i.e., XY is typically
whatever Berkeley DB version you are using), and “olddb” and “newdb”
are the system /var/lib/rpm and the parallel cloned /var/lb/rpm-5.4.16.


There is also a utility dbconvert that will perform the necessary conversion 
(but I have
forgotten the CLI arguments. You can likely find more complete info in the 
*Mandriva
mailing lists from 2011).

I can/will provide either a script (or more info on using dbconvert) on request.

I’m just a lazy/busy schmuck … ;-)

hth

73 de Jeff
=================================================================================
check-convert:
        @echo "=== $@ ==="
        case `rpm --version` in \
        *5.4*|*5.3*) echo "Nothing to do." ;; \
        *)      echo "Converting system database."; \
                rm -rf newdb olddb; \
                mkdir -p olddb; \
                echo "--> copy the system rpmdb"; \
                cp /var/lib/rpm/Packages olddb; \
                echo "--> rebuild to renumber the header instances"; \
                rpm \
                  --dbpath $(testdir)/olddb \
                  --rebuilddb; \
                mkdir -p newdb/log newdb/tmp olddb; \
                echo "--> convert header instances to network order"; \
                @__DB_DUMP@ olddb/Packages \
                  | ${sed} \
                    -e 's/^type=hash$$/type=btree/' \
                    -e '/^h_nelem=/d' \
                    -e 's/^ \(..\)\(..\)\(..\)\(..\)$$/ \4\3\2\1/' \
                  | @__DB_LOAD@ newdb/Packages; \
                echo "--> regenerate the indices"; \
                cp ../rpmdb/DB_CONFIG newdb; \
                ${rpm} \
                  --dbpath $(testdir)/newdb \
                  --rebuilddb -vv; \
                ls -l newdb; \
                echo "--> test the conversion"; \
                ${rpm} --dbpath $(testdir)/newdb -qa; \
                ${rpm} --dbpath $(testdir)/newdb -q rpm; \
                ;; \
        esac

Reply via email to