PortSystem              1.0

name                    perforce
version                 2010.1
categories              devel
platforms               darwin
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/
master_sites            http://www.perforce.com/downloads/perforce/r[string range ${version} 2 end]/bin.darwin80u/:prog \
                        http://www.perforce.com/perforce/doc.052/man/:man

dist_subdir             ${name}/${version}
worksrcdir              ${name}

distfiles               p4:prog p4.1:man p4d:prog p4d.1:man

checksums               p4      md5     4170d202a4bda079e334c7dc5c37c417 \
                                sha1    c666bd19c6de7a1b7283c14c2f0cf8486c56c516 \
                                rmd160  5b3fc0fa7cab9d4fcfd8a2e0675379d2a4cceb60 \
                        p4.1    md5     e5cada2f402e1e016be7999fdc49035d \
                                sha1    f0740627c5232e2eb72a278fd62d5764b7fcbdbb \
                                rmd160  c32ac846dfa8110fadba131ca4c7a3782cf1c180 \
                        p4d     md5     dd2f6de1b1a57a70838379d425606896 \
                                sha1    f26b2b1d2ff1437b343c9bd590f72a0c00846567 \
                                rmd160  7957d8db3b6a2ec5e85fc291a03f746a15ea6b60 \
                        p4d.1   md5     1aa86f28ba0698266bf1dcaded3e4106 \
                                sha1    0383e5eb515ff1a4ecd6fb148aa544a49e68eb59 \
                                rmd160  913efbe9b299030a143e3c6a1fbf672ec526d7b7

extract.mkdir           yes
extract {
    copy {*}[glob ${distpath}/*] ${worksrcpath}
}

use_configure           no

build {}

destroot {
    xinstall -W ${worksrcpath} p4 ${destroot}${prefix}/bin
    xinstall -W ${worksrcpath} p4d ${destroot}${prefix}/sbin
    xinstall -W ${worksrcpath} -m 644 p4.1 ${destroot}${prefix}/share/man/man1
    xinstall -W ${worksrcpath} -m 644 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"
    }
}

supported_archs             i386 ppc x86_64
configure.universal_archs   i386 ppc x86_64
default_variants            +universal
variant_set                 universal
variant universal {}