about summary refs log tree commit diff
path: root/pkgs/servers/mail/postfix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/servers/mail/postfix')
-rw-r--r--pkgs/servers/mail/postfix/0001-Fix-build-with-unbound-1.6.1.patch54
-rw-r--r--pkgs/servers/mail/postfix/2.11.nix63
-rw-r--r--pkgs/servers/mail/postfix/db-linux3.patch39
-rw-r--r--pkgs/servers/mail/postfix/default.nix111
-rw-r--r--pkgs/servers/mail/postfix/pfixtools.nix55
-rw-r--r--pkgs/servers/mail/postfix/pflogsumm.nix35
-rw-r--r--pkgs/servers/mail/postfix/post-install-script.patch28
-rw-r--r--pkgs/servers/mail/postfix/postfix-2.11.0.patch76
-rw-r--r--pkgs/servers/mail/postfix/postfix-2.2.9-db.patch40
-rw-r--r--pkgs/servers/mail/postfix/postfix-2.2.9-lib.patch12
-rw-r--r--pkgs/servers/mail/postfix/postfix-3.0-no-warnings.patch86
-rw-r--r--pkgs/servers/mail/postfix/postfix-script-shell.patch21
-rw-r--r--pkgs/servers/mail/postfix/relative-symlinks.patch13
13 files changed, 364 insertions, 269 deletions
diff --git a/pkgs/servers/mail/postfix/0001-Fix-build-with-unbound-1.6.1.patch b/pkgs/servers/mail/postfix/0001-Fix-build-with-unbound-1.6.1.patch
new file mode 100644
index 000000000000..5de22573ea33
--- /dev/null
+++ b/pkgs/servers/mail/postfix/0001-Fix-build-with-unbound-1.6.1.patch
@@ -0,0 +1,54 @@
+From bf269dda3c81bb9eaa244b3015d426de38c85ccf Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Carles=20Pag=C3=A8s?= <page@ruiec.cat>
+Date: Fri, 3 Mar 2017 09:59:09 +0100
+Subject: [PATCH] Fix build with unbound 1.6.1
+
+From their changelog: Fix to rename ub_callback_t to ub_callback_type, because POSIX reserves _t typedefs
+---
+ postlicyd/dns.c       | 2 +-
+ postlicyd/dns.h       | 2 +-
+ postlicyd/spf-proto.c | 2 +-
+ 3 files changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/postlicyd/dns.c b/postlicyd/dns.c
+index d8409c2..97f1c4d 100644
+--- a/postlicyd/dns.c
++++ b/postlicyd/dns.c
+@@ -123,7 +123,7 @@ static int dns_handler(client_t *event, void *config)
+ }
+ 
+ bool dns_resolve(const char *hostname, dns_rrtype_t type,
+-                 ub_callback_t callback, void *data)
++                 ub_callback_type callback, void *data)
+ {
+     if (_G.ctx == NULL) {
+         _G.ctx = ub_ctx_create();
+diff --git a/postlicyd/dns.h b/postlicyd/dns.h
+index d84de3b..905b924 100644
+--- a/postlicyd/dns.h
++++ b/postlicyd/dns.h
+@@ -89,7 +89,7 @@ typedef void (*dns_result_callback_f)(dns_result_t *result, void *data);
+  */
+ __attribute__((nonnull(1,3,4)))
+ bool dns_resolve(const char *hostname, dns_rrtype_t type,
+-                 ub_callback_t callback, void *data);
++                 ub_callback_type callback, void *data);
+ 
+ /** Fetch the DNS record of the given type.
+  */
+diff --git a/postlicyd/spf-proto.c b/postlicyd/spf-proto.c
+index 31cb0a5..79a2d83 100644
+--- a/postlicyd/spf-proto.c
++++ b/postlicyd/spf-proto.c
+@@ -279,7 +279,7 @@ static bool spf_validate_domain(const char* restrict domain)
+ }
+ 
+ static bool spf_query(spf_t *spf, const char* query, dns_rrtype_t rtype,
+-                      ub_callback_t cb)
++                      ub_callback_type cb)
+ {
+     buffer_reset(&_G.query_buffer);
+     buffer_addstr(&_G.query_buffer, query);
+-- 
+2.12.0
+
diff --git a/pkgs/servers/mail/postfix/2.11.nix b/pkgs/servers/mail/postfix/2.11.nix
deleted file mode 100644
index bfd10fb591b2..000000000000
--- a/pkgs/servers/mail/postfix/2.11.nix
+++ /dev/null
@@ -1,63 +0,0 @@
-{ stdenv, fetchurl, makeWrapper, gnused, db, openssl, cyrus_sasl, coreutils
-, findutils, gnugrep, gawk
-}:
-
-stdenv.mkDerivation rec {
-
-  name = "postfix-${version}";
-
-  version = "2.11.5";
-
-  src = fetchurl {
-    url = "ftp://ftp.cs.uu.nl/mirror/postfix/postfix-release/official/${name}.tar.gz";
-    sha256 = "11riz8ggaa09pi8d6xv2807qp7yjn918mrylfvkfwmvcdlgwck0a";
-  };
-
-  patches = [ ./postfix-2.11.0.patch ];
-
-  buildInputs = [ makeWrapper gnused db openssl cyrus_sasl ];
-
-  preBuild = ''
-    sed -e '/^PATH=/d' -i postfix-install
-
-    export command_directory=$out/sbin
-    export config_directory=$out/etc/postfix
-    export daemon_directory=$out/libexec/postfix
-    export data_directory=/var/lib/postfix
-    export html_directory=$out/share/postfix/doc/html
-    export mailq_path=$out/bin/mailq
-    export manpage_directory=$out/share/man
-    export newaliases_path=$out/bin/newaliases
-    export queue_directory=/var/spool/postfix
-    export readme_directory=$out/share/postfix/doc
-    export sendmail_path=$out/bin/sendmail
-
-    make makefiles \
-      CCARGS='-DUSE_TLS -DUSE_SASL_AUTH -DUSE_CYRUS_SASL -I${cyrus_sasl}/include/sasl \
-              -fPIE -fstack-protector-all --param ssp-buffer-size=4 -O2 -D_FORTIFY_SOURCE=2' \
-      AUXLIBS='-ldb -lnsl -lresolv -lsasl2 -lcrypto -lssl -pie -Wl,-z,relro,-z,now'
-  '';
-
-  installTargets = [ "non-interactive-package" ];
-
-  installFlags = [ " install_root=$out " ];
-
-  postInstall = ''
-    mkdir -p $out
-    mv -v ut/$out/* $out/
-    sed -e '/^PATH=/d' -i $out/libexec/postfix/post-install
-    wrapProgram $out/libexec/postfix/post-install \
-      --prefix PATH ":" ${coreutils}/bin:${findutils}/bin:${gnugrep}/bin
-    wrapProgram $out/libexec/postfix/postfix-script \
-      --prefix PATH ":" ${coreutils}/bin:${findutils}/bin:${gnugrep}/bin:${gawk}/bin:${gnused}/bin
-  '';
-
-  meta = {
-    homepage = "http://www.postfix.org/";
-    description = "A fast, easy to administer, and secure mail server";
-    license = stdenv.lib.licenses.bsdOriginal;
-    platforms = stdenv.lib.platforms.linux;
-    maintainers = [ stdenv.lib.maintainers.rickynils ];
-  };
-
-}
diff --git a/pkgs/servers/mail/postfix/db-linux3.patch b/pkgs/servers/mail/postfix/db-linux3.patch
deleted file mode 100644
index c9dd4646798a..000000000000
--- a/pkgs/servers/mail/postfix/db-linux3.patch
+++ /dev/null
@@ -1,39 +0,0 @@
-diff --git a/makedefs b/makedefs
-index b8b98c8..94443c0 100644
---- a/makedefs
-+++ b/makedefs
-@@ -341,20 +341,20 @@ EOF
- 		esac
- 		;;
-     Linux.3*)	SYSTYPE=LINUX3
--		if [ -f /usr/include/db.h ]
--		then
--		    : we are all set
--		elif [ -f /usr/include/db/db.h ]
--		then
--		    CCARGS="$CCARGS -I/usr/include/db"
--		else
--		    # On a properly installed system, Postfix builds
--		    # by including <db.h> and by linking with -ldb
--		    echo "No <db.h> include file found." 1>&2
--		    echo "Install the appropriate db*-devel package first." 1>&2
--		    echo "See the RELEASE_NOTES file for more information." 1>&2
--		    exit 1
--		fi
-+		#if [ -f /usr/include/db.h ]
-+		#then
-+		    #: we are all set
-+		#elif [ -f /usr/include/db/db.h ]
-+		#then
-+		    #CCARGS="$CCARGS -I/usr/include/db"
-+		#else
-+		    ## On a properly installed system, Postfix builds
-+		    ## by including <db.h> and by linking with -ldb
-+		    #echo "No <db.h> include file found." 1>&2
-+		    #echo "Install the appropriate db*-devel package first." 1>&2
-+		    #echo "See the RELEASE_NOTES file for more information." 1>&2
-+		    #exit 1
-+		#fi
- 		SYSLIBS="-ldb"
- 		for name in nsl resolv
- 		do
diff --git a/pkgs/servers/mail/postfix/default.nix b/pkgs/servers/mail/postfix/default.nix
index 7bd2d6209108..41dfebab7907 100644
--- a/pkgs/servers/mail/postfix/default.nix
+++ b/pkgs/servers/mail/postfix/default.nix
@@ -1,65 +1,98 @@
-{ stdenv, fetchurl, db, glibc, openssl, cyrus_sasl
-, coreutils, findutils, gnused, gnugrep, bison, perl
+{ stdenv, lib, fetchurl, makeWrapper, gnused, db, openssl, cyrus_sasl, libnsl
+, coreutils, findutils, gnugrep, gawk, icu, pcre
+, withPgSQL ? false, postgresql
+, withMySQL ? false, mysql
+, withSQLite ? false, sqlite
+, withLDAP ? false, openldap
 }:
 
-assert stdenv.isLinux;
+let
+  ccargs = lib.concatStringsSep " " ([
+    "-DUSE_TLS" "-DUSE_SASL_AUTH" "-DUSE_CYRUS_SASL" "-I${cyrus_sasl.dev}/include/sasl"
+    "-DHAS_DB_BYPASS_MAKEDEFS_CHECK"
+   ] ++ lib.optional withPgSQL "-DHAS_PGSQL"
+     ++ lib.optionals withMySQL [ "-DHAS_MYSQL" "-I${mysql.connector-c}/include/mysql" "-L${mysql.connector-c}/lib/mysql" ]
+     ++ lib.optional withSQLite "-DHAS_SQLITE"
+     ++ lib.optional withLDAP "-DHAS_LDAP");
+   auxlibs = lib.concatStringsSep " " ([
+     "-ldb" "-lnsl" "-lresolv" "-lsasl2" "-lcrypto" "-lssl"
+   ] ++ lib.optional withPgSQL "-lpq"
+     ++ lib.optional withMySQL "-lmysqlclient"
+     ++ lib.optional withSQLite "-lsqlite3"
+     ++ lib.optional withLDAP "-lldap");
 
-stdenv.mkDerivation rec {
-  name = "postfix-2.8.12";
+in stdenv.mkDerivation rec {
+
+  name = "postfix-${version}";
+
+  version = "3.3.1";
 
   src = fetchurl {
     url = "ftp://ftp.cs.uu.nl/mirror/postfix/postfix-release/official/${name}.tar.gz";
-    sha256 = "11z07mjy53l1fnl7k4101yk4ilibgqr1164628mqcbmmr8bh2szl";
+    sha256 = "0fvymsklp32njsv0ngc1f45j01kcy61r5in99g5palibwkd19xal";
   };
 
-  buildInputs = [db openssl cyrus_sasl bison perl];
+  nativeBuildInputs = [ makeWrapper ];
+  buildInputs = [ db openssl cyrus_sasl icu libnsl pcre ]
+                ++ lib.optional withPgSQL postgresql
+                ++ lib.optional withMySQL mysql.connector-c
+                ++ lib.optional withSQLite sqlite
+                ++ lib.optional withLDAP openldap;
 
-  patches = [ ./postfix-2.2.9-db.patch  ./postfix-2.2.9-lib.patch ./db-linux3.patch ];
+  hardeningDisable = [ "format" ];
+  hardeningEnable = [ "pie" ];
 
-  postPatch = ''
-    sed -i -e s,/usr/bin,/var/run/current-system/sw/bin, \
-      -e s,/usr/sbin,/var/run/current-system/sw/bin, \
-      -e s,:/sbin,, src/util/sys_defs.h
-  '';
+  patches = [
+    ./postfix-script-shell.patch
+    ./postfix-3.0-no-warnings.patch
+    ./post-install-script.patch
+    ./relative-symlinks.patch
+  ];
 
   preBuild = ''
-    export daemon_directory=$out/libexec/postfix
+    sed -e '/^PATH=/d' -i postfix-install
+    sed -e "s|@PACKAGE@|$out|" -i conf/post-install
+
+    # post-install need skip permissions check/set on all symlinks following to /nix/store
+    sed -e "s|@NIX_STORE@|$NIX_STORE|" -i conf/post-install
+
     export command_directory=$out/sbin
-    export queue_directory=/var/spool/postfix
-    export sendmail_path=$out/bin/sendmail
-    export mailq_path=$out/bin/mailq
-    export newaliases_path=$out/bin/newaliases
+    export config_directory=/etc/postfix
+    export meta_directory=$out/etc/postfix
+    export daemon_directory=$out/libexec/postfix
+    export data_directory=/var/lib/postfix/data
     export html_directory=$out/share/postfix/doc/html
+    export mailq_path=$out/bin/mailq
     export manpage_directory=$out/share/man
-    export sample_directory=$out/share/postfix/doc/samples
+    export newaliases_path=$out/bin/newaliases
+    export queue_directory=/var/lib/postfix/queue
     export readme_directory=$out/share/postfix/doc
+    export sendmail_path=$out/bin/sendmail
 
-    make makefiles CCARGS='-DUSE_TLS -DUSE_SASL_AUTH -DUSE_CYRUS_SASL -I${cyrus_sasl}/include/sasl -fPIE -fstack-protector-all --param ssp-buffer-size=4 -O2 -D_FORTIFY_SOURCE=2' AUXLIBS='-lssl -lcrypto -lsasl2 -ldb -lnsl -pie -Wl,-z,relro,-z,now'
+    make makefiles CCARGS='${ccargs}' AUXLIBS='${auxlibs}'
   '';
 
-  installPhase = ''
-    sed -e '/^PATH=/d' -i postfix-install
-    $SHELL postfix-install install_root=out -non-interactive -package
-
-    mkdir -p $out
-    mv -v "out$out/"* $out/
+  installTargets = [ "non-interactive-package" ];
 
-    mkdir -p $out/share/postfix
-    mv conf $out/share/postfix/
-    mv LICENSE TLS_LICENSE $out/share/postfix/
+  installFlags = [ "install_root=installdir" ];
 
-    sed -e 's@^PATH=.*@PATH=${coreutils}/bin:${findutils}/bin:${gnused}/bin:${gnugrep}/bin:'$out'/sbin@' -i $out/share/postfix/conf/post-install $out/libexec/postfix/post-install
-    sed -e '2aPATH=${coreutils}/bin:${findutils}/bin:${gnused}/bin:${gnugrep}/bin:'$out'/sbin' -i $out/share/postfix/conf/postfix-script $out/libexec/postfix/postfix-script
-    chmod a+x $out/share/postfix/conf/{postfix-script,post-install}
+  postInstall = ''
+    mkdir -p $out
+    mv -v installdir/$out/* $out/
+    cp -rv installdir/etc $out
+    sed -e '/^PATH=/d' -i $out/libexec/postfix/post-install
+    wrapProgram $out/libexec/postfix/post-install \
+      --prefix PATH ":" ${lib.makeBinPath [ coreutils findutils gnugrep ]}
+    wrapProgram $out/libexec/postfix/postfix-script \
+      --prefix PATH ":" ${lib.makeBinPath [ coreutils findutils gnugrep gawk gnused ]}
   '';
 
-  inherit glibc;
-
   meta = {
-    homepage = "http://www.postfix.org/";
-    description = "a fast, easy to administer, and secure mail server";
-    license = stdenv.lib.licenses.bsdOriginal;
-    platforms = stdenv.lib.platforms.linux;
-    maintainers = [ stdenv.lib.maintainers.simons ];
+    homepage = http://www.postfix.org/;
+    description = "A fast, easy to administer, and secure mail server";
+    license = with lib.licenses; [ ipl10 epl20 ];
+    platforms = lib.platforms.linux;
+    maintainers = [ lib.maintainers.rickynils ];
   };
+
 }
diff --git a/pkgs/servers/mail/postfix/pfixtools.nix b/pkgs/servers/mail/postfix/pfixtools.nix
new file mode 100644
index 000000000000..8c00bcdbee25
--- /dev/null
+++ b/pkgs/servers/mail/postfix/pfixtools.nix
@@ -0,0 +1,55 @@
+{ stdenv, lib, fetchFromGitHub, git, gperf, pcre, unbound, libev, tokyocabinet, pkgconfig, bash, libsrs2 }:
+
+let
+  version = "0.9";
+
+  pfixtoolsSrc = fetchFromGitHub {
+    owner = "Fruneau";
+    repo = "pfixtools";
+    rev = "pfixtools-${version}";
+    sha256 = "1vmbrw686f41n6xfjphfshn96vl07ynvnsyjdw9yfn9bfnldcjcq";
+  };
+
+  srcRoot = pfixtoolsSrc.name;
+
+  libCommonSrc = fetchFromGitHub {
+    owner = "Fruneau";
+    repo = "libcommon";
+    rev = "b07e6bdea3d24748e0d39783d7d817096d10cc67";
+    sha256 = "14fxldp29j4vmfmhfgwwi37pj8cz0flm1aykkxlbgakz92d4pm35";
+  };
+
+in
+
+stdenv.mkDerivation {
+  name = "pfixtools-${version}";
+
+  src = pfixtoolsSrc;
+
+  patches = [ ./0001-Fix-build-with-unbound-1.6.1.patch ];
+
+  nativeBuildInputs = [ pkgconfig ];
+  buildInputs = [git gperf pcre unbound libev tokyocabinet bash libsrs2];
+
+  postUnpack = ''
+    cp -Rp ${libCommonSrc}/* ${srcRoot}/common;
+    chmod -R +w ${srcRoot}/common;
+  '';
+
+  postPatch = ''
+    substituteInPlace postlicyd/policy_tokens.sh \
+                      --replace /bin/bash ${bash}/bin/bash;
+  '';
+
+  NIX_CFLAGS_COMPILE = "-Wno-error=unused-result -Wno-error=nonnull-compare";
+
+  makeFlags = "DESTDIR=$(out) prefix=";
+
+  meta = {
+    description = "A collection of postfix-related tools";
+    license = with lib.licenses; [ bsd3 ];
+    homepage = https://github.com/Fruneau/pfixtools;
+    platforms = stdenv.lib.platforms.linux;
+    maintainers = with lib.maintainers; [ jerith666 ];
+  };
+}
diff --git a/pkgs/servers/mail/postfix/pflogsumm.nix b/pkgs/servers/mail/postfix/pflogsumm.nix
new file mode 100644
index 000000000000..a9ec36f59ca9
--- /dev/null
+++ b/pkgs/servers/mail/postfix/pflogsumm.nix
@@ -0,0 +1,35 @@
+{ stdenv, fetchurl, buildPerlPackage, perlPackages
+}:
+
+buildPerlPackage rec {
+  name = "pflogsumm-${version}";
+  version = "1.1.3";
+
+  src = fetchurl {
+    url = "http://jimsun.linxnet.com/downloads/${name}.tar.gz";
+    sha256 = "0hkim9s5f1yg5sfs5048jydhy3sbxafls496wcjk0cggxb113py4";
+  };
+
+  outputs = [ "out" "man" ];
+  buildInputs = [ perlPackages.DateCalc ];
+
+  preConfigure = ''
+    touch Makefile.PL
+  '';
+  doCheck = false;
+
+  installPhase = ''
+    mkdir -p "$out/bin"
+    mv "pflogsumm.pl" "$out/bin/pflogsumm"
+
+    mkdir -p "$out/share/man/man1"
+    mv "pflogsumm.1" "$out/share/man/man1"
+  '';
+
+  meta = {
+    homepage = http://jimsun.linxnet.com/postfix_contrib.html;
+    maintainers = with stdenv.lib.maintainers; [ schneefux ];
+    description = "Postfix activity overview";
+    license = stdenv.lib.licenses.gpl2Plus;
+  };
+}
diff --git a/pkgs/servers/mail/postfix/post-install-script.patch b/pkgs/servers/mail/postfix/post-install-script.patch
new file mode 100644
index 000000000000..350fbf929b74
--- /dev/null
+++ b/pkgs/servers/mail/postfix/post-install-script.patch
@@ -0,0 +1,28 @@
+--- a/conf/post-install	1970-01-01 03:00:01.000000000 +0300
++++ b/conf/post-install	2016-01-20 13:25:18.382233172 +0200
+@@ -254,6 +254,8 @@
+ }
+ 
+ # Bootstrapping problem.
++meta_directory="@PACKAGE@/etc/postfix"
++command_directory="@PACKAGE@/bin"
+ 
+ if [ -n "$command_directory" ]
+ then
+@@ -528,7 +530,16 @@
+ 	    # Skip uninstalled files.
+ 	    case $path in
+ 	    no|no/*) continue;;
++        # Skip immutable files from package, correct permissions provided by Nix.
++        @PACKAGE@/*) continue;
+ 	    esac
++        # Also skip symlinks following to /nix/store
++        if test -L $path; then
++            case "$(readlink $path)" in
++                @NIX_STORE@/*) continue;
++            esac
++        fi
++
+ 	    # Pick up the flags.
+ 	    case $flags in *u*) upgrade_flag=1;; *) upgrade_flag=;; esac
+ 	    case $flags in *c*) create_flag=1;; *) create_flag=;; esac
diff --git a/pkgs/servers/mail/postfix/postfix-2.11.0.patch b/pkgs/servers/mail/postfix/postfix-2.11.0.patch
deleted file mode 100644
index cdc4521c428a..000000000000
--- a/pkgs/servers/mail/postfix/postfix-2.11.0.patch
+++ /dev/null
@@ -1,76 +0,0 @@
-diff -ruN postfix-2.11.0-orig/makedefs postfix-2.11.0/makedefs
---- postfix-2.11.0-orig/makedefs	2014-01-05 18:18:56.000000000 +0100
-+++ postfix-2.11.0/makedefs	2014-04-24 09:27:58.193869491 +0200
-@@ -290,36 +290,6 @@
- 		esac
- 		;;
-     Linux.2*)	SYSTYPE=LINUX2
--		case "$CCARGS" in
--		 *-DNO_DB*) ;;
--		 *-DHAS_DB*) ;;
--		 *) if [ -f /usr/include/db.h ]
--		    then
--			: we are all set
--		    elif [ -f /usr/include/db/db.h ]
--		    then
--			CCARGS="$CCARGS -I/usr/include/db"
--		    else
--			# No, we're not going to try db1 db2 db3 etc.
--			# On a properly installed system, Postfix builds
--			# by including <db.h> and by linking with -ldb
--			echo "No <db.h> include file found." 1>&2
--			echo "Install the appropriate db*-devel package first." 1>&2
--			exit 1
--		    fi
--		    SYSLIBS="-ldb"
--		    ;;
--		esac
--		for name in nsl resolv $GDBM_LIBS
--		do
--		    for lib in /usr/lib64 /lib64 /usr/lib /lib
--		    do
--			test -e $lib/lib$name.a -o -e $lib/lib$name.so && {
--			    SYSLIBS="$SYSLIBS -l$name"
--			    break
--			}
--		    done
--		done
- 		# Kernel 2.4 added IPv6
- 		case "$RELEASE" in
- 		2.[0-3].*) CCARGS="$CCARGS -DNO_IPV6";;
-@@ -363,35 +333,6 @@
- 		esac
- 		;;
-     Linux.3*)	SYSTYPE=LINUX3
--		case "$CCARGS" in
--		 *-DNO_DB*) ;;
--		 *-DHAS_DB*) ;;
--		 *) if [ -f /usr/include/db.h ]
--		    then
--			: we are all set
--		    elif [ -f /usr/include/db/db.h ]
--		    then
--			CCARGS="$CCARGS -I/usr/include/db"
--		    else
--			# On a properly installed system, Postfix builds
--			# by including <db.h> and by linking with -ldb
--			echo "No <db.h> include file found." 1>&2
--			echo "Install the appropriate db*-devel package first." 1>&2
--			exit 1
--		    fi
--		    SYSLIBS="-ldb"
--		    ;;
--		esac
--		for name in nsl resolv
--		do
--		    for lib in /usr/lib64 /lib64 /usr/lib /usr/lib/* /lib /lib/*
--		    do
--			test -e $lib/lib$name.a -o -e $lib/lib$name.so && {
--			    SYSLIBS="$SYSLIBS -l$name"
--			    break
--			}
--		    done
--		done
- 		;;
-      GNU.0*|GNU/kFreeBSD.[567]*)
- 		SYSTYPE=GNU0
diff --git a/pkgs/servers/mail/postfix/postfix-2.2.9-db.patch b/pkgs/servers/mail/postfix/postfix-2.2.9-db.patch
deleted file mode 100644
index 65f55ffd8f05..000000000000
--- a/pkgs/servers/mail/postfix/postfix-2.2.9-db.patch
+++ /dev/null
@@ -1,40 +0,0 @@
-diff -ruN postfix-2.2.9/makedefs postfix-2.2.9.new/makedefs
---- postfix-2.2.9/makedefs	2006-01-03 21:50:25.000000000 +0000
-+++ postfix-2.2.9.new/makedefs	2006-03-11 00:38:30.000000000 +0000
-@@ -219,21 +219,21 @@
- 		;;
-     Linux.2*)	SYSTYPE=LINUX2
- 		# Postfix no longer needs DB 1.85 compatibility
--		if [ -f /usr/include/db.h ]
--		then
--		    : we are all set
--		elif [ -f /usr/include/db/db.h ]
--		then
--		    CCARGS="$CCARGS -I/usr/include/db"
--		else
--		    # No, we're not going to try db1 db2 db3 etc.
--		    # On a properly installed system, Postfix builds
--		    # by including <db.h> and by linking with -ldb
--		    echo "No <db.h> include file found." 1>&2
--		    echo "Install the appropriate db*-devel package first." 1>&2
--		    echo "See the RELEASE_NOTES file for more information." 1>&2
--		    exit 1
--		fi
-+		#if [ -f /usr/include/db.h ]
-+		#then
-+		    #: we are all set
-+		#elif [ -f /usr/include/db/db.h ]
-+		#then
-+		    #CCARGS="$CCARGS -I/usr/include/db"
-+		#else
-+		    ## No, we're not going to try db1 db2 db3 etc.
-+		    ## On a properly installed system, Postfix builds
-+		    ## by including <db.h> and by linking with -ldb
-+		    #echo "No <db.h> include file found." 1>&2
-+		    #echo "Install the appropriate db*-devel package first." 1>&2
-+		    #echo "See the RELEASE_NOTES file for more information." 1>&2
-+		    #exit 1
-+		#fi
- 		# GDBM locks the DBM .pag file after open. This breaks postmap.
- 		# if [ -f /usr/include/gdbm-ndbm.h ]
- 		# then
diff --git a/pkgs/servers/mail/postfix/postfix-2.2.9-lib.patch b/pkgs/servers/mail/postfix/postfix-2.2.9-lib.patch
deleted file mode 100644
index 03dcaa87f238..000000000000
--- a/pkgs/servers/mail/postfix/postfix-2.2.9-lib.patch
+++ /dev/null
@@ -1,12 +0,0 @@
-diff -ruN postfix-2.2.9/makedefs postfix-2.2.9.new/makedefs
---- postfix-2.2.9/makedefs	2006-01-03 21:50:25.000000000 +0000
-+++ postfix-2.2.9.new/makedefs	2006-03-11 01:40:30.000000000 +0000
-@@ -247,7 +247,7 @@
- 		SYSLIBS="-ldb"
- 		for name in nsl resolv $GDBM_LIBS
- 		do
--		    for lib in /usr/lib64 /lib64 /usr/lib /lib
-+		    for lib in $glibc/usr/lib64 $glibc/lib64 $glibc/usr/lib $glibc/lib
- 		    do
- 			test -e $lib/lib$name.a -o -e $lib/lib$name.so && {
- 			    SYSLIBS="$SYSLIBS -l$name"
diff --git a/pkgs/servers/mail/postfix/postfix-3.0-no-warnings.patch b/pkgs/servers/mail/postfix/postfix-3.0-no-warnings.patch
new file mode 100644
index 000000000000..d93eaf0aaa0d
--- /dev/null
+++ b/pkgs/servers/mail/postfix/postfix-3.0-no-warnings.patch
@@ -0,0 +1,86 @@
+diff -ru3 postfix-3.0.3/conf/postfix-script postfix-3.0.3-new/conf/postfix-script
+--- postfix-3.0.3/conf/postfix-script	2014-06-27 18:05:15.000000000 +0400
++++ postfix-3.0.3-new/conf/postfix-script	2016-01-09 17:51:38.545733631 +0300
+@@ -84,24 +84,6 @@
+ 	exit 1
+ }
+ 
+-# If this is a secondary instance, don't touch shared files.
+-
+-instances=`test ! -f $def_config_directory/main.cf ||
+-    $command_directory/postconf -c $def_config_directory \
+-    -h multi_instance_directories | sed 's/,/ /'` || {
+-	$FATAL cannot execute $command_directory/postconf!
+-	exit 1
+-}
+-
+-check_shared_files=1
+-for name in $instances
+-do
+-    case "$name" in
+-    "$def_config_directory") ;;
+-    "$config_directory") check_shared_files=; break;;
+-    esac
+-done
+-
+ #
+ # Parse JCL
+ #
+@@ -262,22 +244,6 @@
+ 	    -prune \( -perm -020 -o -perm -002 \) \
+ 	    -exec $WARN group or other writable: {} \;
+ 
+-	# Check Postfix root-owned directory tree owner/permissions.
+-
+-	todo="$config_directory/."
+-	test -n "$check_shared_files" && {
+-		todo="$daemon_directory/. $meta_directory/. $todo"
+-		test "$shlib_directory" = "no" || 
+-		    todo="$shlib_directory/. $todo"
+-	}
+-	todo=`echo "$todo" | tr ' ' '\12' | sort -u`
+-
+-	find $todo ! -user root \
+-	    -exec $WARN not owned by root: {} \;
+-
+-	find $todo \( -perm -020 -o -perm -002 \) \
+-	    -exec $WARN group or other writable: {} \;
+-
+ 	# Check Postfix mail_owner-owned directory tree owner/permissions.
+ 
+ 	find $data_directory/. ! -user $mail_owner \
+@@ -302,18 +268,11 @@
+ 	# Check Postfix setgid_group-owned directory and file group/permissions.
+ 
+ 	todo="$queue_directory/public $queue_directory/maildrop"
+-	test -n "$check_shared_files" && 
+-	   todo="$command_directory/postqueue $command_directory/postdrop $todo"
+ 
+ 	find $todo \
+ 	    -prune ! -group $setgid_group \
+ 	    -exec $WARN not owned by group $setgid_group: {} \;
+ 
+-	test -n "$check_shared_files" &&
+-	find $command_directory/postqueue $command_directory/postdrop \
+-	    -prune ! -perm -02111 \
+-	    -exec $WARN not set-gid or not owner+group+world executable: {} \;
+-
+ 	# Check non-Postfix root-owned directory tree owner/content.
+ 
+ 	for dir in bin etc lib sbin usr
+@@ -334,15 +293,6 @@
+ 
+ 	find corrupt -type f -exec $WARN damaged message: {} \;
+ 
+-	# Check for non-Postfix MTA remnants.
+-
+-	test -n "$check_shared_files" -a -f /usr/sbin/sendmail -a \
+-		-f /usr/lib/sendmail && {
+-	    cmp -s /usr/sbin/sendmail /usr/lib/sendmail || {
+-		$WARN /usr/lib/sendmail and /usr/sbin/sendmail differ
+-		$WARN Replace one by a symbolic link to the other
+-	    }
+-	}
+ 	exit 0
+ 	;;
+ 
diff --git a/pkgs/servers/mail/postfix/postfix-script-shell.patch b/pkgs/servers/mail/postfix/postfix-script-shell.patch
new file mode 100644
index 000000000000..4f5d2f611110
--- /dev/null
+++ b/pkgs/servers/mail/postfix/postfix-script-shell.patch
@@ -0,0 +1,21 @@
+diff --git a/conf/postfix-script b/conf/postfix-script
+index 19088a6..04fae23 100755
+--- a/conf/postfix-script
++++ b/conf/postfix-script
+@@ -43,7 +43,6 @@ FATAL="$LOGGER -p fatal"
+ PANIC="$LOGGER -p panic"
+ 
+ umask 022
+-SHELL=/bin/sh
+ 
+ #
+ # Can't do much without these in place.
+@@ -229,7 +228,7 @@ status)
+ check-fatal)
+ 	# This command is NOT part of the public interface.
+ 
+-	$SHELL $daemon_directory/post-install create-missing || {
++	$daemon_directory/post-install create-missing || {
+ 		$FATAL unable to create missing queue directories
+ 		exit 1
+ 	}
diff --git a/pkgs/servers/mail/postfix/relative-symlinks.patch b/pkgs/servers/mail/postfix/relative-symlinks.patch
new file mode 100644
index 000000000000..f7a2078c0343
--- /dev/null
+++ b/pkgs/servers/mail/postfix/relative-symlinks.patch
@@ -0,0 +1,13 @@
+diff --git a/postfix-install b/postfix/postfix-install
+index 1662c3d..0f20ec0 100644
+--- a/postfix-install
++++ b/postfix-install
+@@ -336,7 +336,7 @@ compare_or_symlink() {
+ 	# 2) we cannot use mv to replace a symlink-to-directory;
+ 	# 3) "ln -n" is not in POSIX, therefore it's not portable.
+ 	# rm+ln is less atomic but this affects compatibility symlinks only.
+-	rm -f $2 && ln -sf $link $2 || exit 1
++	rm -f $2 && ln -rsf $link $2 || exit 1
+     }
+ }
+