# $Id: Portfile 64079 2010-02-21 20:43:45Z jameskyle@macports.org $

PortSystem 1.0

name			vsftpd
version			2.2.2
categories		net
platforms		darwin
maintainers		pmq openmaintainer

description		Secure FTP server for UNIX systems
long_description	vsftpd is an FTP server, or daemon. The 'vs' stands for \
			Very Secure. Obviously this is not a guarantee, but a \
			reflection that it is written with security in mind, and \
			carefully designed to be resilient to attack.

homepage		http://vsftpd.beasts.org
master_sites		ftp://vsftpd.beasts.org/users/cevans/
checksums       md5     6d6bc136af14c23f8fef6f1a51f55418 \
                sha1    43976c6dbffe8e4bdc5f4add73a0c1431662a6c6 \
                rmd160  2703291a9ce76f68cc8ef82f04cb28c471946f53

patchfiles		patch-sysdeputil.c.diff \
			patch-vsf_findlibs.sh.diff \
			patch-vsftpd.conf.diff \
			patch-Makefile.diff

configure {
	reinplace "s|/etc/|${prefix}/etc/|g" \
		${worksrcpath}/Makefile \
		${worksrcpath}/defs.h \
		${worksrcpath}/tunables.c \
		${worksrcpath}/vsftpd.8 \
		${worksrcpath}/vsftpd.conf
	reinplace "s|/var/|${prefix}/var/|g" \
		${worksrcpath}/tunables.c \
		${worksrcpath}/vsftpd.conf.5 \
		${worksrcpath}/vsftpd.conf
	reinplace "s|/usr/share/empty|${prefix}/var/empty|g" \
		${worksrcpath}/tunables.c
	reinplace "s|/usr/share/ssl/|${prefix}/share/ssl/|g" \
		${worksrcpath}/tunables.c
	reinplace "s|/etc/vsftpd|${prefix}/etc/vsftpd|g" \
		${worksrcpath}/vsftpd.conf.5

	reinplace "s|/usr/local/man|${destroot}${prefix}/share/man|g" \
		${worksrcpath}/Makefile
	reinplace "s|/usr/local|${destroot}${prefix}|g" \
		${worksrcpath}/Makefile
}

build.target

startupitem.create yes
startupitem.name ${name}
startupitem.executable ${prefix}/sbin/${name} ${prefix}/etc/${name}.conf

post-destroot {
    xinstall ${worksrcpath}/vsftpd.conf ${destroot}${prefix}/etc/vsftpd.conf.sample
    set docdir ${destroot}${prefix}/share/doc/${name}-${version}
    xinstall -d ${docdir}
    xinstall -m 644 -W ${worksrcpath} AUDIT BENCHMARKS BUGS COPYING FAQ LICENSE \
        README README.security README.ssl SIZE SPEED TODO TUNING \
        ${docdir}
    file copy ${worksrcpath}/EXAMPLE ${docdir}
    file copy ${worksrcpath}/SECURITY ${docdir}
}

destroot.keepdirs	"${destroot}${prefix}/var/empty/" \
			"${destroot}${prefix}/var/log/"

variant ssl description "Enable SSL support" {
    depends_lib-append	port:openssl

    post-configure {
        reinplace "s|#undef VSF_BUILD_SSL|#define VSF_BUILD_SSL|" \
	    ${worksrcpath}/builddefs.h
    }

    build.env-append	LDFLAGS=${configure.ldflags}
}

platform darwin 9 {
	patchfiles-append oldpam.diff
}


livecheck.type regex
livecheck.url ${homepage}
livecheck.regex "vsftpd-(\\d+(?:\\.\\d+)*)"
