RPM Community Forums

Mailing List Message of <rpm-devel>

Re: Eliminating --initdb

From: Ralf S. Engelschall <rse+rpm-devel@rpm5.org>
Date: Sun 29 Jul 2007 - 22:51:50 CEST
Message-ID: <20070729205150.GA76800@engelschall.com>
On Sun, Jul 29, 2007, Jeff Johnson wrote:

> The option has been unnecessary in all but an obscure --root corner
> case since Berkeley DB has been used.
>
> Shall we finally eliminate the option?

I personally would vote "no".

In OpenPKG we even go the other direction: we use two small patch-hunks
(see below) to ensure that on --initdb and --rebuilddb all(!) database
files are present and not just spring into existence on-demand later.
The reason is mainly consistency as we want to fixate their ownerships,
permissions, etc. just once and for this we use an explicit --initdb
call. But as OpenPKG is not a represenative RPM use case do not mind too
much about --initdb, we can also provide it in the OpenPKG patch set
only...

                                       Ralf S. Engelschall
                                       rse@engelschall.com
                                       www.engelschall.com

Index: rpmdb/rpmdb.c
--- rpmdb/rpmdb.c	23 Jul 2007 08:45:08 -0000	1.141
+++ rpmdb/rpmdb.c	29 Jul 2007 20:45:47 -0000
@@ -1273,8 +1273,16 @@
     int rc;

 /*@-boundswrite@*/
+#if defined(OPENPKG)
+    /* do not pass RPMDB_FLAG_JUSTCHECK as it would close the database and so
+       "db" would be always NULL and this way the code below (which ensures
+       that all database files are created) would be effectively dead */
+    rc = rpmdbOpenDatabase(prefix, NULL, _dbapi, &db, (O_CREAT | O_RDWR),
+		perms, 0);
+#else
     rc = rpmdbOpenDatabase(prefix, NULL, _dbapi, &db, (O_CREAT | O_RDWR),
 		perms, RPMDB_FLAG_JUSTCHECK);
+#endif
 /*@=boundswrite@*/
     if (db != NULL) {
 	int xx;
@@ -3960,6 +3994,12 @@
     }
 /*@=boundswrite@*/

+#if defined(OPENPKG)
+    /* in OpenPKG for consistency reasons we want that all database files are present at any time
+       and not just spring into existence on-demand, so enforce this here for new database. */
+    (void)rpmdbOpenAll(newdb);
+#endif
+
     _rebuildinprogress = 0;

     _dbapi_rebuild = newdb->db_api;
Received on Sun Jul 29 22:52:33 2007
Driven by Jeff Johnson and the RPM project team.
Hosted by OpenPKG and Ralf S. Engelschall.
Powered by FreeBSD and OpenPKG.