# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4

PortSystem              1.0

name                    perforce
version                 2010.1
revision                1
categories              devel
platforms               {darwin any}
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                https://www.perforce.com
master_sites            https://web.archive.org/web/20101114120829if_/http://filehost.perforce.com/perforce/r10.1/bin.darwin80u/:progp4 \
                        https://web.archive.org/web/20101114082044if_/http://filehost.perforce.com/perforce/r10.1/bin.darwin80u/:progp4d \
                        https://web.archive.org/web/20080509060459/http://www.perforce.com/perforce/doc.052/man/:manp4 \
                        https://web.archive.org/web/20080509163822/http://www.perforce.com/perforce/doc.052/man/:manp4d

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

distfiles               p4:progp4 p4.1:manp4 p4d:progp4d p4d.1:manp4d

checksums               p4 \
                        rmd160  6e28afa8a73fc5e0cd3124618e165ae229bf39f6 \
                        sha256  2ce97b5d9f920ea72b27c508af1da0e26f16155455830d7e662fdf372332ae2a \
                        size    2312600 \
                        p4.1 \
                        rmd160  c32ac846dfa8110fadba131ca4c7a3782cf1c180 \
                        sha256  7986ae2e099b47f418939981bc082a4238b35c7cb93687c2683fa038d18f5b13 \
                        size    72954 \
                        p4d \
                        rmd160  95bbbf288e04bc061e7a0365f5e591fbea2b7ab6 \
                        sha256  bba7d65c0efdd0f3ed0217b25bc5e0d32c7f0437207c995bb19ed14c16bf876e \
                        size    6381156 \
                        p4d.1 \
                        rmd160  913efbe9b299030a143e3c6a1fbf672ec526d7b7 \
                        sha256  ddb9a52d9c22cab889813981352f60c665eac68120714e674f686ff7f3fa07a3 \
                        size    4529

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 0644 p4.1 ${destroot}${prefix}/share/man/man1
    xinstall -W ${worksrcpath} -m 0644 p4d.1 ${destroot}${prefix}/share/man/man8/p4d.8
}

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 {}
configure.cxx_stdlib        libstdc++
