description="Mail Transport Agent (MTA) for sending email to other users of your host machine"
url="http://www.postfix.org"

packager="tnut <tnut@nutyx.org>"
contributors="Berlius, Fanch, Greg, Minzord"

makedepends=(libnsl db cyrus-sasl openssl icu mariadb openldap pcre postgresql sqlite)
run=(shadow)

name=postfix
version=3.5.8
runyx_version=20200412

source=(http://downloads.tuxfamily.org/nutyx/files/runyx-${runyx_version}.tar.xz
	ftp://ftp.porcupine.org/mirrors/postfix-release/official/$name-$version.tar.gz)

prepare() {
SN="postfix"
IDN="32"
if ! (getent group $SN > /dev/null); then
   groupadd -g $IDN $SN
fi
if ! (getent passwd $SN > /dev/null); then
   useradd -c "Postfix Daemon User" -d /var/spool/$SN \
   -u $IDN -g $SN -s /bin/false $SN
fi

SN="postdrop"
IDN="33"
if ! (getent group $SN > /dev/null); then
   groupadd -g $IDN $SN
fi
}
build() {

cd $name-$version

sed -i 's/.\x08//g' README_FILES/*

make CCARGS="-DUSE_TLS -I/usr/include/openssl/        \
-DUSE_SASL_AUTH -DUSE_CYRUS_SASL -I/usr/include/sasl" \
AUXLIBS="-lssl -lcrypto -lsasl2"                      \
makefiles
make

sh postfix-install -non-interactive \
daemon_directory=$PKG/usr/lib/postfix \
manpage_directory=$PKG/usr/share/man \
html_directory=$PKG/usr/share/doc/postfix-$version/html \
readme_directory=$PKG/usr/share/doc/postfix-$version/readme

# Service
cd ../runyx-${runyx_version}
make DESTDIR=$PKG install-sysv-postfix

}
