From 029ac18e386529a52c793b620542cd5817fcf753 Mon Sep 17 00:00:00 2001 From: Denis Shulyaka Date: Wed, 1 Oct 2014 01:08:26 +0400 Subject: [PATCH] Postfix MTA Signed-off-by: Denis Shulyaka --- mail/postfix/Makefile | 167 ++++++++++++++++++++ mail/postfix/patches/100-fsstat.patch | 12 ++ mail/postfix/patches/200-manpages.patch | 80 ++++++++++ mail/postfix/patches/300-init.patch | 23 +++ mail/postfix/patches/400-cdb.patch | 14 ++ mail/postfix/patches/500-crosscompile.patch | 27 ++++ 6 files changed, 323 insertions(+) create mode 100644 mail/postfix/Makefile create mode 100644 mail/postfix/patches/100-fsstat.patch create mode 100644 mail/postfix/patches/200-manpages.patch create mode 100644 mail/postfix/patches/300-init.patch create mode 100644 mail/postfix/patches/400-cdb.patch create mode 100644 mail/postfix/patches/500-crosscompile.patch diff --git a/mail/postfix/Makefile b/mail/postfix/Makefile new file mode 100644 index 00000000000000..034e9aedb4ed5d --- /dev/null +++ b/mail/postfix/Makefile @@ -0,0 +1,167 @@ +# +# Copyright (C) 2014 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +include $(TOPDIR)/rules.mk + +PKG_NAME:=postfix +PKG_RELEASE:=1 +PKG_SOURCE_URL:=ftp://ftp.porcupine.org/mirrors/postfix-release/official/ +PKG_VERSION:=2.11.1 +PKG_MD5SUM:=56ac1f1a79737c4ac1e24535a122a4a6 +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz +PKG_MAINTAINER:=Denis Shulyaka +PKG_LICENSE:=IPL-1.0 +PKG_LICENSE_FILE:=LICENSE + +include $(INCLUDE_DIR)/package.mk + +define Package/postfix + SECTION:=mail + CATEGORY:=Mail + TITLE:=Postfix Mail Transmit Agent + URL:=http://www.postfix.org/ + DEPENDS:=+POSTFIX_TLS:libopenssl +POSTFIX_SASL:libsasl2 +POSTFIX_LDAP:libopenldap +tinycdb +libpcre +endef + +define Package/postfix/description + Postfix is Wietse Venema's mailer that started life as an alternative to the widely-used Sendmail program. Postfix attempts to be fast, easy to administer, and secure, while at the same time being sendmail compatible enough to not upset existing users. Thus, the outside has a sendmail-ish flavor, but the inside is completely different. +endef + +define Package/postfix/config + menu "Select postfix build options" + config POSTFIX_TLS + bool "TLS support" + default y + help + Implements TLS support in postfix (using OpenSSL). + config POSTFIX_SASL + bool "SASL support" + default y + help + Implements SASL support in postfix (using Cyrus SASL). + config POSTFIX_LDAP + bool "LDAP support" + default y + help + Implements LDAP support in postfix (using OpenLDAP). + endmenu +endef + +define Package/postfix/conffiles +/etc/postfix/main.cf +/etc/postfix/aliases +endef + +CCARGS=-DHAS_CDB -DNO_DB -DNO_EPOLL -DNO_SIGSETJMP -DNO_NIS -DDEF_DB_TYPE=\"cdb\" +AUXLIBS=-L$(STAGING_DIR)/usr/lib -lcdb + +ifdef CONFIG_POSTFIX_TLS + CCARGS+=-DUSE_TLS + AUXLIBS+=-lssl -lcrypto +endif + +ifdef CONFIG_POSTFIX_SASL + CCARGS+=-DUSE_SASL_AUTH -DUSE_CYRUS_SASL -I$(STAGING_DIR)/usr/include/sasl + AUXLIBS+=-lsasl2 +endif + +ifdef CONFIG_POSTFIX_LDAP + CCARGS+=-DHAS_LDAP + AUXLIBS+=-lldap -llber +endif + +define Build/Configure + cd $(PKG_BUILD_DIR); $(MAKE) makefiles CCARGS='$(CCARGS)' $(TARGET_CONFIGURE_OPTS) prefix="$(PKG_INSTALL_DIR)/usr" AUXLIBS="$(AUXLIBS)" +endef + +define Build/Compile + # Currently postfix has a bug with Makefiles that CCARGS are not passed to the compiler, so we are copying them to CC + cd $(PKG_BUILD_DIR); $(MAKE) $(TARGET_CONFIGURE_OPTS) prefix="$(PKG_INSTALL_DIR)/usr" CC='$(TARGET_CC) $(CCARGS)' + # recompiling postconf natively because we need it executable for Package/postfix/install (could be avoided with a rewritten install method): + cp -r $(PKG_BUILD_DIR)/src/util $(PKG_BUILD_DIR)/src/util.native + cp -r $(PKG_BUILD_DIR)/src/xsasl $(PKG_BUILD_DIR)/src/xsasl.native + cp -r $(PKG_BUILD_DIR)/src/global $(PKG_BUILD_DIR)/src/global.native + cp -r $(PKG_BUILD_DIR)/src/postconf $(PKG_BUILD_DIR)/src/postconf.native + + cd $(PKG_BUILD_DIR)/src/util.native; $(MAKE) clean && $(MAKE) CC=$(HOSTCC) + cd $(PKG_BUILD_DIR)/src/xsasl.native; $(MAKE) clean && $(MAKE) CC=$(HOSTCC) + cd $(PKG_BUILD_DIR)/src/global.native; $(MAKE) clean && $(MAKE) CC=$(HOSTCC) + cd $(PKG_BUILD_DIR)/src/postconf.native; $(HOSTCC) $(CCARGS) -g -O -I. -I../../include -DLINUX2 -c *.c && $(HOSTCC) -o postconf *.o ../xsasl.native/libxsasl.a ../global.native/libglobal.a ../util.native/libutil.a -lnsl -lresolv + mv $(PKG_BUILD_DIR)/bin/postconf $(PKG_BUILD_DIR)/bin/postconf.target + cp $(PKG_BUILD_DIR)/src/postconf.native/postconf $(PKG_BUILD_DIR)/bin/postconf + rm -rf $(PKG_BUILD_DIR)/src/util.native $(PKG_BUILD_DIR)/src/xsasl.native $(PKG_BUILD_DIR)/src/global.native $(PKG_BUILD_DIR)/src/postconf.native + # fixing main.cf.default that was broken due to postconf (also need to check why postconf -d returns the build system's domain and hostname): + (echo "# DO NOT EDIT THIS FILE. EDIT THE MAIN.CF FILE INSTEAD. THE"; \ + echo "# TEXT HERE JUST SHOWS DEFAULT SETTINGS BUILT INTO POSTFIX."; \ + echo "#"; \ + $(PKG_BUILD_DIR)/bin/postconf -d) |egrep -v '^(myhostname|mydomain|mynetworks) ' > $(PKG_BUILD_DIR)/conf/main.cf.default +endef + +define Package/postfix/install + cd $(PKG_BUILD_DIR); $(MAKE) install_root=$(1) readme_directory=no html_directory=no manpage_directory=no queue_directory=/usr/var/spool/postfix data_directory=/usr/var/lib/postfix non-interactive-package + # Removing those useless man pages: + $(RM) -r $(1)/usr/local/man + # restoring target postconf: + $(INSTALL_BIN) $(PKG_BUILD_DIR)/bin/postconf.target $(1)/usr/sbin/postconf + # fixing configuration (we don't want mail directory to be on tmpfs): + $(PKG_BUILD_DIR)/bin/postconf -c $(1)/etc/postfix/ -e \ + "data_directory = /usr/var/lib/postfix" \ + "mail_spool_directory = /usr/var/mail" + $(INSTALL_DIR) $(1)/usr/var/lib/postfix + $(INSTALL_DIR) $(1)/usr/var/mail + $(INSTALL_DIR) $(1)/etc/init.d/ + $(INSTALL_BIN) $(PKG_BUILD_DIR)/postfix_init $(1)/etc/init.d/postfix +endef + +define Package/postfix/postinst +#!/bin/sh +# check if we are on real system +if [ -z "$${IPKG_INSTROOT}" ]; then + + echo "Enabling postfix..." + /etc/init.d/postfix enable + postfix set-permissions + postfix upgrade-configuration + newaliases + if [ `ps | grep "postfix/master" | grep -cv grep` -gt 0 ] + then + postfix reload + fi + if [ `grep -c aliases /etc/sysupgrade.conf` -eq 0 ] + then + echo "/etc/postfix/main.cf" >> /etc/sysupgrade.conf + echo "/etc/postfix/aliases" >> /etc/sysupgrade.conf + fi + +fi +endef + +define Package/postfix/prerm +#!/bin/sh +# check if we are on real system +if [ -z "$${IPKG_INSTROOT}" ]; then + + if [ `ps | grep "postfix/master" | grep -cv grep` -gt 0 ] + then + postfix stop + fi + + echo "Disabling postfix..." + /etc/init.d/postfix disable + +fi +endef + +define Package/postfix/postrm +#!/bin/sh +# check if we are on real system +if [ -z "$${IPKG_INSTROOT}" ]; then + rm -f /etc/postfix/aliases.cdb # /usr/var/lib/postfix/master.lock +fi +endef + +$(eval $(call BuildPackage,postfix)) diff --git a/mail/postfix/patches/100-fsstat.patch b/mail/postfix/patches/100-fsstat.patch new file mode 100644 index 00000000000000..c91acca7a3efc6 --- /dev/null +++ b/mail/postfix/patches/100-fsstat.patch @@ -0,0 +1,12 @@ +diff -rupN postfix-2.8.1/src/smtpd/smtpd_check.c postfix-2.8.1_patched/src/smtpd/smtpd_check.c +--- postfix-2.8.1/src/smtpd/smtpd_check.c 2011-01-04 22:03:50.000000000 +0300 ++++ postfix-2.8.1_patched/src/smtpd/smtpd_check.c 2011-03-06 19:35:39.000000000 +0300 +@@ -4894,7 +4894,7 @@ char *smtpd_check_queue(SMTPD_STATE *s + */ + #define BLOCKS(x) ((x) / fsbuf.block_size) + +- fsspace(".", &fsbuf); ++ fsspace("/overlay", &fsbuf); + if (msg_verbose) + msg_info("%s: blocks %lu avail %lu min_free %lu msg_size_limit %lu", + myname, diff --git a/mail/postfix/patches/200-manpages.patch b/mail/postfix/patches/200-manpages.patch new file mode 100644 index 00000000000000..948376c519e8e4 --- /dev/null +++ b/mail/postfix/patches/200-manpages.patch @@ -0,0 +1,80 @@ +diff -Naur postfix-2.10.2/conf/post-install postfix-2.10.2_patched/conf/post-install +--- postfix-2.10.2/conf/post-install 2013-06-13 18:07:46.000000000 +0400 ++++ postfix-2.10.2_patched/conf/post-install 2013-11-19 21:17:49.572820573 +0400 +@@ -350,10 +350,10 @@ + + # Sanity checks + +-case $manpage_directory in +- no) echo $0: Error: manpage_directory no longer accepts \"no\" values. 1>&2 +- echo Try again with \"$0 manpage_directory=/pathname ...\". 1>&2; exit 1;; +-esac ++#case $manpage_directory in ++# no) echo $0: Error: manpage_directory no longer accepts \"no\" values. 1>&2 ++# echo Try again with \"$0 manpage_directory=/pathname ...\". 1>&2; exit 1;; ++#esac + + case $setgid_group in + no) echo $0: Error: setgid_group no longer accepts \"no\" values. 1>&2 +@@ -361,7 +361,7 @@ + esac + + for path in "$daemon_directory" "$command_directory" "$queue_directory" \ +- "$sendmail_path" "$newaliases_path" "$mailq_path" "$manpage_directory" ++ "$sendmail_path" "$newaliases_path" "$mailq_path" + do + case "$path" in + /*) ;; +@@ -369,7 +369,7 @@ + esac + done + +-for path in "$html_directory" "$readme_directory" ++for path in "$html_directory" "$readme_directory" "$manpage_directory" + do + case "$path" in + /*) ;; +diff -Naur postfix-2.10.2/postfix-install postfix-2.10.2_patched/postfix-install +--- postfix-2.10.2/postfix-install 2012-05-22 23:40:29.000000000 +0400 ++++ postfix-2.10.2_patched/postfix-install 2013-11-19 21:12:20.694160734 +0400 +@@ -481,13 +481,13 @@ + exit 1;; + esac + +-case "$manpage_directory" in +- no) (echo $0: Error: the manpage_directory parameter no longer accepts +- echo \"no\" values. Try again with \"manpage_directory=/path/name\" +- echo on the command line or execute \"make install\" and specify +- echo manpage_directory interactively.) | ${FMT} 1>&2 +- exit 1;; +-esac ++#case "$manpage_directory" in ++# no) (echo $0: Error: the manpage_directory parameter no longer accepts ++# echo \"no\" values. Try again with \"manpage_directory=/path/name\" ++# echo on the command line or execute \"make install\" and specify ++# echo manpage_directory interactively.) | ${FMT} 1>&2 ++# exit 1;; ++#esac + + for path in "$html_directory" "$readme_directory" + do +@@ -500,7 +500,7 @@ + done + + for path in "$daemon_directory" "$data_directory" "$command_directory" "$queue_directory" \ +- "$sendmail_path" "$newaliases_path" "$mailq_path" "$manpage_directory" ++ "$sendmail_path" "$newaliases_path" "$mailq_path" + do + case "$path" in + /*) ;; +@@ -680,8 +680,8 @@ + compare_or_replace $mode "$owner" "$group" html/$file \ + $HTML_DIRECTORY/$file || exit 1;; + '$manpage_directory') +- check_parent $MANPAGE_DIRECTORY/$file || exit 1 +- compare_or_replace $mode "$owner" "$group" man/$file \ ++ test "$manpage_directory" = "no" || check_parent $MANPAGE_DIRECTORY/$file || exit 1 ++ test "$manpage_directory" = "no" || compare_or_replace $mode "$owner" "$group" man/$file \ + $MANPAGE_DIRECTORY/$file || exit 1;; + '$readme_directory') + test "$readme_directory" = "no" || diff --git a/mail/postfix/patches/300-init.patch b/mail/postfix/patches/300-init.patch new file mode 100644 index 00000000000000..f564d0a1fd7185 --- /dev/null +++ b/mail/postfix/patches/300-init.patch @@ -0,0 +1,23 @@ +diff -rupN postfix-2.8.1/postfix_init postfix-2.8.1_patched/postfix_init +--- postfix-2.8.1/postfix_init 1970-01-01 03:00:00.000000000 +0300 ++++ postfix-2.8.1_patched/postfix_init 2011-03-06 21:44:50.000000000 +0300 +@@ -0,0 +1,19 @@ ++#!/bin/sh /etc/rc.common ++# Copyright (C) 2014 OpenWrt.org ++ ++START=50 ++STOP=50 ++ ++enable() { ++ group_exists postfix || group_add postfix ++ group_exists postdrop || group_add postdrop ++ user_exists postfix || user_add postfix ++} ++ ++start() { ++ postfix start ++} ++ ++stop() { ++ postfix stop ++} diff --git a/mail/postfix/patches/400-cdb.patch b/mail/postfix/patches/400-cdb.patch new file mode 100644 index 00000000000000..cc04cd17e8b346 --- /dev/null +++ b/mail/postfix/patches/400-cdb.patch @@ -0,0 +1,14 @@ +diff -Naur postfix-2.11.1/src/util/sys_defs.h postfix-2.11.1.patched/src/util/sys_defs.h +--- postfix-2.11.1/src/util/sys_defs.h 2013-09-30 00:51:55.000000000 +0400 ++++ postfix-2.11.1.patched/src/util/sys_defs.h 2014-09-29 03:11:48.962277971 +0400 +@@ -767,9 +767,8 @@ + #define INTERNAL_LOCK MYFLOCK_STYLE_FLOCK + #define DEF_MAILBOX_LOCK "fcntl, dotlock" /* RedHat >= 4.x */ + #define HAS_FSYNC +-#define HAS_DB + #define NATIVE_DB_TYPE "hash" +-#define ALIAS_DB_MAP DEF_DB_TYPE ":/etc/aliases" ++#define ALIAS_DB_MAP DEF_DB_TYPE ":/etc/postfix/aliases" + #ifndef NO_NIS + #define HAS_NIS + #endif diff --git a/mail/postfix/patches/500-crosscompile.patch b/mail/postfix/patches/500-crosscompile.patch new file mode 100644 index 00000000000000..abd3f7d98c5665 --- /dev/null +++ b/mail/postfix/patches/500-crosscompile.patch @@ -0,0 +1,27 @@ +--- postfix-2.10.2/makedefs 2013-02-04 05:33:13.000000000 +0400 ++++ postfix-2.10.2_patched/makedefs 2013-11-19 22:48:50.528560454 +0400 +@@ -107,9 +107,9 @@ + + case $# in + # Officially supported usage. +- 0) SYSTEM=`(uname -s) 2>/dev/null` +- RELEASE=`(uname -r) 2>/dev/null` +- VERSION=`(uname -v) 2>/dev/null` ++ 0) SYSTEM="Linux" ++ RELEASE="3.10.18" ++ VERSION="OpenWRT" + case "$VERSION" in + dcosx*) SYSTEM=$VERSION;; + esac;; +@@ -384,9 +384,9 @@ + esac + for name in nsl resolv + do +- for lib in /usr/lib64 /lib64 /usr/lib /usr/lib/* /lib /lib/* ++ for lib in /usr/lib64 /usr/lib64/* /usr/lib /usr/lib/* /lib /lib/* + do +- test -e $lib/lib$name.a -o -e $lib/lib$name.so && { ++ test -e $PKG_BUILD_DIR/$lib/lib$name.a -o -e $PKG_BUILD_DIR/$lib/lib$name.so && { + SYSLIBS="$SYSLIBS -l$name" + break + }