File disable-bdb.diff of Package rpm-ndb.26688

--- ./Makefile.am.orig	2019-12-09 15:06:29.928482250 +0000
+++ ./Makefile.am	2019-12-09 15:06:37.016465444 +0000
@@ -2,7 +2,7 @@
 
 ACLOCAL_AMFLAGS = -I m4
 
-DISTCHECK_CONFIGURE_FLAGS = --with-external-db --enable-python
+DISTCHECK_CONFIGURE_FLAGS = --enable-python
 
 include $(top_srcdir)/rpm.am
 AM_CFLAGS = @RPMCFLAGS@
--- ./configure.ac.orig	2019-12-09 15:06:29.940482221 +0000
+++ ./configure.ac	2019-12-09 15:06:37.016465444 +0000
@@ -509,6 +509,16 @@ AM_CONDITIONAL(LIBDW,[test "$WITH_LIBDW"
 AM_CONDITIONAL(HAVE_LIBDW_STRTAB,[test "$HAVE_LIBDW_STRTAB" = yes])
 
 #=================
+# Check for BDB support
+AC_ARG_ENABLE([bdb],
+              [AS_HELP_STRING([--enable-bdb=@<:@yes/no/auto@:>@],
+                              [build with Berkeley DB rpm database format support (default=yes)])],
+              [enable_bdb="$enableval"],
+              [enable_bdb=yes])
+have_bdb=no
+AS_IF([test "x$enable_bdb" != "xno"], [
+
+
 # Process --with/without-external-db
 AC_ARG_WITH(external_db, [AS_HELP_STRING([--with-external-db],[build against an external Berkeley db])],
 [case "$with_external_db" in
@@ -533,12 +543,14 @@ yes )
   ],[
     AC_MSG_ERROR([missing required header db.h])
   ])
+  have_bdb=yes
   ;;
 no|maybe )
   # Try internal database first, then fall back to external
   # unless --without-external-db (no) was explicitly given.
   if [ test -x db/dist/configure ]; then
     AC_DEFINE(HAVE_DB_H, 1, [Define if you have the <db3/db.h> header file])
+    have_bdb=internal
   else
     case "$with_external_db" in
     maybe)
@@ -561,11 +573,20 @@ no|maybe )
       AC_MSG_ERROR([internal Berkeley DB directory not present, see INSTALL])
     ;;
     esac
+    have_bdb=yes
   fi
   ;;
 esac
-
+AC_DEFINE([WITH_BDB], [1], [Define if BDB is available])
 AC_SUBST([WITH_DB_LIB])
+])
+
+AM_CONDITIONAL([BDB], [test "x$have_bdb" != "xno"])
+AM_CONDITIONAL([WITH_INTERNAL_DB],[test "x$have_bdb" = "xinternal"])
+if test "x$have_bdb" = "xinternal"; then
+    AC_CONFIG_SUBDIRS(db3)
+fi
+
 
 #=================
 # Process --enable-ndb
@@ -1052,11 +1073,6 @@ AC_SUBST(RPMCONFIGDIR)
 
 AC_SUBST(OBJDUMP)
 
-if test "$with_external_db" = no; then
-    AC_CONFIG_SUBDIRS(db3)
-fi
-
-AM_CONDITIONAL([WITH_INTERNAL_DB],[test "$with_external_db" = no])
 AM_CONDITIONAL([DOXYGEN],[test "$DOXYGEN" != no])
 AM_CONDITIONAL([HACKINGDOCS],[test "$with_hackingdocs" = yes])
 
--- ./lib/Makefile.am.orig	2017-10-05 10:04:56.944602155 +0000
+++ ./lib/Makefile.am	2019-12-09 15:06:37.016465444 +0000
@@ -24,7 +24,7 @@ EXTRA_PROGRAMS =
 
 usrlib_LTLIBRARIES = librpm.la
 librpm_la_SOURCES = \
-	backend/db3.c backend/dbi.c backend/dbi.h \
+	backend/dbi.c backend/dbi.h \
 	backend/dbiset.c backend/dbiset.h \
 	headerutil.c header.c headerfmt.c header_internal.h \
 	rpmdb.c rpmdb_internal.h \
@@ -59,11 +59,14 @@ librpm_la_LIBADD += @LUA_LIBS@
 librpm_la_SOURCES += rpmliblua.c rpmliblua.h
 endif
 
+if BDB
 if WITH_INTERNAL_DB
+librpm_la_SOURCES += backend/db3.c
 librpm_la_LIBADD += $(libdb_la)
 else
 librpm_la_LIBADD += @WITH_DB_LIB@
 endif
+endif
 
 if NDB
 librpm_la_SOURCES += \
--- ./lib/backend/dbi.c.orig	2017-10-05 10:04:56.946602155 +0000
+++ ./lib/backend/dbi.c	2019-12-09 15:12:53.475571937 +0000
@@ -49,12 +49,32 @@ dbDetectBackend(rpmdb rdb)
 	rdb->db_ops = &ndb_dbops;
     } else
 #endif
-    {
+#if defined(WITH_BDB)
+    if (!strcmp(db_backend, "bdb")) {
 	rdb->db_ops = &db3_dbops;
-	if (*db_backend == '\0') {
+    } else
+#endif
+    {
+	if (db_backend)
 	    free(db_backend);
+#if defined(WITH_BDB)
+	if (!rdb->db_ops) {
+	    rdb->db_ops = &db3_dbops;
 	    db_backend = xstrdup("bdb");
 	}
+#endif
+#ifdef ENABLE_NDB
+	if (!rdb->db_ops) {
+	    rdb->db_ops = &ndb_dbops;
+	    db_backend = xstrdup("ndb");
+	}
+#endif
+#if defined(WITH_LMDB)
+	if (!rdb->db_ops) {
+	    rdb->db_ops = &lmdb_dbops;
+	    db_backend = xstrdup("lmdb");
+	}
+#endif
     }
 
 #if defined(WITH_LMDB)
@@ -75,12 +95,14 @@ dbDetectBackend(rpmdb rdb)
     free(path);
 #endif
 
+#if defined(WITH_BDB)
     path = rstrscat(NULL, dbhome, "/Packages", NULL);
     if (access(path, F_OK) == 0 && rdb->db_ops != &db3_dbops) {
 	rdb->db_ops = &db3_dbops;
 	rpmlog(RPMLOG_WARNING, _("Found BDB Packages database while attempting %s backend: using bdb backend.\n"), db_backend);
     }
     free(path);
+#endif
 
     if (db_backend)
 	free(db_backend);
--- ./lib/backend/dbi.h.orig	2019-12-09 15:06:29.920482268 +0000
+++ ./lib/backend/dbi.h	2019-12-09 15:06:37.016465444 +0000
@@ -265,8 +265,10 @@ struct rpmdbOps_s {
     const void * (*idxdbKey)(dbiIndex dbi, dbiCursor dbc, unsigned int *keylen);
 };
 
+#if defined(WITH_BDB)
 RPM_GNUC_INTERNAL
 extern struct rpmdbOps_s db3_dbops;
+#endif
 
 #ifdef ENABLE_NDB
 RPM_GNUC_INTERNAL
openSUSE Build Service is sponsored by