# -*- 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
PortGroup               python 1.0

name                    buildbot-slave-0.8
version                 0.8.14
revision                0
checksums               rmd160  f4171b45935737ba37d8c9ee9c9cb4978618a224 \
                        sha256  7db02738c02d34c4d32508ac200e5f089ba73549315b127a9d8c0808d1a6d7a9 \
                        size    117325

set branch              [join [lrange [split ${version} .] 0 1] .]
categories              devel python
platforms               {darwin any}
supported_archs         noarch
license                 GPL-2
maintainers             {ryandesign @ryandesign} openmaintainer

description             build slave for Buildbot continuous integration system

long_description        Buildbot is a system to automate the compile/test \
                        cycle of most software projects to validate code \
                        changes. This port provides version 0.8.x of the slave \
                        (worker) part of the system. Subsequent versions have \
                        a redesigned architecture and are available in the \
                        buildbot-worker port.

homepage                https://buildbot.net
python.rootname         buildbot-slave
dist_subdir             buildbot-slave

python.default_version  27

depends_lib-append      port:py${python.version}-twisted

depends_test            port:py${python.version}-mock

build.env               NO_INSTALL_REQS=1

set sharedir            ${prefix}/share/${subport}
set docdir              ${prefix}/share/doc/${subport}
set plistfile           org.macports.buildslave.template.plist

add_users               buildbot group=buildbot

post-extract {
    # Copy "group" permission to "others", which is empty.
    fs-traverse item ${worksrcpath} {
        set p [file attributes ${item} -permissions]
        file attributes ${item} -permissions [format {0%o} [expr {(${p} >> 3 & 7) | ${p}}]]
    }

    file mkdir ${worksrcpath}/macports
    copy ${filespath}/${plistfile} ${worksrcpath}/macports/${plistfile}
}

post-patch {
    reinplace -locale C "s|@PREFIX@|${prefix}|g" ${worksrcpath}/macports/${plistfile}
}

post-destroot {
    xinstall -d ${destroot}${docdir}
    xinstall -m 0644 -W ${worksrcpath} COPYING NEWS README UPGRADING \
        ${destroot}${docdir}
    xinstall -m 0644 ${worksrcpath}/docs/buildslave.1 \
        ${destroot}${prefix}/share/man/man1
    xinstall -d ${destroot}${sharedir}
    xinstall -m 0755 ${worksrcpath}/macports/${plistfile} \
        ${destroot}${sharedir}
}

test.run                yes
test.env                PYTHONPATH=.
test.cmd                ${prefix}/bin/trial-${python.branch}
test.target             buildslave.test

livecheck.regex         ${python.rootname}-([quotemeta ${branch}]\[0-9.\]+)[quotemeta ${extract.suffix}]

notes "
An example launchd plist file is available in ${sharedir}. After you have\
created your build slave, copy the plist to /Library/LaunchDaemons (as root)\
and edit the WorkingDirectory field as needed. Then instruct launchd to run\
it with:

sudo launchctl load -w /Library/LaunchDaemons/your.plist.name
"
