- Fix build with various python releases (2.4-2.7) and berkeley db versions (4.x-5.x)

This commit is contained in:
Sunpoet Po-Chuan Hsieh 2011-10-10 04:05:14 +00:00
parent d0d16499ad
commit b16b930ff6
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=283296
5 changed files with 480 additions and 11 deletions

View file

@ -27,6 +27,7 @@ WRKSRC= ${PYTHON_WRKSRC}/Modules
DISTINFO_FILE= ${PORTSDIR}/lang/python${PYTHON_SUFFIX}/distinfo
MAKE_ENV= BSDDB_VERSION=${BDB_LIB_NAME}
PLIST_FILES= %%PYTHON_SITELIBDIR%%/_bsddb.so
EXTRA_PATCHES+= ${FILESDIR}/extra-patch-py${PYTHON_SUFFIX}-_bsddb.c
.include <bsd.port.pre.mk>

View file

@ -0,0 +1,167 @@
--- _bsddb.c.orig 2006-10-06 02:49:36.000000000 +0800
+++ _bsddb.c 2011-10-10 10:29:43.469871000 +0800
@@ -162,8 +162,10 @@
static PyObject* DBRunRecoveryError; /* DB_RUNRECOVERY */
static PyObject* DBVerifyBadError; /* DB_VERIFY_BAD */
static PyObject* DBNoServerError; /* DB_NOSERVER */
+#if (DBVER < 50)
static PyObject* DBNoServerHomeError; /* DB_NOSERVER_HOME */
static PyObject* DBNoServerIDError; /* DB_NOSERVER_ID */
+#endif
#if (DBVER >= 33)
static PyObject* DBPageNotFoundError; /* DB_PAGE_NOTFOUND */
static PyObject* DBSecondaryBadError; /* DB_SECONDARY_BAD */
@@ -187,6 +189,9 @@
#define DB_BUFFER_SMALL ENOMEM
#endif
+#if (DBVER < 48)
+#define DB_GID_SIZE DB_XIDDATASIZE
+#endif
/* --------------------------------------------------------------------- */
/* Structure definitions */
@@ -544,8 +549,10 @@
case DB_RUNRECOVERY: errObj = DBRunRecoveryError; break;
case DB_VERIFY_BAD: errObj = DBVerifyBadError; break;
case DB_NOSERVER: errObj = DBNoServerError; break;
+#if (DBVER < 50)
case DB_NOSERVER_HOME: errObj = DBNoServerHomeError; break;
case DB_NOSERVER_ID: errObj = DBNoServerIDError; break;
+#endif
#if (DBVER >= 33)
case DB_PAGE_NOTFOUND: errObj = DBPageNotFoundError; break;
case DB_SECONDARY_BAD: errObj = DBSecondaryBadError; break;
@@ -3831,6 +3838,7 @@
}
+#if (DBVER < 45)
static PyObject*
DBEnv_set_lk_max(DBEnvObject* self, PyObject* args)
{
@@ -3846,6 +3854,7 @@
RETURN_IF_ERR();
RETURN_NONE();
}
+#endif
#if (DBVER >= 32)
@@ -4317,9 +4326,9 @@
if (!PyArg_ParseTuple(args, "s#:prepare", &gid, &gid_size))
return NULL;
- if (gid_size != DB_XIDDATASIZE) {
+ if (gid_size != DB_GID_SIZE) {
PyErr_SetString(PyExc_TypeError,
- "gid must be DB_XIDDATASIZE bytes long");
+ "gid must be DB_GID_SIZE bytes long");
return NULL;
}
@@ -4532,7 +4541,9 @@
{"set_lg_dir", (PyCFunction)DBEnv_set_lg_dir, METH_VARARGS},
{"set_lg_max", (PyCFunction)DBEnv_set_lg_max, METH_VARARGS},
{"set_lk_detect", (PyCFunction)DBEnv_set_lk_detect, METH_VARARGS},
+#if (DBVER < 45)
{"set_lk_max", (PyCFunction)DBEnv_set_lk_max, METH_VARARGS},
+#endif
#if (DBVER >= 32)
{"set_lk_max_locks", (PyCFunction)DBEnv_set_lk_max_locks, METH_VARARGS},
{"set_lk_max_lockers", (PyCFunction)DBEnv_set_lk_max_lockers, METH_VARARGS},
@@ -4574,6 +4585,7 @@
static PyObject*
DBEnv_getattr(DBEnvObject* self, char *name)
{
+#if (DBVER < 46)
if (!strcmp(name, "db_home")) {
CHECK_ENV_NOT_CLOSED(self);
if (self->db_env->db_home == NULL) {
@@ -4581,6 +4593,7 @@
}
return PyString_FromString(self->db_env->db_home);
}
+#endif
return Py_FindMethod(DBEnv_methods, (PyObject* )self, name);
}
@@ -4886,13 +4899,17 @@
ADD_INT(d, DB_MAX_RECORDS);
#if (DBVER >= 42)
+#if (DBVER < 50)
ADD_INT(d, DB_RPCCLIENT);
+#endif
#else
ADD_INT(d, DB_CLIENT);
/* allow apps to be written using DB_RPCCLIENT on older BerkeleyDB */
_addIntToDict(d, "DB_RPCCLIENT", DB_CLIENT);
#endif
+#if (DBVER < 48 || DBVER > 51)
ADD_INT(d, DB_XA_CREATE);
+#endif
ADD_INT(d, DB_CREATE);
ADD_INT(d, DB_NOMMAP);
@@ -5039,7 +5056,9 @@
ADD_INT(d, DB_AFTER);
ADD_INT(d, DB_APPEND);
ADD_INT(d, DB_BEFORE);
+#if (DBVER < 45)
ADD_INT(d, DB_CACHED_COUNTS);
+#endif
#if (DBVER >= 41)
_addIntToDict(d, "DB_CHECKPOINT", 0);
#else
@@ -5074,7 +5093,9 @@
ADD_INT(d, DB_POSITION);
ADD_INT(d, DB_PREV);
ADD_INT(d, DB_PREV_NODUP);
+#if (DBVER < 45)
ADD_INT(d, DB_RECORDCOUNT);
+#endif
ADD_INT(d, DB_SET);
ADD_INT(d, DB_SET_RANGE);
ADD_INT(d, DB_SET_RECNO);
@@ -5107,8 +5128,10 @@
ADD_INT(d, DB_LOCK_DEADLOCK);
ADD_INT(d, DB_LOCK_NOTGRANTED);
ADD_INT(d, DB_NOSERVER);
+#if (DBVER < 52)
ADD_INT(d, DB_NOSERVER_HOME);
ADD_INT(d, DB_NOSERVER_ID);
+#endif
ADD_INT(d, DB_NOTFOUND);
ADD_INT(d, DB_OLD_VERSION);
ADD_INT(d, DB_RUNRECOVERY);
@@ -5130,15 +5153,17 @@
ADD_INT(d, DB_TIME_NOTGRANTED);
ADD_INT(d, DB_TXN_NOT_DURABLE);
ADD_INT(d, DB_TXN_WRITE_NOSYNC);
+#if (DBVER < 47)
ADD_INT(d, DB_LOG_AUTOREMOVE);
ADD_INT(d, DB_DIRECT_LOG);
+#endif
ADD_INT(d, DB_DIRECT_DB);
ADD_INT(d, DB_INIT_REP);
ADD_INT(d, DB_ENCRYPT);
ADD_INT(d, DB_CHKSUM);
#endif
-#if (DBVER >= 43)
+#if (DBVER >= 43) && (DBVER < 47)
ADD_INT(d, DB_LOG_INMEMORY);
ADD_INT(d, DB_BUFFER_SMALL);
#endif
@@ -5203,8 +5228,10 @@
MAKE_EX(DBRunRecoveryError);
MAKE_EX(DBVerifyBadError);
MAKE_EX(DBNoServerError);
+#if (DBVER < 50)
MAKE_EX(DBNoServerHomeError);
MAKE_EX(DBNoServerIDError);
+#endif
#if (DBVER >= 33)
MAKE_EX(DBPageNotFoundError);
MAKE_EX(DBSecondaryBadError);

View file

@ -0,0 +1,110 @@
--- _bsddb.c.orig 2008-05-17 14:46:39.000000000 +0800
+++ _bsddb.c 2011-10-10 10:29:43.469871000 +0800
@@ -167,8 +167,10 @@
static PyObject* DBRunRecoveryError; /* DB_RUNRECOVERY */
static PyObject* DBVerifyBadError; /* DB_VERIFY_BAD */
static PyObject* DBNoServerError; /* DB_NOSERVER */
+#if (DBVER < 52)
static PyObject* DBNoServerHomeError; /* DB_NOSERVER_HOME */
static PyObject* DBNoServerIDError; /* DB_NOSERVER_ID */
+#endif
#if (DBVER >= 33)
static PyObject* DBPageNotFoundError; /* DB_PAGE_NOTFOUND */
static PyObject* DBSecondaryBadError; /* DB_SECONDARY_BAD */
@@ -192,6 +194,9 @@
#define DB_BUFFER_SMALL ENOMEM
#endif
+#if (DBVER < 48)
+#define DB_GID_SIZE DB_XIDDATASIZE
+#endif
/* --------------------------------------------------------------------- */
/* Structure definitions */
@@ -581,8 +586,10 @@
case DB_RUNRECOVERY: errObj = DBRunRecoveryError; break;
case DB_VERIFY_BAD: errObj = DBVerifyBadError; break;
case DB_NOSERVER: errObj = DBNoServerError; break;
+#if (DBVER < 52)
case DB_NOSERVER_HOME: errObj = DBNoServerHomeError; break;
case DB_NOSERVER_ID: errObj = DBNoServerIDError; break;
+#endif
#if (DBVER >= 33)
case DB_PAGE_NOTFOUND: errObj = DBPageNotFoundError; break;
case DB_SECONDARY_BAD: errObj = DBSecondaryBadError; break;
@@ -4737,9 +4744,9 @@
if (!PyArg_ParseTuple(args, "s#:prepare", &gid, &gid_size))
return NULL;
- if (gid_size != DB_XIDDATASIZE) {
+ if (gid_size != DB_GID_SIZE) {
PyErr_SetString(PyExc_TypeError,
- "gid must be DB_XIDDATASIZE bytes long");
+ "gid must be DB_GID_SIZE bytes long");
return NULL;
}
@@ -5332,6 +5339,7 @@
static PyObject*
DBEnv_getattr(DBEnvObject* self, char *name)
{
+#if (DBVER < 46)
if (!strcmp(name, "db_home")) {
CHECK_ENV_NOT_CLOSED(self);
if (self->db_env->db_home == NULL) {
@@ -5339,6 +5347,7 @@
}
return PyString_FromString(self->db_env->db_home);
}
+#endif
return Py_FindMethod(DBEnv_methods, (PyObject* )self, name);
}
@@ -5708,13 +5717,17 @@
ADD_INT(d, DB_MAX_RECORDS);
#if (DBVER >= 42)
+#if (DBVER < 50)
ADD_INT(d, DB_RPCCLIENT);
+#endif
#else
ADD_INT(d, DB_CLIENT);
/* allow apps to be written using DB_RPCCLIENT on older BerkeleyDB */
_addIntToDict(d, "DB_RPCCLIENT", DB_CLIENT);
#endif
+#if (DBVER < 48 || DBVER > 51)
ADD_INT(d, DB_XA_CREATE);
+#endif
ADD_INT(d, DB_CREATE);
ADD_INT(d, DB_NOMMAP);
@@ -5936,8 +5949,10 @@
ADD_INT(d, DB_LOCK_DEADLOCK);
ADD_INT(d, DB_LOCK_NOTGRANTED);
ADD_INT(d, DB_NOSERVER);
+#if (DBVER < 52)
ADD_INT(d, DB_NOSERVER_HOME);
ADD_INT(d, DB_NOSERVER_ID);
+#endif
ADD_INT(d, DB_NOTFOUND);
ADD_INT(d, DB_OLD_VERSION);
ADD_INT(d, DB_RUNRECOVERY);
@@ -5959,15 +5974,17 @@
ADD_INT(d, DB_TIME_NOTGRANTED);
ADD_INT(d, DB_TXN_NOT_DURABLE);
ADD_INT(d, DB_TXN_WRITE_NOSYNC);
+#if (DBVER < 47)
ADD_INT(d, DB_LOG_AUTOREMOVE);
ADD_INT(d, DB_DIRECT_LOG);
+#endif
ADD_INT(d, DB_DIRECT_DB);
ADD_INT(d, DB_INIT_REP);
ADD_INT(d, DB_ENCRYPT);
ADD_INT(d, DB_CHKSUM);
#endif
-#if (DBVER >= 43)
+#if (DBVER >= 43) && (DBVER < 47)
ADD_INT(d, DB_LOG_INMEMORY);
ADD_INT(d, DB_BUFFER_SMALL);
ADD_INT(d, DB_SEQ_DEC);

View file

@ -0,0 +1,160 @@
--- _bsddb.c.orig 2010-05-09 23:15:40.000000000 +0800
+++ _bsddb.c 2011-10-10 10:29:43.469871000 +0800
@@ -186,8 +186,10 @@
static PyObject* DBRunRecoveryError; /* DB_RUNRECOVERY */
static PyObject* DBVerifyBadError; /* DB_VERIFY_BAD */
static PyObject* DBNoServerError; /* DB_NOSERVER */
+#if (DBVER < 52)
static PyObject* DBNoServerHomeError; /* DB_NOSERVER_HOME */
static PyObject* DBNoServerIDError; /* DB_NOSERVER_ID */
+#endif
static PyObject* DBPageNotFoundError; /* DB_PAGE_NOTFOUND */
static PyObject* DBSecondaryBadError; /* DB_SECONDARY_BAD */
@@ -215,6 +217,9 @@
#define DB_BUFFER_SMALL ENOMEM
#endif
+#if (DBVER < 48)
+#define DB_GID_SIZE DB_XIDDATASIZE
+#endif
/* --------------------------------------------------------------------- */
/* Structure definitions */
@@ -698,8 +703,10 @@
case DB_RUNRECOVERY: errObj = DBRunRecoveryError; break;
case DB_VERIFY_BAD: errObj = DBVerifyBadError; break;
case DB_NOSERVER: errObj = DBNoServerError; break;
+#if (DBVER < 52)
case DB_NOSERVER_HOME: errObj = DBNoServerHomeError; break;
case DB_NOSERVER_ID: errObj = DBNoServerIDError; break;
+#endif
case DB_PAGE_NOTFOUND: errObj = DBPageNotFoundError; break;
case DB_SECONDARY_BAD: errObj = DBSecondaryBadError; break;
case DB_BUFFER_SMALL: errObj = DBNoMemoryError; break;
@@ -4522,7 +4529,7 @@
flags=DB_NEXT; /* Prepare for next loop pass */
for (i=0; i<retp; i++) {
gid=PyBytes_FromStringAndSize((char *)(preplist[i].gid),
- DB_XIDDATASIZE);
+ DB_GID_SIZE);
if (!gid) {
Py_DECREF(list);
return NULL;
@@ -5047,6 +5054,7 @@
}
+#if (DBVER < 50)
static PyObject*
DBEnv_set_rpc_server(DBEnvObject* self, PyObject* args, PyObject* kwargs)
{
@@ -5068,6 +5076,7 @@
RETURN_IF_ERR();
RETURN_NONE();
}
+#endif
static PyObject*
DBEnv_set_verbose(DBEnvObject* self, PyObject* args)
@@ -5650,6 +5659,7 @@
RETURN_NONE();
}
+#if (DBVER < 52)
static PyObject*
DBEnv_repmgr_set_local_site(DBEnvObject* self, PyObject* args, PyObject*
kwargs)
@@ -5696,6 +5706,7 @@
RETURN_IF_ERR();
return NUMBER_FromLong(eidp);
}
+#endif
static PyObject*
DBEnv_repmgr_set_ack_policy(DBEnvObject* self, PyObject* args)
@@ -5949,9 +5960,9 @@
if (!PyArg_ParseTuple(args, "s#:prepare", &gid, &gid_size))
return NULL;
- if (gid_size != DB_XIDDATASIZE) {
+ if (gid_size != DB_GID_SIZE) {
PyErr_SetString(PyExc_TypeError,
- "gid must be DB_XIDDATASIZE bytes long");
+ "gid must be DB_GID_SIZE bytes long");
return NULL;
}
@@ -6541,8 +6552,10 @@
#endif
{"set_get_returns_none",(PyCFunction)DBEnv_set_get_returns_none, METH_VARARGS},
{"txn_recover", (PyCFunction)DBEnv_txn_recover, METH_NOARGS},
+#if (DBVER < 50)
{"set_rpc_server", (PyCFunction)DBEnv_set_rpc_server,
METH_VARARGS||METH_KEYWORDS},
+#endif
{"set_verbose", (PyCFunction)DBEnv_set_verbose, METH_VARARGS},
#if (DBVER >= 42)
{"get_verbose", (PyCFunction)DBEnv_get_verbose, METH_VARARGS},
@@ -6584,10 +6597,12 @@
#if (DBVER >= 45)
{"repmgr_start", (PyCFunction)DBEnv_repmgr_start,
METH_VARARGS|METH_KEYWORDS},
+#if (DBVER < 52)
{"repmgr_set_local_site", (PyCFunction)DBEnv_repmgr_set_local_site,
METH_VARARGS|METH_KEYWORDS},
{"repmgr_add_remote_site", (PyCFunction)DBEnv_repmgr_add_remote_site,
METH_VARARGS|METH_KEYWORDS},
+#endif
{"repmgr_set_ack_policy", (PyCFunction)DBEnv_repmgr_set_ack_policy,
METH_VARARGS},
{"repmgr_get_ack_policy", (PyCFunction)DBEnv_repmgr_get_ack_policy,
@@ -7092,13 +7107,17 @@
ADD_INT(d, DB_MAX_RECORDS);
#if (DBVER >= 42)
+#if (DBVER < 50)
ADD_INT(d, DB_RPCCLIENT);
+#endif
#else
ADD_INT(d, DB_CLIENT);
/* allow apps to be written using DB_RPCCLIENT on older Berkeley DB */
_addIntToDict(d, "DB_RPCCLIENT", DB_CLIENT);
#endif
+#if (DBVER < 48 || DBVER > 51)
ADD_INT(d, DB_XA_CREATE);
+#endif
ADD_INT(d, DB_CREATE);
ADD_INT(d, DB_NOMMAP);
@@ -7115,7 +7134,7 @@
ADD_INT(d, DB_INIT_TXN);
ADD_INT(d, DB_JOINENV);
- ADD_INT(d, DB_XIDDATASIZE);
+ ADD_INT(d, DB_GID_SIZE);
ADD_INT(d, DB_RECOVER);
ADD_INT(d, DB_RECOVER_FATAL);
@@ -7296,8 +7315,10 @@
ADD_INT(d, DB_LOCK_DEADLOCK);
ADD_INT(d, DB_LOCK_NOTGRANTED);
ADD_INT(d, DB_NOSERVER);
+#if (DBVER < 52)
ADD_INT(d, DB_NOSERVER_HOME);
ADD_INT(d, DB_NOSERVER_ID);
+#endif
ADD_INT(d, DB_NOTFOUND);
ADD_INT(d, DB_OLD_VERSION);
ADD_INT(d, DB_RUNRECOVERY);
@@ -7512,8 +7533,10 @@
MAKE_EX(DBRunRecoveryError);
MAKE_EX(DBVerifyBadError);
MAKE_EX(DBNoServerError);
+#if (DBVER < 52)
MAKE_EX(DBNoServerHomeError);
MAKE_EX(DBNoServerIDError);
+#endif
MAKE_EX(DBPageNotFoundError);
MAKE_EX(DBSecondaryBadError);

View file

@ -1,25 +1,36 @@
--- _bsddb.c.orig 2011-06-11 23:46:26.000000000 +0800
+++ _bsddb.c 2011-09-14 00:21:23.155423631 +0800
@@ -696,8 +696,10 @@
+++ _bsddb.c 2011-10-10 10:29:43.469871000 +0800
@@ -187,8 +187,10 @@
static PyObject* DBRunRecoveryError; /* DB_RUNRECOVERY */
static PyObject* DBVerifyBadError; /* DB_VERIFY_BAD */
static PyObject* DBNoServerError; /* DB_NOSERVER */
+#if (DBVER < 52)
static PyObject* DBNoServerHomeError; /* DB_NOSERVER_HOME */
static PyObject* DBNoServerIDError; /* DB_NOSERVER_ID */
+#endif
static PyObject* DBPageNotFoundError; /* DB_PAGE_NOTFOUND */
static PyObject* DBSecondaryBadError; /* DB_SECONDARY_BAD */
@@ -696,8 +698,10 @@
case DB_RUNRECOVERY: errObj = DBRunRecoveryError; break;
case DB_VERIFY_BAD: errObj = DBVerifyBadError; break;
case DB_NOSERVER: errObj = DBNoServerError; break;
+#if (DBVER < 50)
+#if (DBVER < 52)
case DB_NOSERVER_HOME: errObj = DBNoServerHomeError; break;
case DB_NOSERVER_ID: errObj = DBNoServerIDError; break;
+#endif
case DB_PAGE_NOTFOUND: errObj = DBPageNotFoundError; break;
case DB_SECONDARY_BAD: errObj = DBSecondaryBadError; break;
case DB_BUFFER_SMALL: errObj = DBNoMemoryError; break;
@@ -7608,6 +7610,7 @@
@@ -7608,6 +7612,7 @@
RETURN_NONE();
}
+#if (DBVER < 50)
+#if (DBVER < 52)
static PyObject*
DBEnv_repmgr_set_local_site(DBEnvObject* self, PyObject* args, PyObject*
kwargs)
@@ -7654,6 +7657,7 @@
@@ -7654,6 +7659,7 @@
RETURN_IF_ERR();
return NUMBER_FromLong(eidp);
}
@ -27,11 +38,11 @@
static PyObject*
DBEnv_repmgr_set_ack_policy(DBEnvObject* self, PyObject* args)
@@ -8855,10 +8859,12 @@
@@ -8855,10 +8861,12 @@
#if (DBVER >= 45)
{"repmgr_start", (PyCFunction)DBEnv_repmgr_start,
METH_VARARGS|METH_KEYWORDS},
+#if (DBVER < 50)
+#if (DBVER < 52)
{"repmgr_set_local_site", (PyCFunction)DBEnv_repmgr_set_local_site,
METH_VARARGS|METH_KEYWORDS},
{"repmgr_add_remote_site", (PyCFunction)DBEnv_repmgr_add_remote_site,
@ -40,18 +51,27 @@
{"repmgr_set_ack_policy", (PyCFunction)DBEnv_repmgr_set_ack_policy,
METH_VARARGS},
{"repmgr_get_ack_policy", (PyCFunction)DBEnv_repmgr_get_ack_policy,
@@ -9651,8 +9657,10 @@
@@ -9437,7 +9445,7 @@
#endif
#endif
-#if (DBVER < 48)
+#if (DBVER < 48 || DBVER > 51)
ADD_INT(d, DB_XA_CREATE);
#endif
@@ -9651,8 +9659,10 @@
ADD_INT(d, DB_LOCK_DEADLOCK);
ADD_INT(d, DB_LOCK_NOTGRANTED);
ADD_INT(d, DB_NOSERVER);
+#if (DBVER < 50)
+#if (DBVER < 52)
ADD_INT(d, DB_NOSERVER_HOME);
ADD_INT(d, DB_NOSERVER_ID);
+#endif
ADD_INT(d, DB_NOTFOUND);
ADD_INT(d, DB_OLD_VERSION);
ADD_INT(d, DB_RUNRECOVERY);
@@ -9766,7 +9774,9 @@
@@ -9766,7 +9776,9 @@
ADD_INT(d, DB_REP_PERMANENT);
#if (DBVER >= 44)
@ -61,3 +81,14 @@
ADD_INT(d, DB_REP_CONF_DELAYCLIENT);
ADD_INT(d, DB_REP_CONF_BULK);
ADD_INT(d, DB_REP_CONF_NOWAIT);
@@ -9912,8 +9924,10 @@
MAKE_EX(DBRunRecoveryError);
MAKE_EX(DBVerifyBadError);
MAKE_EX(DBNoServerError);
+#if (DBVER < 52)
MAKE_EX(DBNoServerHomeError);
MAKE_EX(DBNoServerIDError);
+#endif
MAKE_EX(DBPageNotFoundError);
MAKE_EX(DBSecondaryBadError);