summary refs log tree commit diff
path: root/pkgs/development/libraries/db
diff options
context:
space:
mode:
authorWilliam A. Kennington III <william@wkennington.com>2014-01-31 03:25:49 -0600
committerBjørn Forsman <bjorn.forsman@gmail.com>2014-02-15 12:03:01 +0100
commit99f5d2edb423194540a2bf83365e7b78b1ffccc9 (patch)
tree6f0b7b5a75c6d02b9b8599ae5e1cf1b512af6d7f /pkgs/development/libraries/db
parent68b3fd33a78ce51268f0eec31386a056d760ffc1 (diff)
downloadnixpkgs-99f5d2edb423194540a2bf83365e7b78b1ffccc9.tar
nixpkgs-99f5d2edb423194540a2bf83365e7b78b1ffccc9.tar.gz
nixpkgs-99f5d2edb423194540a2bf83365e7b78b1ffccc9.tar.bz2
nixpkgs-99f5d2edb423194540a2bf83365e7b78b1ffccc9.tar.lz
nixpkgs-99f5d2edb423194540a2bf83365e7b78b1ffccc9.tar.xz
nixpkgs-99f5d2edb423194540a2bf83365e7b78b1ffccc9.tar.zst
nixpkgs-99f5d2edb423194540a2bf83365e7b78b1ffccc9.zip
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.
Diffstat (limited to 'pkgs/development/libraries/db')
-rw-r--r--pkgs/development/libraries/db/cygwin-4.4.patch21
-rw-r--r--pkgs/development/libraries/db/cygwin-4.5.patch22
-rw-r--r--pkgs/development/libraries/db/db-4.4.nix7
-rw-r--r--pkgs/development/libraries/db/db-4.5.nix7
-rw-r--r--pkgs/development/libraries/db/db-4.7.nix6
-rw-r--r--pkgs/development/libraries/db/db-4.8.nix6
-rw-r--r--pkgs/development/libraries/db/db-5.3.nix36
-rw-r--r--pkgs/development/libraries/db/db-6.0.nix7
-rw-r--r--pkgs/development/libraries/db/generic.nix41
-rw-r--r--pkgs/development/libraries/db/register-race-fix.patch47
10 files changed, 169 insertions, 31 deletions
diff --git a/pkgs/development/libraries/db/cygwin-4.4.patch b/pkgs/development/libraries/db/cygwin-4.4.patch
new file mode 100644
index 00000000000..3f9d658b5da
--- /dev/null
+++ b/pkgs/development/libraries/db/cygwin-4.4.patch
@@ -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;
diff --git a/pkgs/development/libraries/db/cygwin-4.5.patch b/pkgs/development/libraries/db/cygwin-4.5.patch
new file mode 100644
index 00000000000..3f0ee78a708
--- /dev/null
+++ b/pkgs/development/libraries/db/cygwin-4.5.patch
@@ -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~
diff --git a/pkgs/development/libraries/db/db-4.4.nix b/pkgs/development/libraries/db/db-4.4.nix
new file mode 100644
index 00000000000..4a182353f25
--- /dev/null
+++ b/pkgs/development/libraries/db/db-4.4.nix
@@ -0,0 +1,7 @@
+{ stdenv, fetchurl, ... } @ args:
+
+import ./generic.nix (args // rec {
+  version = "4.4.20";
+  extraPatches = [ ./cygwin-4.4.patch ];
+  sha256 = "0y9vsq8dkarx1mhhip1vaciz6imbbyv37c1dm8b20l7p064bg2i9";
+})
diff --git a/pkgs/development/libraries/db/db-4.5.nix b/pkgs/development/libraries/db/db-4.5.nix
new file mode 100644
index 00000000000..6a0a921d8de
--- /dev/null
+++ b/pkgs/development/libraries/db/db-4.5.nix
@@ -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";
+})
diff --git a/pkgs/development/libraries/db/db-4.7.nix b/pkgs/development/libraries/db/db-4.7.nix
new file mode 100644
index 00000000000..62ccfd7d3a5
--- /dev/null
+++ b/pkgs/development/libraries/db/db-4.7.nix
@@ -0,0 +1,6 @@
+{ stdenv, fetchurl, ... } @ args:
+
+import ./generic.nix (args // rec {
+  version = "4.7.25";
+  sha256 = "0gi667v9cw22c03hddd6xd6374l0pczsd56b7pba25c9sdnxjkzi";
+})
diff --git a/pkgs/development/libraries/db/db-4.8.nix b/pkgs/development/libraries/db/db-4.8.nix
new file mode 100644
index 00000000000..e77307d6fa5
--- /dev/null
+++ b/pkgs/development/libraries/db/db-4.8.nix
@@ -0,0 +1,6 @@
+{ stdenv, fetchurl, ... } @ args:
+
+import ./generic.nix (args // rec {
+  version = "4.8.30";
+  sha256 = "0ampbl2f0hb1nix195kz1syrqqxpmvnvnfvphambj7xjrl3iljg0";
+})
diff --git a/pkgs/development/libraries/db/db-5.3.nix b/pkgs/development/libraries/db/db-5.3.nix
index a59d28ba963..af16f1ddf54 100644
--- a/pkgs/development/libraries/db/db-5.3.nix
+++ b/pkgs/development/libraries/db/db-5.3.nix
@@ -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";
+})
diff --git a/pkgs/development/libraries/db/db-6.0.nix b/pkgs/development/libraries/db/db-6.0.nix
new file mode 100644
index 00000000000..22e858a9d18
--- /dev/null
+++ b/pkgs/development/libraries/db/db-6.0.nix
@@ -0,0 +1,7 @@
+{ stdenv, fetchurl, ... } @ args:
+
+import ./generic.nix (args // rec {
+  version = "6.0.20";
+  sha256 = "00r2aaglq625y8r9xd5vw2y070plp88f1mb2gbq3kqsl7128lsl0";
+  license = stdenv.lib.licenses.agpl3;
+})
diff --git a/pkgs/development/libraries/db/generic.nix b/pkgs/development/libraries/db/generic.nix
new file mode 100644
index 00000000000..de9fb27b4ec
--- /dev/null
+++ b/pkgs/development/libraries/db/generic.nix
@@ -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;
+  };
+}
diff --git a/pkgs/development/libraries/db/register-race-fix.patch b/pkgs/development/libraries/db/register-race-fix.patch
new file mode 100644
index 00000000000..bb05c966e5b
--- /dev/null
+++ b/pkgs/development/libraries/db/register-race-fix.patch
@@ -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?
+  	 *