RPM Community Forums

Mailing List Message of <rpm-users>

Re: Error in changing Default Location of RPM database

From: Jeff Johnson <n3npq@mac.com>
Date: Tue 09 Feb 2010 - 16:14:42 CET
Message-id: <CDFC2D15-39A4-41F6-B705-8F969E79D9DB@mac.com>

On Feb 9, 2010, at 9:51 AM, Manoj Palhade wrote:

> Dear RPM Team,
> 
>  As discussed previously regarding “Default Location of RPM database”
> 
> Default Location of RPM database is stored in %_dbpath variable in macro file at /lib/rpm folder 
>  
> Value of %_dbpath variable is %{_var}/lib/rpm 
>  
> I done following changed in macro file at /lib/rpm folder
> So instead of changing “%_dbpath”; I made changes in “_var” variable.
>  
> I changed value of %_var variable.
> %_var /var/sys/opt instead of /opt/sys/var
>  
> I am using following options in "configure" command
> 
> --with-dbabi=sqlite
> 
> --with-sqlite=/opt/sys
> 
> --without-db
> 
> 
> 

Yes, (at least) these build options are necessary to compile RPM w/o Berkeley DB.

> After this I tried to execute RPM commands such as #rpm –e. But I am getting following error.
> 
> # rpm -Uvh Opt-1.0-1.x86pc.rpm
> 
> error: cannot open Packages database in /var/opt/sys/lib/rpm
> 
> error: cannot open Packages database in /var/opt/sys/lib/rpm
> 
>  
> 
> # rpm -qa
> 
> error: cannot open Packages database in /var/opt/sys/lib/rpm
> 
> After this I tired following command
> 
> #cd /var/opt/sys/lib/rpm
> 

The build options (mostly) change macros in /usr/lib/rpm/macros (or whatever path
you have chosen). Examine that file and look for the path "/opt/sys" to ensure that
the values are being set correctly.

The problem that you are seeing is that -- if RPM cannot find its default
configuration from /usr/lib/rpm/macros --- then compiled in fall back values
are used, which are appropriate for Berkeley DB but not for sqlite3.

The best fix is to patch RPM to change the fallback configuration to be
appropriate for sqlite3, not Berkeley DB. Equivalently, one has to ensure
that RPM can *always* read its default configuration with the values
appropriate for sqlite3.

>  
> # file *
> 
> Basenames:      Berkeley DB (Btree, version 9, native byte-order)
> 
> Conflictname:   Berkeley DB (Btree, version 9, native byte-order)
> 
> Dirnames:       Berkeley DB (Btree, version 9, native byte-order)
> 
> Filedigests:    Berkeley DB (Hash, version 9, native byte-order)
> 
> Filepaths:      Berkeley DB (Btree, version 9, native byte-order)
> 
> Group:          Berkeley DB (Btree, version 9, native byte-order)
> 
> Installtid:     Berkeley DB (Btree, version 9, native byte-order)
> 
> Name:           Berkeley DB (Btree, version 9, native byte-order)
> 
> Nvra:           Berkeley DB (Btree, version 9, native byte-order)
> 
> Packagecolor:   Berkeley DB (Hash, version 9, native byte-order)
> 
> Packages:       Berkeley DB (Btree, version 9, native byte-order)
> 
> Providename:    Berkeley DB (Btree, version 9, native byte-order)
> 
> Provideversion: Berkeley DB (Btree, version 9, native byte-order)
> 
> Requirename:    Berkeley DB (Btree, version 9, native byte-order)
> 
> Sha1header:     Berkeley DB (Hash, version 9, native byte-order)
> 
> Sigmd5:         Berkeley DB (Hash, version 9, native byte-order)
> 
> Sourcepkgid:    Berkeley DB (Btree, version 9, native byte-order)
> 
> Triggername:    Berkeley DB (Btree, version 9, native byte-order)
> 
> #
> 
> 

I 'm not sure how those file were created if you build --without-db. Either the
files are from some other RPM execurable that jsut happen to be there, or
you have not succeeded in building RPM w/o Berkeley DB.

Use nm or readelf (or equivalent) on /usr/lib/librpmmisc-X.Y.so and look for symbols
with a "_rpmdb" suffix. If the symbols are not present in librpmmisc-X.Y.so,
then you have succeeded in building RPM w/o Berkeley DB.

And without Berkeley DB, then the likeliest explanation for the files is
that they were created by some other RPM executable compiled with Berkeley DB.

> I am not sure How is above “Berkeley DB” files are getting created. Same error I am getting is I change “_dbpath” variable instead of “_var” variable Please let me know how to resolve this Berkeley DB Issue.
> 
> I rollback (reversed) changes in macro file at /lib/rpm folder. Now value of %_var variable /opt/sys/var
> I tried following command which is giving expected output and I am able to execute RPM commands like install RPM package.
> 
> # cd /opt/sys/var/lib/rpm
> 
> # file *
> 
> Packages: SQLite 3.x database
> 
> # sqlite3 Packages
> 
> SQLite version 3.6.14.2
> 
> Enter ".help" for instructions
> 
> Enter SQL statements terminated with a ";"
> 
> sqlite> .dump
> 
> BEGIN TRANSACTION;
> 
> CREATE TABLE 'Packages' (key int UNIQUE PRIMARY KEY, value blob);
> 
> CREATE TABLE 'db_info' (endian TEXT);
> 
> INSERT INTO "db_info" VALUES('68');
> 
> COMMIT;
> 
> sqlite> .exit
> 
> #
> 
>  
> # rpm -Uvh /opt/sys/src/rpm/RPMS/x86pc/Opt-hmi-1.0-1.x86pc.rpm
> 
> Preparing...                ########################################### [100%]
> 
>    1:Opt-hmi                ########################################### [100%]
> 
> #
> 
>  
> # file *
> 
> Basenames:      SQLite 3.x database
> 
> Conflictname:   SQLite 3.x database
> 
> Dirnames:       SQLite 3.x database
> 
> Filedigests:    SQLite 3.x database
> 
> Filepaths:      SQLite 3.x database
> 
> Group:          SQLite 3.x database
> 
> Installtid:     SQLite 3.x database
> 
> Name:           SQLite 3.x database
> 
> Nvra:           SQLite 3.x database
> 
> Packagecolor:   SQLite 3.x database
> 
> Packages:       SQLite 3.x database
> 
> Providename:    SQLite 3.x database
> 
> Provideversion: SQLite 3.x database
> 
> Sha1header:     SQLite 3.x database
> 
> Sigmd5:         SQLite 3.x database
> 
> Sourcepkgid:    SQLite 3.x database
> 
> Triggername:    SQLite 3.x database
> 
> #
> 
> 
> 
> Please let me know How to change “Default Location of RPM database” with out getting created “Berkeley DB” files.
> 

The path to the rpmdb is in /usr/lib/rpm/macros (or whatever path you have chosen):

	# The location of the rpm database file(s).
	%_dbpath %{_var}/lib/rpm 

The type of database to use is controlled by

	# Database API configuration:
	#
	# 0,1: Berkeley-DB 1.x API (no longer supported)
	# 2: Berkeley-DB 2.x API (no longer supported)
	# 3: Berkeley-DB 3.x/4.x API (default)
	# 4: SQLite 3.x API (alternative)
	#
	# There are different macros so that --rebuilddb can convert the
	# database between formats (usually for upgrading purposes)
	#
	%_dbapi 3
	%_dbapi_used %{_dbapi} 

For only sqlite3, the only meaningful value is
	%_dbapi 4

But the most reliable "fix" will be  to also change the compiled
in default value for %_dbapi to be always 4 for your give configuration.
That change needs to be made in rpmdb/rpmdb.c.

hth

73 de Jeff

>  
> Thanks and Regards,
> Manoj Palhade 
> 
Received on Tue Feb 9 16:15:10 2010
Driven by Jeff Johnson and the RPM project team.
Hosted by OpenPKG and Ralf S. Engelschall.
Powered by FreeBSD and OpenPKG.