# $Id: Portfile 56184 2009-08-25 06:11:10Z ryandesign@macports.org $

PortSystem 1.0
name		perforce
version		06.2
categories	devel
maintainers	nomaintainer
description	Fast source code management system
long_description	Perforce is a commercial revision control system that can be used gratis for developing free software. (see the WWW page for details). 
homepage    http://www.perforce.com/
platforms	darwin
master_sites    ftp://www.perforce.com/pub/perforce/r${version}/bin.darwin80ppc/ \
                http://www.perforce.com/perforce/doc.052/man/
dist_subdir	${name}
worksrcdir	${name}
distfiles	p4 p4.1 p4d p4d.1
checksums	p4 md5 345fe525b8a647c5b12fc078a67edba6 \
		p4.1 md5 e5cada2f402e1e016be7999fdc49035d \
		p4d md5 b00b4a3ff97afe4526ba2a7a8fa7008c \
		p4d.1 md5 1aa86f28ba0698266bf1dcaded3e4106
extract		{ system "mkdir -p ${worksrcpath}"
	 	  system "cp ${distpath}/* ${worksrcpath}/" }
use_configure	no
build		{}
destroot	{
		  system "install -o root -m 755 -d ${destroot}${prefix}/bin"
		  system "install -o root -m 755 -d ${destroot}${prefix}/sbin"
		  system "install -o root -m 755 -d ${destroot}${prefix}/share/man/man1"
		  system "install -o root -m 755 -d ${destroot}${prefix}/share/man/man8"
		  system "cd ${worksrcpath} && install -o root -m 755 -c p4 ${destroot}${prefix}/bin"
		  system "cd ${worksrcpath} && install -o root -m 755 -c p4d ${destroot}${prefix}/sbin"
		  system "cd ${worksrcpath} && install -o root -m 644 -c p4.1 \
		    ${destroot}${prefix}/share/man/man1"
		  system "cd ${worksrcpath} && install -o root -m 644 -c p4d.1 \
		    ${destroot}${prefix}/share/man/man8" }

variant server {
	startupitem.create    yes
	startupitem.start    "su -c ${prefix}/sbin/p4d -d -r ${prefix}/share/perforce/depot -L ${prefix}/share/perforce/log"

	post-destroot {
		addgroup perforce
		set gid [existsgroup perforce]
		adduser perforce realname=Perforce\ Server gid=${gid} \
			home=${prefix}/share/perforce shell=/bin/sh
		system "install -o perforce -m 755 -d \
			${destroot}${prefix}/share/perforce/depot"
		system "install -o perforce -m 644 -c /dev/null \
			${destroot}${prefix}/share/perforce/log"
	}
}

