ASR_BASE
Change-Id: Icf3719cc0afe3eeb3edc7fa80a2eb5199ca9dda1
diff --git a/external/subpack/mail/postfix/Makefile b/external/subpack/mail/postfix/Makefile
new file mode 100644
index 0000000..106c18a
--- /dev/null
+++ b/external/subpack/mail/postfix/Makefile
@@ -0,0 +1,279 @@
+#
+# Copyright (C) 2014-2015 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_VERSION:=3.5.8
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:= \
+ https://de.postfix.org/ftpmirror/official/ \
+ http://ftp.porcupine.org/mirrors/postfix-release/official/
+PKG_HASH:=22582628cf3edc18c5155c9ff44543dd95a9435fb68135d76a99f572cb07456f
+
+PKG_MAINTAINER:=Denis Shulyaka <Shulyaka@gmail.com>
+PKG_LICENSE:=IPL-1.0
+PKG_LICENSE_FILES:=LICENSE
+PKG_CPE_ID:=cpe:/a:postfix:postfix
+
+PKG_CONFIG_DEPENDS:= \
+ CONFIG_POSTFIX_TLS \
+ CONFIG_POSTFIX_SASL \
+ CONFIG_POSTFIX_LDAP \
+ CONFIG_POSTFIX_CDB \
+ CONFIG_POSTFIX_DB \
+ CONFIG_POSTFIX_SQLITE \
+ CONFIG_POSTFIX_MYSQL \
+ CONFIG_POSTFIX_PGSQL \
+ CONFIG_POSTFIX_PCRE \
+ CONFIG_POSTFIX_EAI \
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/postfix
+ SECTION:=mail
+ CATEGORY:=Mail
+ TITLE:=Postfix Mail Transmit Agent
+ USERID:= \
+ postfix=25:postfix=25 \
+ postdrop=26:postdrop=26
+ URL:=http://www.postfix.org/
+ DEPENDS:=+POSTFIX_CDB:tinycdb +POSTFIX_TLS:libopenssl +POSTFIX_SASL:libsasl2 +POSTFIX_LDAP:libopenldap +POSTFIX_DB:libdb47 +POSTFIX_SQLITE:libsqlite3 +POSTFIX_MYSQL:libmysqlclient +POSTFIX_PGSQL:libpq +POSTFIX_EAI:icu +POSTFIX_PCRE: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).
+ config POSTFIX_DB
+ bool "BerkeleyDB support"
+ default n
+ help
+ Implements support for btree and hash files using Berkeley DB.
+ config POSTFIX_CDB
+ bool "CDB support"
+ default y
+ help
+ Implements support for cdb files using tinycdb
+ config POSTFIX_SQLITE
+ bool "SQLITE support"
+ default y
+ help
+ Implements support for SQLite3 DB
+ config POSTFIX_MYSQL
+ bool "MYSQL support"
+ default n
+ help
+ Implements support for MySQL
+ config POSTFIX_PGSQL
+ bool "PostgreSQL support"
+ default n
+ help
+ Implement support for PostgreSQL
+ config POSTFIX_PCRE
+ bool "PCRE support"
+ default y
+ help
+ Implement support for Perl Compatible Regular Expressions
+ config POSTFIX_EAI
+ bool "SMTPUTF8 support"
+ default n
+ help
+ Enable Postfix support for Email Address Internationalization
+ (EAI) as defined in RFC 6531 (SMTPUTF8 extension), RFC 6532
+ (Internationalized email headers) and RFC 6533
+ (Internationalized delivery status notifications).
+ Since version 3.0, Postfix fully supports UTF-8 email
+ addresses and UTF-8 message header values.
+ endmenu
+endef
+
+CCARGS=-DNO_NIS -fcommon
+AUXLIBS=-L$(STAGING_DIR)/usr/lib
+
+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
+
+ifdef CONFIG_POSTFIX_CDB
+ CCARGS+=-DHAS_CDB
+ AUXLIBS+=-lcdb
+ ifndef default_database_type
+ default_database_type=cdb
+ endif
+endif
+
+ifdef CONFIG_POSTFIX_DB
+ AUXLIBS+=-ldb
+ CCARGS+=-DHAS_DB
+ ifndef default_database_type
+ default_database_type=btree
+ endif
+else
+ CCARGS+=-DNO_DB
+endif
+
+ifdef CONFIG_POSTFIX_SQLITE
+ CCARGS+=-DHAS_SQLITE -I$(STAGING_DIR)/usr/include/
+ AUXLIBS+=-L$(STAGING_DIR)/usr/lib -lsqlite3 -lpthread
+endif
+
+ifdef CONFIG_POSTFIX_MYSQL
+ CCARGS+=-DHAS_MYSQL -I$(STAGING_DIR)/usr/include/mysql
+ AUXLIBS+=-L$(STAGING_DIR)/usr/lib -lmysqlclient -lz -lm
+endif
+
+ifdef CONFIG_POSTFIX_PGSQL
+ CCARGS+=-DHAS_PGSQL -I$(STAGING_DIR)/usr/include/
+ AUXLIBS+=-L$(STAGING_DIR)/usr/lib -lpq
+endif
+
+ifdef CONFIG_POSTFIX_PCRE
+ CCARGS+=-DHAS_PCRE -I$(STAGING_DIR)/usr/include/
+ AUXLIBS+=-L$(STAGING_DIR)/usr/lib -lpcre
+else
+ CCARGS+=-DNO_PCRE
+endif
+
+ifdef CONFIG_POSTFIX_EAI
+ AUXLIBS+=-licuuc
+ CCARGS+=-DHAS_EAI
+ smtputf8_conf = yes
+else
+ CCARGS+=-DNO_EAI
+ smtputf8_conf = no
+endif
+
+CCARGS+=-DDEF_DB_TYPE=\"$(default_database_type)\"
+TARGET_LDFLAGS += $(if $(CONFIG_USE_GLIBC),-lresolv)
+
+# prevent postfix-install from executing postconf at build time
+# by explicitly providing the default values to postfix-install
+config_directory=/etc/postfix
+sample_directory=/etc/postfix
+command_directory=/usr/sbin
+daemon_directory=/usr/libexec/postfix
+html_directory=no
+manpage_directory=no
+readme_directory=no
+sendmail_path=/usr/sbin/sendmail
+newaliases_path=/usr/bin/newaliases
+mailq_path=/usr/bin/mailq
+shlib_directory=/usr/lib/postfix
+meta_directory=/etc/postfix
+data_directory=/usr/var/lib/postfix
+queue_directory=/usr/var/spool/postfix
+mail_spool_directory=/usr/var/mail
+
+ln_suffix=.postfix
+ln_suffix_pre_pf=.pre-postfix
+ln_suffix_legacy=.old
+
+define Package/postfix/conffiles
+$(config_directory)
+endef
+
+define Build/Configure
+ if [ "$(default_database_type)" = "" ]; then \
+ echo "Build error: CDB or BerkeleyDB support must be enabled."; \
+ exit 1; \
+ fi
+ cd $(PKG_BUILD_DIR); $(MAKE) makefiles CCARGS='$(CCARGS)' $(TARGET_CONFIGURE_OPTS) 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 as a workaround
+ cd $(PKG_BUILD_DIR); $(MAKE) $(TARGET_CONFIGURE_OPTS) CC='$(TARGET_CC) $(CCARGS) $(TARGET_CFLAGS) $(TARGET_LDFLAGS)'
+ $(foreach p, \
+ default_database_type config_directory command_directory daemon_directory \
+ shlib_directory manpage_directory data_directory queue_directory \
+ mail_spool_directory, \
+ echo "$(p) = $($(p))" >> $(PKG_BUILD_DIR)/conf/main.cf;)
+endef
+
+define Package/postfix/install
+ cd $(PKG_BUILD_DIR); $(MAKE) install_root=$(1) command_directory=$(command_directory) daemon_directory=$(daemon_directory) data_directory=$(data_directory) html_directory=$(html_directory) mail_owner=postfix mailq_path=$(mailq_path)$(ln_suffix) manpage_directory=$(manpage_directory) newaliases_path=$(newaliases_path)$(ln_suffix) queue_directory=$(queue_directory) readme_directory=$(readme_directory) sendmail_path=$(sendmail_path)$(ln_suffix) setgid_group=postdrop sample_directory=$(sample_directory) config_directory=$(config_directory) shlib_directory=$(shlib_directory) meta_directory=$(meta_directory) mail_version=$(PKG_VERSION) non-interactive-package
+ $(INSTALL_DIR) $(1)/etc/init.d/
+ $(INSTALL_BIN) ./files/postfix.init $(1)/etc/init.d/postfix
+endef
+
+define Package/postfix/postinst
+#!/bin/sh
+
+for syml in $(sendmail_path) $(newaliases_path) $(mailq_path); do
+ file=$${IPKG_INSTROOT}$${syml}
+ if [ -f "$${file}$(ln_suffix_legacy)" ]; then
+ # update files saved by legacy versions of Postfix postinst script
+ mv "$${file}$(ln_suffix_legacy)" "$${file}$(ln_suffix_pre_pf)"
+ fi
+ if [ -f "$${file}" ]; then
+ linktarget=$$(basename $$(readlink "$${file}"))
+ postfixf=$$(basename "$${syml}")$(ln_suffix)
+ if [ $${linktarget} != $${postfixf} ]; then
+ mv "$${file}" "$${file}$(ln_suffix_pre_pf)"
+ echo "Info: $${file} saved as $${file}$(ln_suffix_pre_pf)"
+ fi
+ fi
+ if [ ! -f "$${file}" ]; then
+ ln -s "$${syml}$(ln_suffix)" "$${file}"
+ fi
+done
+# fix file/dir ownership in data_directory and queue_directory
+if [ -z "$${IPKG_INSTROOT}" ]; then
+ postfix set-permissions
+fi
+
+endef
+
+define Package/postfix/postrm
+#!/bin/sh
+rm -f "$(sendmail_path)" "$(newaliases_path)" "$(mailq_path)"
+
+for syml in "$(sendmail_path)" "$(newaliases_path)" "$(mailq_path)"; do
+ file=$${IPKG_INSTROOT}$${syml}
+ if [ -f "$${file}$(ln_suffix_legacy)" ]; then
+ # update files saved by legacy versions of Postfix postinst script
+ mv "$${file}$(ln_suffix_legacy)" "$${file}$(ln_suffix_pre_pf)"
+ fi
+ if [ -f "$${syml}$(ln_suffix_pre_pf)" ]; then
+ mv "$${syml}$(ln_suffix_pre_pf)" "$${syml}"
+ echo "Info: $${syml}$(ln_suffix_pre_pf) restored as $${syml}"
+ fi
+done
+endef
+
+$(eval $(call BuildPackage,postfix))
diff --git a/external/subpack/mail/postfix/files/postfix.init b/external/subpack/mail/postfix/files/postfix.init
new file mode 100644
index 0000000..161c371
--- /dev/null
+++ b/external/subpack/mail/postfix/files/postfix.init
@@ -0,0 +1,61 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2014 OpenWrt.org
+
+START=72
+STOP=50
+
+extra_command "status" "Display the service status"
+extra_command "abort" "Stop the service abruptly. Running processes are signaled to stop immediately"
+extra_command "flush" "Force delivery: attempt to deliver every message in the deferred mail queue"
+extra_command "postinst" "Force running a script that checks for users, group, configuration, permissions, etc"
+
+postinst() {
+ if [ -z "$(postconf -nh myhostname)" ]; then
+ postconf -e "myhostname = $(uci get system.@system[0].hostname)"
+ fi
+ if [ -z "$(postconf -nh mydomain)" ]; then
+ postconf -e "mydomain = $(uci get dhcp.@dnsmasq[0].domain)"
+ fi
+ if [ -z "$(postconf -nh mynetworks_style)" ]; then
+ postconf -e "mynetworks_style = subnet"
+ fi
+ mail_spool_directory=$(postconf -h mail_spool_directory)
+ if [ ! -d $mail_spool_directory ]; then
+ mkdir -p -m 0755 $mail_spool_directory
+ chown -R postfix $mail_spool_directory
+ fi
+
+ postfix set-permissions
+ postfix post-install upgrade-source
+ postfix upgrade-configuration
+ newaliases
+ postmap $(postconf -h config_directory)/virtual
+ postfix check
+}
+
+start() {
+ if [ -z "$(postconf -nh myhostname)" ]; then
+ postinst
+ fi
+ postfix start
+}
+
+stop() {
+ postfix stop
+}
+
+reload() {
+ postfix reload
+}
+
+status() {
+ postfix status
+}
+
+abort() {
+ postfix abort
+}
+
+flush() {
+ postfix flush
+}
diff --git a/external/subpack/mail/postfix/patches/200-manpages.patch b/external/subpack/mail/postfix/patches/200-manpages.patch
new file mode 100644
index 0000000..0a3b9f3
--- /dev/null
+++ b/external/subpack/mail/postfix/patches/200-manpages.patch
@@ -0,0 +1,78 @@
+--- a/conf/post-install
++++ b/conf/post-install
+@@ -366,10 +366,10 @@ test -f $config_directory/main.cf && {
+
+ # 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
+@@ -377,7 +377,7 @@ case $setgid_group in
+ esac
+
+ for path in "$daemon_directory" "$command_directory" "$queue_directory" \
+- "$sendmail_path" "$newaliases_path" "$mailq_path" "$manpage_directory" \
++ "$sendmail_path" "$newaliases_path" "$mailq_path" \
+ "$meta_directory"
+ do
+ case "$path" in
+@@ -386,7 +386,7 @@ do
+ esac
+ done
+
+-for path in "$html_directory" "$readme_directory" "$shlib_directory"
++for path in "$html_directory" "$readme_directory" "$shlib_directory" "$manpage_directory"
+ do
+ case "$path" in
+ /*) ;;
+--- a/postfix-install
++++ b/postfix-install
+@@ -563,13 +563,13 @@ case "$setgid_group" in
+ 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" "$shlib_directory"
+ do
+@@ -582,7 +582,7 @@ do
+ 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" \
+ "$meta_directory"
+ do
+ case "$path" in
+@@ -789,8 +789,8 @@ do
+ 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/external/subpack/mail/postfix/patches/300-bdb_hash_segfault.patch b/external/subpack/mail/postfix/patches/300-bdb_hash_segfault.patch
new file mode 100644
index 0000000..1ae9359
--- /dev/null
+++ b/external/subpack/mail/postfix/patches/300-bdb_hash_segfault.patch
@@ -0,0 +1,13 @@
+--- a/src/util/dict_db.c
++++ b/src/util/dict_db.c
+@@ -750,8 +750,8 @@ static DICT *dict_db_open(const char *cl
+ msg_fatal("create DB database: %m");
+ if (db == 0)
+ msg_panic("db_create null result");
+- if (type == DB_HASH && db->set_h_nelem(db, DICT_DB_NELM) != 0)
+- msg_fatal("set DB hash element count %d: %m", DICT_DB_NELM);
++// if (type == DB_HASH && db->set_h_nelem(db, DICT_DB_NELM) != 0)
++// msg_fatal("set DB hash element count %d: %m", DICT_DB_NELM);
+ db_base_buf = vstring_alloc(100);
+ #if DB_VERSION_MAJOR == 6 || DB_VERSION_MAJOR == 5 || \
+ (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR > 0)
diff --git a/external/subpack/mail/postfix/patches/400-cdb.patch b/external/subpack/mail/postfix/patches/400-cdb.patch
new file mode 100644
index 0000000..074d030
--- /dev/null
+++ b/external/subpack/mail/postfix/patches/400-cdb.patch
@@ -0,0 +1,13 @@
+--- a/src/util/sys_defs.h
++++ b/src/util/sys_defs.h
+@@ -760,9 +760,8 @@ extern int initgroups(const char *, int)
+ #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/external/subpack/mail/postfix/patches/500-crosscompile.patch b/external/subpack/mail/postfix/patches/500-crosscompile.patch
new file mode 100644
index 0000000..c7448a3
--- /dev/null
+++ b/external/subpack/mail/postfix/patches/500-crosscompile.patch
@@ -0,0 +1,27 @@
+--- a/makedefs
++++ b/makedefs
+@@ -215,7 +215,7 @@ error() {
+
+ case $# in
+ # Officially supported usage.
+- 0) SYSTEM=`(uname -s) 2>/dev/null`
++ 0) SYSTEM="OpenWRT"
+ RELEASE=`(uname -r) 2>/dev/null`
+ # No ${x%%y} support in Solaris 11 /bin/sh
+ RELEASE_MAJOR=`expr "$RELEASE" : '\([0-9]*\)'` || exit 1
+@@ -242,6 +242,15 @@ case "$SYSTEM" in
+ esac
+
+ case "$SYSTEM.$RELEASE" in
++ OpenWRT*) SYSTYPE=LINUX$RELEASE_MAJOR
++ SYSLIBS="$SYSLIBS -ldl"
++ : ${SHLIB_SUFFIX=.so}
++ : ${SHLIB_CFLAGS=-fPIC}
++ : ${SHLIB_LD="${CC-gcc} -shared"' -Wl,-soname,${LIB}'}
++ : ${SHLIB_RPATH='-Wl,--enable-new-dtags -Wl,-rpath,${SHLIB_DIR}'}
++ : ${SHLIB_ENV="LD_LIBRARY_PATH=`pwd`/lib"}
++ : ${PLUGIN_LD="${CC-gcc} -shared"}
++ ;;
+ SCO_SV.3.2) SYSTYPE=SCO5
+ # Use the native compiler by default
+ : ${CC="/usr/bin/cc -b elf"}
diff --git a/external/subpack/mail/postfix/patches/501-include_stdio.patch b/external/subpack/mail/postfix/patches/501-include_stdio.patch
new file mode 100644
index 0000000..84ad04a
--- /dev/null
+++ b/external/subpack/mail/postfix/patches/501-include_stdio.patch
@@ -0,0 +1,10 @@
+--- a/src/posttls-finger/posttls-finger.c
++++ b/src/posttls-finger/posttls-finger.c
+@@ -342,6 +342,7 @@
+ #include <sys/un.h>
+ #include <netinet/in.h>
+ #include <arpa/inet.h>
++#include <stdio.h>
+
+ #ifdef STRCASECMP_IN_STRINGS_H
+ #include <strings.h>
diff --git a/external/subpack/mail/postfix/patches/600-nopostconf.patch b/external/subpack/mail/postfix/patches/600-nopostconf.patch
new file mode 100644
index 0000000..ab83a02
--- /dev/null
+++ b/external/subpack/mail/postfix/patches/600-nopostconf.patch
@@ -0,0 +1,43 @@
+--- a/postfix-install
++++ b/postfix-install
+@@ -861,23 +861,23 @@ do
+ esac
+ done
+
+-bin/postconf -c $CONFIG_DIRECTORY -e \
+- "daemon_directory = $daemon_directory" \
+- "data_directory = $data_directory" \
+- "command_directory = $command_directory" \
+- "queue_directory = $queue_directory" \
+- "mail_owner = $mail_owner" \
+- "setgid_group = $setgid_group" \
+- "sendmail_path = $sendmail_path" \
+- "mailq_path = $mailq_path" \
+- "newaliases_path = $newaliases_path" \
+- "html_directory = $html_directory" \
+- "manpage_directory = $manpage_directory" \
+- "sample_directory = $sample_directory" \
+- "readme_directory = $readme_directory" \
+- "shlib_directory = $shlib_directory" \
+- "meta_directory = $meta_directory" \
+-|| exit 1
++#bin/postconf -c $CONFIG_DIRECTORY -e \
++# "daemon_directory = $daemon_directory" \
++# "data_directory = $data_directory" \
++# "command_directory = $command_directory" \
++# "queue_directory = $queue_directory" \
++# "mail_owner = $mail_owner" \
++# "setgid_group = $setgid_group" \
++# "sendmail_path = $sendmail_path" \
++# "mailq_path = $mailq_path" \
++# "newaliases_path = $newaliases_path" \
++# "html_directory = $html_directory" \
++# "manpage_directory = $manpage_directory" \
++# "sample_directory = $sample_directory" \
++# "readme_directory = $readme_directory" \
++# "shlib_directory = $shlib_directory" \
++# "meta_directory = $meta_directory" \
++#|| exit 1
+
+ # If Postfix is being installed locally from source code, do the
+ # post-install processing now.
diff --git a/external/subpack/mail/postfix/patches/700-defaultconfig.patch b/external/subpack/mail/postfix/patches/700-defaultconfig.patch
new file mode 100644
index 0000000..c779d12
--- /dev/null
+++ b/external/subpack/mail/postfix/patches/700-defaultconfig.patch
@@ -0,0 +1,92 @@
+--- a/conf/main.cf
++++ b/conf/main.cf
+@@ -40,43 +40,8 @@ compatibility_level = 2
+ #
+ #soft_bounce = no
+
+-# LOCAL PATHNAME INFORMATION
+-#
+-# The queue_directory specifies the location of the Postfix queue.
+-# This is also the root directory of Postfix daemons that run chrooted.
+-# See the files in examples/chroot-setup for setting up Postfix chroot
+-# environments on different UNIX systems.
+-#
+-queue_directory = /var/spool/postfix
+-
+-# The command_directory parameter specifies the location of all
+-# postXXX commands.
+-#
+-command_directory = /usr/sbin
+-
+-# The daemon_directory parameter specifies the location of all Postfix
+-# daemon programs (i.e. programs listed in the master.cf file). This
+-# directory must be owned by root.
+-#
+-daemon_directory = /usr/libexec/postfix
+-
+-# The data_directory parameter specifies the location of Postfix-writable
+-# data files (caches, random numbers). This directory must be owned
+-# by the mail_owner account (see below).
+-#
+-data_directory = /var/lib/postfix
+-
+ # QUEUE AND PROCESS OWNERSHIP
+ #
+-# The mail_owner parameter specifies the owner of the Postfix queue
+-# and of most Postfix daemon processes. Specify the name of a user
+-# account THAT DOES NOT SHARE ITS USER OR GROUP ID WITH OTHER ACCOUNTS
+-# AND THAT OWNS NO OTHER FILES OR PROCESSES ON THE SYSTEM. In
+-# particular, don't specify nobody or daemon. PLEASE USE A DEDICATED
+-# USER.
+-#
+-mail_owner = postfix
+-
+ # The default_privs parameter specifies the default rights used by
+ # the local delivery agent for delivery to external file or command.
+ # These rights are used in the absence of a recipient user context.
+@@ -632,45 +597,4 @@ debugger_command =
+ # -dmS $process_name gdb $daemon_directory/$process_name
+ # $process_id & sleep 1
+
+-# INSTALL-TIME CONFIGURATION INFORMATION
+-#
+-# The following parameters are used when installing a new Postfix version.
+-#
+-# sendmail_path: The full pathname of the Postfix sendmail command.
+-# This is the Sendmail-compatible mail posting interface.
+-#
+-sendmail_path =
+-
+-# newaliases_path: The full pathname of the Postfix newaliases command.
+-# This is the Sendmail-compatible command to build alias databases.
+-#
+-newaliases_path =
+-
+-# mailq_path: The full pathname of the Postfix mailq command. This
+-# is the Sendmail-compatible mail queue listing command.
+-#
+-mailq_path =
+-
+-# setgid_group: The group for mail submission and queue management
+-# commands. This must be a group name with a numerical group ID that
+-# is not shared with other accounts, not even with the Postfix account.
+-#
+-setgid_group =
+-
+-# html_directory: The location of the Postfix HTML documentation.
+-#
+-html_directory =
+-
+-# manpage_directory: The location of the Postfix on-line manual pages.
+-#
+-manpage_directory =
+-
+-# sample_directory: The location of the Postfix sample configuration files.
+-# This parameter is obsolete as of Postfix 2.1.
+-#
+-sample_directory =
+-
+-# readme_directory: The location of the Postfix README files.
+-#
+-readme_directory =
+ inet_protocols = ipv4
diff --git a/external/subpack/mail/postfix/patches/800-fmt.patch b/external/subpack/mail/postfix/patches/800-fmt.patch
new file mode 100644
index 0000000..262a2ae
--- /dev/null
+++ b/external/subpack/mail/postfix/patches/800-fmt.patch
@@ -0,0 +1,11 @@
+--- a/conf/post-install
++++ b/conf/post-install
+@@ -326,7 +326,7 @@ fake_fmt() {
+ case `uname -s` in
+ HP-UX*) FMT=cat;;
+ SunOS*) FMT=fake_fmt;;
+- *) FMT=fmt;;
++ *) FMT=cat;;
+ esac
+
+ # If a parameter is not set via the command line or environment,
diff --git a/external/subpack/mail/postfix/patches/900_less_overlayfs_rewrites.patch b/external/subpack/mail/postfix/patches/900_less_overlayfs_rewrites.patch
new file mode 100644
index 0000000..faed3af
--- /dev/null
+++ b/external/subpack/mail/postfix/patches/900_less_overlayfs_rewrites.patch
@@ -0,0 +1,23 @@
+--- a/conf/post-install
++++ b/conf/post-install
+@@ -566,15 +566,16 @@ test -n "$create" && {
+ then
+ set_permission=1
+ fi
++ test -n "$recursive" && nonrecursive="" || nonrecursive="-maxdepth 0"
+ test -n "$set_permission" && {
+- chown $recursive $owner $path || exit 1
+- test -z "$group" || chgrp $recursive $group $path || exit 1
++ find $path $nonrecursive ! -user $owner -exec chown $owner "{}" ";" || exit 1
++ test -z "$group" || find $path $nonrecursive ! -group $group -exec chgrp $group "{}" ";" || exit 1
+ # Don't "chmod -R"; queue file status is encoded in mode bits.
+ if [ "$type" = "d" -a -n "$recursive" ]
+ then
+- find $path -type d -exec chmod $mode "{}" ";"
++ find $path -type d -a ! -perm $mode -exec chmod $mode "{}" ";"
+ else
+- chmod $mode $path
++ find $path $nonrecursive ! -perm $mode -exec chmod $mode "{}" ";"
+ fi || exit 1
+ }
+ done