summaryrefslogtreecommitdiff
path: root/pkgtools/pkg_install/files/lib/pkgdb.c
diff options
context:
space:
mode:
authorchristos <christos@pkgsrc.org>2006-01-04 23:33:23 +0000
committerchristos <christos@pkgsrc.org>2006-01-04 23:33:23 +0000
commitc6761ed17e9777054908c7b706ce79ae385b5ac0 (patch)
treecf77d4af9d78c16c3ed8812b5291327b64976c5d /pkgtools/pkg_install/files/lib/pkgdb.c
parentb36634437fe0d43d0d7387ae49255952175c5250 (diff)
downloadpkgsrc-c6761ed17e9777054908c7b706ce79ae385b5ac0.tar.gz
Handle newer versions of Berkeley DB. Our algorithm is:
- if you have > db1 the probably you have db_185.h which means that dbopen is really __db185_open, and we'll prefer that. - else if you have db1, then you have db1/db.h and dbopen - else if you have db.h, then this is either the one from db1 and it will work with -ldb having dbopen, or it will not. Note that the compatibility option on __db185_open() will actually not create or update db1.85/1.86 files, but it will use the current format of the db library. This compatibility layer is source code only.
Diffstat (limited to 'pkgtools/pkg_install/files/lib/pkgdb.c')
-rw-r--r--pkgtools/pkg_install/files/lib/pkgdb.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/pkgtools/pkg_install/files/lib/pkgdb.c b/pkgtools/pkg_install/files/lib/pkgdb.c
index f8017780770..96b959dea62 100644
--- a/pkgtools/pkg_install/files/lib/pkgdb.c
+++ b/pkgtools/pkg_install/files/lib/pkgdb.c
@@ -1,4 +1,4 @@
-/* $NetBSD: pkgdb.c,v 1.24 2005/02/05 00:28:58 jlam Exp $ */
+/* $NetBSD: pkgdb.c,v 1.25 2006/01/04 23:33:23 christos Exp $ */
#if HAVE_CONFIG_H
#include "config.h"
@@ -8,7 +8,7 @@
#include <sys/cdefs.h>
#endif
#ifndef lint
-__RCSID("$NetBSD: pkgdb.c,v 1.24 2005/02/05 00:28:58 jlam Exp $");
+__RCSID("$NetBSD: pkgdb.c,v 1.25 2006/01/04 23:33:23 christos Exp $");
#endif
/*
@@ -41,7 +41,9 @@ __RCSID("$NetBSD: pkgdb.c,v 1.24 2005/02/05 00:28:58 jlam Exp $");
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#if HAVE_DB1_DB_H
+#if HAVE_DB_185_H
+#include <db_185.h>
+#elif HAVE_DB1_DB_H
#include <db1/db.h>
#elif HAVE_DB_H
#include <db.h>
@@ -64,6 +66,11 @@ __RCSID("$NetBSD: pkgdb.c,v 1.24 2005/02/05 00:28:58 jlam Exp $");
#if HAVE_STRING_H
#include <string.h>
#endif
+#if defined(HAVE_DBOPEN) || (defined(HAVE___DB185_OPEN) && defined(HAVE_DB_185_H))
+#define HAVE_DBLIB 1
+#else
+#define HAVE_DBLIB 0
+#endif
#include "lib.h"
@@ -79,13 +86,13 @@ __RCSID("$NetBSD: pkgdb.c,v 1.24 2005/02/05 00:28:58 jlam Exp $");
/* just in case we change the environment variable name */
#define PKG_DBDIR "PKG_DBDIR"
-#if HAVE_DBOPEN
+#if HAVE_DBLIB
static DB *pkgdbp;
#endif
static char *pkgdb_dir = NULL;
static char pkgdb_cache[MaxPathSize];
-#if HAVE_DBOPEN
+#if HAVE_DBLIB
/*
* Open the pkg-database
* Return value:
@@ -265,7 +272,7 @@ pkgdb_remove_pkg(const char *pkg)
return ret;
}
-#else /* !HAVE_DBOPEN */
+#else /* !HAVE_DBLIB */
int pkgdb_open(int mode) { return 1; }
void pkgdb_close(void) {}
@@ -275,7 +282,7 @@ void pkgdb_dump(void) {}
int pkgdb_remove(const char *key) { return 0; }
int pkgdb_remove_pkg(const char *pkg) { return 1; }
-#endif /* HAVE_DBOPEN */
+#endif /* HAVE_DBLIB */
/*
* Return the location of the package reference counts database directory.