# $Id: Portfile 38162 2008-07-09 23:23:52Z ryandesign@macports.org $

PortSystem 1.0
name			sendfile
version			2.1b
revision		1
categories		net
platforms		darwin
maintainers		nomaintainer
homepage		http://fex.rus.uni-stuttgart.de/saft/sendfile.html
description		A saft suite for asynchronous transfers

long_description	Sendfile is a SAFT implementation for UNIX and serves as a tool for \
			asynchronous sending of files in the internet, conserving their file \
			attributes. It consists of the following parts: \
			sendfiled - the server daemon \
			sendfile - a client for sending files \
			sendmsg - a client for sending one-line text messages \
			receive - a client for receiving spooled files

dist_subdir		${name}/${version}_${revision}
master_sites		http://fex.rus.uni-stuttgart.de/download/
checksums		md5 671cd95971c53066a9d0fa66ac04e813 \
			sha1 3126ba04943e37dd4589edd6c5bc5d7f44ca8488 \
			rmd160 541619db34a9dbfdd85d5d1c2fc235e426e26087

patchfiles		patch-makeconfig.diff patch-sendfiled.c.diff

use_configure		no

pre-build {		reinplace "s|/var/spool|${prefix}/var/spool|" ${worksrcpath}/makeconfig
			reinplace "s|/usr/local|${prefix}|g" ${worksrcpath}/makeconfig
			reinplace "s|/var/log|${prefix}/var/log|" ${worksrcpath}/makeconfig
			reinplace "s|/opt/bin|${prefix}/bin|" ${worksrcpath}/etc/sendfile.cf
			}
			
build.args		config

post-build {		reinplace "s|/var/spool|${prefix}/var/spool|" ${worksrcpath}/etc/sfconf
			reinplace "s|/var/spool|${prefix}/var/spool|g" ${worksrcpath}/etc/sfdconf
			reinplace "s|/usr/local|${prefix}|g" ${worksrcpath}/etc/sfdconf
			}

destroot.destdir	${destroot}${prefix}
destroot.target

destroot {		xinstall -m 755 -v -W ${worksrcpath}/src \
			sendfile sendmsg receive fetchfile utf7encode wlock \
			${destroot}${prefix}/bin
			xinstall -m 755 -v -W ${worksrcpath}/etc \
			sfconf sfdconf check_sendfile \
			${destroot}${prefix}/bin
			xinstall -m 644 -v -W ${worksrcpath}/etc \
			sendfile.cf sendfile.deny \
			${destroot}${prefix}/etc
			xinstall -m 644 -v -W ${worksrcpath}/doc \
			sendmsg.1 sendfile.1 receive.1 fetchfile.1 utf7encode.1 wlock.1 \
			${destroot}${prefix}/share/man/man1
			xinstall -m 755 ${worksrcpath}/src/sendfiled ${destroot}${prefix}/sbin
			file mkdir ${destroot}${prefix}/share/doc/${name}
			file copy ${worksrcpath}/doc/README ${destroot}${prefix}/share/doc/${name}
			file copy ${worksrcpath}/doc/fetchfile.7 ${destroot}${prefix}/share/man/man7
			file copy ${worksrcpath}/doc/sendfiled.8 ${destroot}${prefix}/share/man/man8
			}
			

post-destroot {		system "cd '${destroot}${prefix}/bin' && ln -s utf7encode utf7decode"
			xinstall -m 755 -d ${destroot}${prefix}/var/spool/sendfile
			xinstall -m 700 -d ${destroot}${prefix}/var/spool/sendfile/LOG
			xinstall -m 1777 -d ${destroot}${prefix}/var/spool/sendfile/OUTGOING
			destroot.keepdirs-append ${destroot}${prefix}/var/spool/sendfile
			destroot.keepdirs-append ${destroot}${prefix}/var/spool/sendfile/LOG
			destroot.keepdirs-append ${destroot}${prefix}/var/spool/sendfile/OUTGOING
			}

# Notify the user how to launch the sendfile daemon
post-install {		ui_msg "\nFor being able to receive files, you'll have to use either"
			ui_msg "xinetd or inetd, depending on what you are using.\n"
			ui_msg "Use the following line if you'll go for inetd:"
			ui_msg "saft stream tcp nowait root /path/to/sendfiled sendfiled\n"
			ui_msg "For xinetd, just take a service file as an example.\n"
			ui_msg "If you're running Mac OS X 10.2 or Darwin 6.x, you should"
			ui_msg "add an entry in /etc/services to allow connections from and to"
			ui_msg "port 487 both udp and tcp.\n"
                        }

