ASR_BASE

Change-Id: Icf3719cc0afe3eeb3edc7fa80a2eb5199ca9dda1
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