# Description: Postfix Mail Transport Agent (MTA)
# URL: https://www.postfix.org/
# Maintainer: Matt Housh, jaeger at crux dot ninja
# Depends on: cyrus-sasl

name=postfix
version=3.9.0
release=1
source=(http://ftp.porcupine.org/mirrors/postfix-release/official/${name}-${version}.tar.gz
    aliases postfix.rc)

build() {
    cd $name-$version

    make tidy
    make makefiles \
        DEBUG="" \
        OPT="${CFLAGS}" \
        pie=yes \
        shared=yes \
        dynamicmaps=yes \
        CCARGS="-DUSE_SASL_AUTH -DUSE_CYRUS_SASL -DUSE_TLS -I/usr/include/sasl" \
        AUXLIBS="-lsasl2 -lssl -lcrypto"
    make

    make non-interactive-package install_root=${PKG} \
        config_directory=/etc/postfix \
        daemon_directory=/usr/lib/postfix \
    mail_owner=mail \
        manpage_directory=/usr/share/man \
        shlib_directory=/usr/lib/postfix

    chown mail ${PKG}/var/spool/postfix/* \
        ${PKG}/var/lib/postfix
    chgrp postdrop ${PKG}/var/spool/postfix/{maildrop,public} \
        ${PKG}/usr/sbin/post{drop,queue}
    chmod g+s ${PKG}/usr/sbin/post{drop,queue}

    install -D -m 0644 ${SRC}/aliases ${PKG}/etc/postfix/aliases
    install -D -m 0755 ${SRC}/postfix.rc ${PKG}/etc/rc.d/postfix

    touch ${PKG}/etc/postfix/{aliases,access,canonical,relocated,transport,virtual}.db
    touch ${PKG}/etc/postfix/{relay_domains,body_checks,mime_header_checks}

    sed -i -e 's,egrep,grep -E,g' $PKG/usr/lib/postfix/postfix-{,tls-}script
}

# vim: set ts=4 et:
