# $Id: Portfile 54601 2009-07-30 06:26:57Z toby@macports.org $

PortSystem       1.0

name             pureftpd
version          1.0.21
categories       net
platforms        darwin
maintainers      nomaintainer

homepage         http://pureftpd.org/
description      A fast and standard-conformant FTP server

long_description "Pure-FTPd is a fast, production-quality, standard-conformant FTP server, \
                 based upon Troll-FTPd. \
                 Unlike other popular FTP servers, it's designed to be secure in default \
                 configuration, has no known buffer overflow, it is really trivial to set \
                 up and it is especially designed for modern kernels. \
                 Features include chroot()ed and/or virtual chroot()ed home directories, \
                 virtual domains, built-in 'ls', anti-warez system, bounded ports for \
                 passive downloads, FXP protocol, bandwidth throttling, ratios, \
                 LDAP / MySQL / PostgreSQL-based authentication, fortune files, Apache-like \
                 log files, fast standalone mode, text / HTML / XML real-time status report, \
                 virtual users, virtual quotas and more."

master_sites     ftp://ftp.pureftpd.org/pure-ftpd/releases/ \
                 ftp://ftp.fr.pureftpd.org/pure-ftpd/releases/

distname         pure-ftpd-${version}
use_bzip2        yes

checksums        md5    ca8a8dbec0cd9c8ea92fc4c37ea9c410 \
                 sha1   1405ff2b9b9c3616c4e390eb99779884173a3347 \
                 rmd160 1ad61243c1f8a8d1055ee839eec0d9117681cf20

patchfiles       patch-pam_pureftpd.diff

configure.args   --with-everything \
                 --with-virtualchroot \
                 --with-paranoidmsg \
                 --with-pam \
                 --with-rendezvous \
                 --without-capabilities \
                 --mandir=${prefix}/share/man \
                 --infodir=${prefix}/share/info

destroot.destdir prefix=${destroot}${prefix} \
                 mandir=${destroot}${prefix}/share/man

post-destroot { \
    file mkdir ${destroot}${prefix}/share/doc/${name}
    xinstall -m 644 -v -W ${worksrcpath} \
    AUTHORS CONTACT FAQ HISTORY NEWS README \
    README.Authentication-Modules README.Configuration-File \
    README.LDAP README.MacOS-X README.MySQL README.PGSQL \
    README.TLS README.Virtual-Users pureftpd-ldap.conf \
    pureftpd-mysql.conf pureftpd-pgsql.conf THANKS \
    ${destroot}${prefix}/share/doc/${name}
    file copy ${worksrcpath}/pam/pure-ftpd \
    ${destroot}${prefix}/share/doc/${name}
}

# Notify the user how to launch the ftpd
post-install {
    ui_msg "\nYou can now start PureFTPd in 3 ways,"
    ui_msg "either via xinetd, in standalone mode, or"
    ui_msg "if you're using Mac OS X 10.4 / Darwin 8.x"
    ui_msg "via launchd(8).\n"
    ui_msg "If you're under Mac OS X 10.3 or Mac OS X 10.4,"
    ui_msg "you have to copy ${prefix}/share/doc/${name}/pure-ftpd"
    ui_msg "to /etc/pam.d and use the '-lpam' flag when"
    ui_msg "launching pure-ftpd to have PAM working.\n"
}

# Langugage variants, should only be able to choose one.
variant brazilian description "Use Bazilian language for server messages" { configure.args-append --with-language=brazilian }
variant czech description "Use Czech language for server messages" { configure.args-append --with-language=czech }
variant danish description "Use Danish language for server messages" { configure.args-append --with-language=danish }
variant dutch description "Use Dutch language for server messages" { configure.args-append --with-language=dutch }
variant french description "Use French language for server messages" { configure.args-append --with-language=french }
variant french_funny description "Use French funny language for server messages" { configure.args-append --with-language=french-funny }
variant german description "Use German language for server messages" { configure.args-append --with-language=german }
variant italian description "Use Italian language for server messages" { configure.args-append --with-language=italian }
variant korean description "Use Korean language for server messages" { configure.args-append --with-language=korean }
variant norwegian description "Use Norwegian language for server messages" { configure.args-append --with-language=norwegian }
variant polish description "Use Polish language for server messages" { configure.args-append --with-language=polish }
variant romanian description "Use Romanian language for server messages" { configure.args-append --with-language=romanian }
variant russian description "Use Russian language for server messages" { configure.args-append --with-language=russian }
variant simplified_chinese description "Use simplified Chinese for server messages" { configure.args-append --with-language=simplified-chinese }
variant slovak description "Use Slovak language for server messages" { configure.args-append --with-language=slovak }
variant spanish description "Use Spanish language for server messages" { configure.args-append --with-language=spanish }
variant swedish description "Use Swedish language for server messages" { configure.args-append --with-language=swedish }
variant traditional_chinese description "Use traditional Chinese language for server messages" { configure.args-append --with-language=traditional-chinese }

variant mysql5 description "Use the native MySQL support for users database." {
    depends_lib-append path:bin/mysql_config5:mysql5
    configure.args-append --with-mysql
    configure.cflags-append "-I${prefix}/include/mysql5/mysql"
    configure.ldflags-append "-L${prefix}/lib/mysql5/mysql"
}

variant nobanner description "Don't display the initial banner" { configure.args-append --without-banner }

variant tls description "Encryption of the control channel using SSL/TLS" {
    depends_lib             lib:libssl.dylib:openssl
    configure.args-append   --with-tls \
                            --with-certfile=${prefix}/etc/ssl/private/pure-ftpd.pem
}
