about summary refs log tree commit diff
path: root/pkgs/servers/mail/dspam
diff options
context:
space:
mode:
authorYorick van Pelt <yorick@yorickvanpelt.nl>2022-10-11 18:04:10 +0200
committerYorick van Pelt <yorick@yorickvanpelt.nl>2022-10-12 10:29:27 +0200
commit44cbcce4123eb5a539842d53b82fcca7b5c3fdcd (patch)
tree48d45ad3999895aa9c9bd869a505ba3f0e960ad8 /pkgs/servers/mail/dspam
parent4a90d82f1ac1ba3f4cea71273a92e9c820777067 (diff)
dspam: switch from mysql57 to mariadb-connector-c
Diffstat (limited to 'pkgs/servers/mail/dspam')
-rw-r--r--pkgs/servers/mail/dspam/default.nix17
-rw-r--r--pkgs/servers/mail/dspam/mariadb.patch42
2 files changed, 56 insertions, 3 deletions
diff --git a/pkgs/servers/mail/dspam/default.nix b/pkgs/servers/mail/dspam/default.nix
index e2388e6a94916..31f149f1dd422 100644
--- a/pkgs/servers/mail/dspam/default.nix
+++ b/pkgs/servers/mail/dspam/default.nix
@@ -1,7 +1,7 @@
 { stdenv, lib, fetchurl, makeWrapper
 , gawk, gnused, gnugrep, coreutils, which
 , perlPackages
-, withMySQL ? false, zlib, mysql57
+, withMySQL ? false, zlib, mariadb-connector-c
 , withPgSQL ? false, postgresql
 , withSQLite ? false, sqlite
 , withDB ? false, db
@@ -25,13 +25,21 @@ in stdenv.mkDerivation rec {
     url = "mirror://sourceforge/dspam/dspam/${pname}-${version}/${pname}-${version}.tar.gz";
     sha256 = "1acklnxn1wvc7abn31l3qdj8q6k13s51k5gv86vka7q20jb5cxmf";
   };
+  patches = [
+    # https://gist.github.com/WhiteAnthrax/613136c76882e0ead3cb3bdad6b3d551
+    ./mariadb.patch
+  ];
 
   buildInputs = [ perlPackages.perl ]
-                ++ lib.optionals withMySQL [ zlib mysql57.connector-c ]
+                ++ lib.optionals withMySQL [ zlib mariadb-connector-c.out ]
                 ++ lib.optional withPgSQL postgresql
                 ++ lib.optional withSQLite sqlite
                 ++ lib.optional withDB db;
   nativeBuildInputs = [ makeWrapper ];
+  # patch out libmysql >= 5 check, since mariadb-connector is at 3.x
+  postPatch = ''
+    sed -i 's/atoi(m) >= 5/1/g' configure m4/mysql_drv.m4
+  '';
 
   configureFlags = [
     "--with-storage-driver=${drivers}"
@@ -50,7 +58,10 @@ in stdenv.mkDerivation rec {
     "--enable-preferences-extension"
     "--enable-long-usernames"
     "--enable-external-lookup"
-  ] ++ lib.optional withMySQL "--with-mysql-includes=${mysql57.connector-c}/include/mysql"
+  ] ++ lib.optionals withMySQL [
+    "--with-mysql-includes=${mariadb-connector-c.dev}/include/mysql"
+    "--with-mysql-libraries=${mariadb-connector-c.out}/lib/mysql"
+  ]
     ++ lib.optional withPgSQL "--with-pgsql-libraries=${postgresql.lib}/lib";
 
   # Workaround build failure on -fno-common toolchains like upstream
diff --git a/pkgs/servers/mail/dspam/mariadb.patch b/pkgs/servers/mail/dspam/mariadb.patch
new file mode 100644
index 0000000000000..5f3d8277d9433
--- /dev/null
+++ b/pkgs/servers/mail/dspam/mariadb.patch
@@ -0,0 +1,42 @@
+diff -ur dspam-3.10.2.orig/configure dspam-3.10.2/configure
+--- dspam-3.10.2.orig/configure	2012-04-24 02:53:49.000000000 +0900
++++ dspam-3.10.2/configure	2019-05-24 01:59:06.557890494 +0900
+@@ -13280,7 +13280,7 @@
+     #include <mysql.h>
+     #include <mysqld_error.h>
+     #include <errmsg.h>
+-    #if defined(PROTOCOL_VERSION) && defined(ER_LOCK_DEADLOCK) && defined(ER_LOCK_WAIT_TIMEOUT) && defined(ER_LOCK_OR_ACTIVE_TRANSACTION) && defined(CR_ERROR_FIRST)
++    #if defined(PROTOCOL_VERSION) && defined(ER_LOCK_DEADLOCK) && defined(ER_LOCK_WAIT_TIMEOUT) && defined(ER_LOCK_OR_ACTIVE_TRANSACTION) && defined(CR_MIN_ERROR)
+     /* Success */
+     #else
+     #error Unsupported version of MySQL
+@@ -13293,7 +13293,7 @@
+ 
+                 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+ $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+-as_fn_error $? "Unsupported version of MySQL (no PROTOCOL_VERSION or ER_LOCK_DEADLOCK or ER_LOCK_WAIT_TIMEOUT or ER_LOCK_OR_ACTIVE_TRANSACTION or CR_ERROR_FIRST defined)
++as_fn_error $? "Unsupported version of MySQL (no PROTOCOL_VERSION or ER_LOCK_DEADLOCK or ER_LOCK_WAIT_TIMEOUT or ER_LOCK_OR_ACTIVE_TRANSACTION or CR_MIN_ERROR defined)
+ See \`config.log' for more details" "$LINENO" 5; }
+                 mysql_headers_success=no
+ 
+diff -ur dspam-3.10.2.orig/m4/mysql_drv.m4 dspam-3.10.2/m4/mysql_drv.m4
+--- dspam-3.10.2.orig/m4/mysql_drv.m4	2011-08-17 07:38:30.000000000 +0900
++++ dspam-3.10.2/m4/mysql_drv.m4	2019-05-24 02:00:08.301217506 +0900
+@@ -80,7 +80,7 @@
+     #include <mysql.h>
+     #include <mysqld_error.h>
+     #include <errmsg.h>
+-    #if defined(PROTOCOL_VERSION) && defined(ER_LOCK_DEADLOCK) && defined(ER_LOCK_WAIT_TIMEOUT) && defined(ER_LOCK_OR_ACTIVE_TRANSACTION) && defined(CR_ERROR_FIRST)
++    #if defined(PROTOCOL_VERSION) && defined(ER_LOCK_DEADLOCK) && defined(ER_LOCK_WAIT_TIMEOUT) && defined(ER_LOCK_OR_ACTIVE_TRANSACTION) && defined(CR_MIN_ERROR)
+     /* Success */
+     #else
+     #error Unsupported version of MySQL 
+@@ -88,7 +88,7 @@
+             ]])],
+             [],
+             [
+-                AC_MSG_FAILURE([Unsupported version of MySQL (no PROTOCOL_VERSION or ER_LOCK_DEADLOCK or ER_LOCK_WAIT_TIMEOUT or ER_LOCK_OR_ACTIVE_TRANSACTION or CR_ERROR_FIRST defined)])
++                AC_MSG_FAILURE([Unsupported version of MySQL (no PROTOCOL_VERSION or ER_LOCK_DEADLOCK or ER_LOCK_WAIT_TIMEOUT or ER_LOCK_OR_ACTIVE_TRANSACTION or CR_MIN_ERROR defined)])
+                 mysql_headers_success=no
+             ])
+ fi