db: Reorganize Berkeley Database Packaging

Currently, the berkeley databases resuses a lot of the same code for the
expressions of each version. This consolidates all of the build routines
similar to that of the linux kernel.

This patch also adds version 6 of BDB.
This commit is contained in:
William A. Kennington III
2014-01-31 03:25:49 -06:00
committed by Bjørn Forsman
parent 68b3fd33a7
commit 99f5d2edb4
16 changed files with 88 additions and 130 deletions

View File

@@ -0,0 +1,21 @@
diff -rc db-4.4.20.NC-old/os/os_flock.c db-4.4.20.NC/os/os_flock.c
*** db-4.4.20.NC-old/os/os_flock.c Mon Jun 20 16:59:01 2005
--- db-4.4.20.NC/os/os_flock.c Wed Jun 7 17:01:49 2006
***************
*** 36,41 ****
--- 36,50 ----
DB_ASSERT(F_ISSET(fhp, DB_FH_OPENED) && fhp->fd != -1);
+ #ifdef __CYGWIN__
+ /*
+ * Windows file locking interferes with read/write operations, so we
+ * map the ranges to an area past the end of the file.
+ */
+ DB_ASSERT(offset < (off_t) 1 << 62);
+ offset += (off_t) 1 << 62;
+ #endif
+
#ifdef HAVE_FCNTL
fl.l_start = offset;
fl.l_len = 1;

View File

@@ -0,0 +1,22 @@
diff -rc db-4.5.20-orig/os/os_flock.c db-4.5.20/os/os_flock.c
*** db-4.5.20-orig/os/os_flock.c 2006-10-13 12:36:12.000000000 +0200
--- db-4.5.20/os/os_flock.c 2006-10-13 12:40:11.000000000 +0200
***************
*** 30,35 ****
--- 30,44 ----
DB_ASSERT(dbenv, F_ISSET(fhp, DB_FH_OPENED) && fhp->fd != -1);
+ #ifdef __CYGWIN__
+ /*
+ * Windows file locking interferes with read/write operations, so we
+ * map the ranges to an area past the end of the file.
+ */
+ DB_ASSERT(dbenv, offset < (off_t) 1 << 62);
+ offset += (off_t) 1 << 62;
+ #endif
+
fl.l_start = offset;
fl.l_len = 1;
fl.l_type = acquire ? F_WRLCK : F_UNLCK;
Only in db-4.5.20/os: os_flock.c~

View File

@@ -0,0 +1,7 @@
{ stdenv, fetchurl, ... } @ args:
import ./generic.nix (args // rec {
version = "4.4.20";
extraPatches = [ ./cygwin-4.4.patch ];
sha256 = "0y9vsq8dkarx1mhhip1vaciz6imbbyv37c1dm8b20l7p064bg2i9";
})

View File

@@ -0,0 +1,7 @@
{ stdenv, fetchurl, ... } @ args:
import ./generic.nix (args // rec {
version = "4.5.20";
extraPatches = [ ./cygwin-4.5.patch ./register-race-fix.patch ];
sha256 = "0bd81k0qv5i8w5gbddrvld45xi9k1gvmcrfm0393v0lrm37dab7m";
})

View File

@@ -0,0 +1,6 @@
{ stdenv, fetchurl, ... } @ args:
import ./generic.nix (args // rec {
version = "4.7.25";
sha256 = "0gi667v9cw22c03hddd6xd6374l0pczsd56b7pba25c9sdnxjkzi";
})

View File

@@ -0,0 +1,6 @@
{ stdenv, fetchurl, ... } @ args:
import ./generic.nix (args // rec {
version = "4.8.30";
sha256 = "0ampbl2f0hb1nix195kz1syrqqxpmvnvnfvphambj7xjrl3iljg0";
})

View File

@@ -1,32 +1,6 @@
{ stdenv, fetchurl
, cxxSupport ? true
}:
{ stdenv, fetchurl, ... } @ args:
stdenv.mkDerivation rec {
name = "db-5.3.28";
src = fetchurl {
url = "http://download.oracle.com/berkeley-db/${name}.tar.gz";
sha256 = "0a1n5hbl7027fbz5lm0vp0zzfp1hmxnz14wx3zl9563h83br5ag0";
};
configureFlags = [
(if cxxSupport then "--enable-cxx" else "--disable-cxx")
];
preConfigure = ''
cd build_unix
configureScript=../dist/configure
'';
postInstall = ''
rm -rf $out/docs
'';
meta = with stdenv.lib; {
homepage = "http://www.oracle.com/technetwork/database/database-technologies/berkeleydb/index.html";
description = "Berkeley DB";
license = "Berkeley Database License";
platforms = platforms.unix;
};
}
import ./generic.nix (args // rec {
version = "5.3.28";
sha256 = "0a1n5hbl7027fbz5lm0vp0zzfp1hmxnz14wx3zl9563h83br5ag0";
})

View File

@@ -0,0 +1,7 @@
{ stdenv, fetchurl, ... } @ args:
import ./generic.nix (args // rec {
version = "6.0.20";
sha256 = "00r2aaglq625y8r9xd5vw2y070plp88f1mb2gbq3kqsl7128lsl0";
license = stdenv.lib.licenses.agpl3;
})

View File

@@ -0,0 +1,41 @@
{ stdenv, fetchurl
, cxxSupport ? true
, compat185 ? true
# Options from inherited versions
, version, sha256
, extraPatches ? [ ]
, license ? "Berkeley Database License"
}:
stdenv.mkDerivation rec {
name = "db-${version}";
src = fetchurl {
url = "http://download.oracle.com/berkeley-db/${name}.tar.gz";
sha256 = sha256;
};
patches = extraPatches;
configureFlags = [
(if cxxSupport then "--enable-cxx" else "--disable-cxx")
(if compat185 then "--enable-compat185" else "--disable-compat185")
];
preConfigure = ''
cd build_unix
configureScript=../dist/configure
'';
postInstall = ''
rm -rf $out/docs
'';
meta = with stdenv.lib; {
homepage = "http://www.oracle.com/technetwork/database/database-technologies/berkeleydb/index.html";
description = "Berkeley DB";
license = license;
platforms = platforms.unix;
};
}

View File

@@ -0,0 +1,47 @@
diff -rc db-4.5.20-orig/env/env_register.c db-4.5.20/env/env_register.c
*** db-4.5.20-orig/env/env_register.c 2006-09-09 16:29:04.000000000 +0200
--- db-4.5.20/env/env_register.c 2007-05-16 21:13:27.000000000 +0200
***************
*** 255,260 ****
--- 255,262 ----
buf[nr - 1] = '\0';
}
+ //sleep(3);
+
pos = (off_t)lcnt * PID_LEN;
if (REGISTRY_LOCK(dbenv, pos, 1) == 0) {
if ((ret = REGISTRY_UNLOCK(dbenv, pos)) != 0)
***************
*** 361,366 ****
--- 363,392 ----
if (recovery_failed)
goto err;
+ //sleep(5);
+
+ /*
+ * Acquire an exclusive lock to prevent a race like this:
+ *
+ * 1) Process X is about to exit and process Y is just
+ * starting.
+ * 2) Process Y reads X's slot.
+ * 3) Process X clears its slot.
+ * 4) Process Y sees that X's slot isn't cleared yet (since it
+ * just read the old value).
+ * 5) Process X closes the registry, releases the lock on its
+ * slot.
+ * 6) Process Y tries to acquire X's slot and succeeds, so it
+ * concludes that X died and recovery is needed.
+ *
+ * A more efficient solution to this problem would be to let
+ * __envreg_add acquire the lock on a slot first, and *then*
+ * read the slot (instead of the other way around). Then we
+ * wouldn't need the exclusive lock here.
+ */
+ if ((ret = REGISTRY_EXCL_LOCK(dbenv, 0)) != 0)
+ goto err;
+
/*
* Why isn't an exclusive lock necessary to discard a DB_ENV handle?
*