--- Begin Message ---
- To: mdz@debian.org
- Subject: atp-ftparchive patch
- From: Clint Adams <schizo@debian.org>
- Date: Fri, 2 Apr 2004 17:18:08 -0500
- Message-id: <20040402221808.GA4492@scowler.net>
The BTS queue overrun is making me incredibly neurotic, so I'm sending
you this patch.
diff -ur -x configure -x po apt-0.6.21.orig/buildlib/environment.mak.in apt-0.6.21/buildlib/environment.mak.in
--- apt-0.6.21.orig/buildlib/environment.mak.in 2004-02-09 16:03:14.000000000 -0500
+++ apt-0.6.21/buildlib/environment.mak.in 2004-04-02 10:41:06.769904621 -0500
@@ -48,7 +48,7 @@
PYTHONPREFIX = @PYTHONPREFIX@
PYTHONEXECPREFIX = @PYTHONEXECPREFIX@
PYTHONINCLUDE = @PYTHONINCLUDE@
-DB2LIB = @DB2LIB@
+BDBLIB = @BDBLIB@
INTLLIBS = @INTLLIBS@
# Shim Headerfile control
diff -ur -x configure -x po apt-0.6.21.orig/configure.in apt-0.6.21/configure.in
--- apt-0.6.21.orig/configure.in 2004-03-17 01:53:49.000000000 -0500
+++ apt-0.6.21/configure.in 2004-04-02 11:02:58.527929406 -0500
@@ -52,11 +52,28 @@
dnl AC_MSG_ERROR(failed: I need posix threads, pthread)
dnl fi
-dnl Check for DB2
-AC_CHECK_HEADER(db2/db.h,
- [AC_CHECK_LIB(db2,db_open,
- [AC_DEFINE(HAVE_DB2) DB2LIB="-ldb2"])])
-AC_SUBST(DB2LIB)
+dnl Check for BDB
+saveLIBS="$LIBS"
+LIBS="$LIBS -ldb"
+
+AC_CHECK_HEADER(db.h,
+ [AC_MSG_CHECKING(if we can link against BerkeleyDB)
+ AC_LINK_IFELSE(
+ [AC_LANG_PROGRAM(
+ [#include <db.h>],
+ [int r, s, t; db_version(&r, &s, &t);]
+ )],
+ [AC_DEFINE(HAVE_BDB)
+ BDBLIB="-ldb"
+ AC_MSG_RESULT(yes)],
+ [BDBLIB=""
+ AC_MSG_RESULT(no)]
+ )]
+)
+
+LIBS="$saveLIBS"
+
+AC_SUBST(BDBLIB)
dnl Converts the ARCH to be something singular for this general CPU family
dnl This is often the dpkg architecture string.
diff -ur -x configure -x po apt-0.6.21.orig/debian/control apt-0.6.21/debian/control
--- apt-0.6.21.orig/debian/control 2004-03-17 01:51:41.000000000 -0500
+++ apt-0.6.21/debian/control 2004-04-02 12:52:53.943070820 -0500
@@ -4,7 +4,7 @@
Maintainer: APT Development Team <deity@lists.debian.org>
Uploaders: Jason Gunthorpe <jgg@debian.org>, Adam Heath <doogie@debian.org>, Matt Zimmerman <mdz@debian.org>
Standards-Version: 3.6.1
-Build-Depends: debhelper (>= 4.1.62), libdb2-dev, gettext (>= 0.11.5)
+Build-Depends: debhelper (>= 4.1.62), libdb4.2-dev, gettext (>= 0.11.5)
Build-Depends-Indep: debiandoc-sgml, docbook-utils (>= 0.6.12-1)
Package: apt
diff -ur -x configure -x po apt-0.6.21.orig/ftparchive/cachedb.cc apt-0.6.21/ftparchive/cachedb.cc
--- apt-0.6.21.orig/ftparchive/cachedb.cc 2003-04-20 12:48:56.000000000 -0400
+++ apt-0.6.21/ftparchive/cachedb.cc 2004-04-02 12:21:02.255707388 -0500
@@ -30,6 +30,8 @@
/* This opens the DB2 file for caching package information */
bool CacheDB::ReadyDB(string DB)
{
+ int err;
+
ReadOnly = _config->FindB("APT::FTPArchive::ReadOnlyDB",false);
// Close the old DB
@@ -50,13 +52,26 @@
if (DB.empty())
return true;
-
- if ((errno = db_open(DB.c_str(),DB_HASH,
+
+ db_create(&Dbp, NULL, 0);
+ if ((err = Dbp->open(Dbp, NULL, DB.c_str(), NULL, DB_HASH,
(ReadOnly?DB_RDONLY:DB_CREATE),
- 0644,0,0,&Dbp)) != 0)
+ 0644)) != 0)
{
- Dbp = 0;
- return _error->Errno("db_open",_("Unable to open DB2 file %s"),DB.c_str());
+ if (err == DB_OLD_VERSION)
+ {
+ _error->Warning(_("DB is old, attempting to upgrade %s"),DBFile.c_str());
+ err = Dbp->upgrade(Dbp, DB.c_str(), 0);
+ if (!err)
+ err = Dbp->open(Dbp, NULL, DB.c_str(), NULL, DB_HASH,
+ (ReadOnly?DB_RDONLY:DB_CREATE), 0644);
+
+ }
+ if (err)
+ {
+ Dbp = 0;
+ return _error->Errno("db->open",_("Unable to open DB file %s"),DB.c_str());
+ }
}
DBFile = DB;
@@ -247,15 +262,9 @@
/* I'm not sure what VERSION_MINOR should be here.. 2.4.14 certainly
needs the lower one and 2.7.7 needs the upper.. */
-#if DB_VERSION_MAJOR >= 2 && DB_VERSION_MINOR >= 7
- DBC *Cursor;
- if ((errno = Dbp->cursor(Dbp,0,&Cursor,0)) != 0)
- return _error->Error(_("Unable to get a cursor"));
-#else
DBC *Cursor;
- if ((errno = Dbp->cursor(Dbp,0,&Cursor)) != 0)
+ if ((errno = Dbp->cursor(Dbp, NULL, &Cursor, 0)) != 0)
return _error->Error(_("Unable to get a cursor"));
-#endif
DBT Key;
DBT Data;
diff -ur -x configure -x po apt-0.6.21.orig/ftparchive/cachedb.h apt-0.6.21/ftparchive/cachedb.h
--- apt-0.6.21.orig/ftparchive/cachedb.h 2002-11-23 21:22:55.000000000 -0500
+++ apt-0.6.21/ftparchive/cachedb.h 2004-04-02 11:15:49.519170605 -0500
@@ -16,7 +16,7 @@
#pragma interface "cachedb.h"
#endif
-#include <db2/db.h>
+#include <db.h>
#include <string>
#include <apt-pkg/debfile.h>
#include <inttypes.h>
diff -ur -x configure -x po apt-0.6.21.orig/ftparchive/makefile apt-0.6.21/ftparchive/makefile
--- apt-0.6.21.orig/ftparchive/makefile 2001-02-20 02:03:18.000000000 -0500
+++ apt-0.6.21/ftparchive/makefile 2004-04-02 10:46:42.975043092 -0500
@@ -6,9 +6,9 @@
include ../buildlib/defaults.mak
# The apt-ftparchive program
-ifdef DB2LIB
+ifdef BDBLIB
PROGRAM=apt-ftparchive
-SLIBS = -lapt-pkg -lapt-inst $(DB2LIB)
+SLIBS = -lapt-pkg -lapt-inst $(BDBLIB)
LIB_MAKES = apt-pkg/makefile apt-inst/makefile
SOURCE = apt-ftparchive.cc cachedb.cc writer.cc contents.cc override.cc \
multicompress.cc
@@ -17,4 +17,4 @@
PROGRAM=apt-ftparchive
MESSAGE="Must have db2 to build apt-ftparchive"
include $(FAIL_H)
-endif # ifdef DB2LIB
+endif # ifdef BDBLIB
--- End Message ---