PortSystem          1.0

name                netatalk
version             2.0.5
revision            5
categories          net
platforms           darwin
maintainers         nomaintainer
description         file and printer server for Apple Macintosh clients
long_description    netatalk is a daemon which provides POSIX-compliant \
                    Unix/BSD systems with the ability to share files and \
                    printers with Apple Macintosh computers.

homepage            http://netatalk.sourceforge.net/
master_sites        sourceforge

checksums           rmd160  47247d376bf421652d9f9897c75853424215ae0a \
                    sha256  aa11b26ad5c6cfb6043458fc849ed82b13b6d13219191a6335fce1bc76288b37 \
                    size    993882

use_bzip2           yes
startupitem.create  yes
startupitem.start   "${prefix}/etc/netatalk/initscript start"
startupitem.stop    "${prefix}/etc/netatalk/initscript stop"
startupitem.restart "${prefix}/etc/netatalk/initscript restart"

patchfiles          patch-afppasswd.c \
                    patch-paths.h \
                    patch-uams_randnum.c \
                    patch-adv1tov2.c \
                    patch-usockfd.c

depends_lib         port:db47 \
                    path:lib/libssl.dylib:openssl \
                    path:bin/perl:perl5 \
                    port:libiconv

if {${os.platform} eq "darwin" && ${os.major} >= 10} {
    pre-patch {
        ui_msg "AppleTalk has been removed from Mac OS X 10.6+."
        ui_msg "Building without AppleTalk support."
        patchfiles-append patch-configure
        configure.args-append --disable-ddp
    }
}

post-patch  {
    reinplace "s|__PREFIX__|${prefix}|g" \
        ${worksrcpath}/include/atalk/paths.h
}

configure.args      --with-bdb=${prefix} \
                    --mandir=${prefix}/share/man \
                    --with-logfile=${prefix}/var/log/netatalk.log \
                    --with-spooldir=${prefix}/var/spool/netatalk \
                    --with-ssl-dir=${prefix} \
                    --with-libiconv=${prefix}

configure.cppflags-append -I${prefix}/include/db47
configure.ldflags-append  -L${prefix}/lib/db47

post-destroot {
    file delete -force ${destroot}${prefix}/sbin/atalkd \
        ${destroot}${prefix}/share/netatalk ${destroot}/etc
    xinstall -m 755 -d ${destroot}${prefix}/var/log/ \
        ${destroot}${prefix}/var/run/netatalk \
        ${destroot}${prefix}/var/spool/netatalk
    xinstall -m 755 ${filespath}/initscript ${destroot}${prefix}/etc/netatalk/
    reinplace "s|MACPORTS_PREFIX|${prefix}|" ${destroot}${prefix}/etc/netatalk/initscript
    system "touch ${destroot}${prefix}/var/log/netatalk.log"
    system "touch ${destroot}${prefix}/var/run/netatalk/afpd"
    destroot.keepdirs ${destroot}${prefix}/var/spool/netatalk
}