# -*- 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
version                 0.8.12
revision                2
categories              devel python
platforms               darwin
supported_archs         noarch
license                 GPL-2
maintainers             {ryandesign @ryandesign} openmaintainer

description             buildslave for buildbot continuous integration system

long_description        Buildbot is a system to automate the compile/test \
                        cycle required by most software projects to validate \
                        code changes. This port provides the slave side of \
                        the system.

homepage                http://buildbot.net/
master_sites            https://pypi.python.org/packages/source/b/buildbot-slave/
dist_subdir             ${name}

checksums               md5     a5bdda0174e0428b14580323d35b221f \
                        rmd160  42c30f14bace0871f16f4094e72caf440e843643 \
                        sha256  905eab122dcfc9425d51f0ed0c7682e7f933e140a7203637aa12a84498bd7461

python.default_version  27

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

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 a user that can be used to run the buildbot slave
add_users               buildbot group=buildbot

pre-extract {
    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 644 -W ${worksrcpath} COPYING NEWS README UPGRADING \
        ${destroot}${docdir}
    xinstall -m 644 ${worksrcpath}/docs/buildslave.1 \
        ${destroot}${prefix}/share/man/man1
    xinstall -d ${destroot}${sharedir}
    xinstall -m 755 ${worksrcpath}/macports/${plistfile} \
        ${destroot}${sharedir}
}

depends_test            port:py${python.version}-mock
test.run                yes
test.env                PYTHONPATH=.
test.cmd                ${prefix}/bin/trial-${python.branch}
test.target             buildslave.test

livecheck.type          regex
livecheck.url           https://pypi.python.org/pypi/${name}/
livecheck.regex         {buildbot-slave\/(\d+\.\d+(?:\.\d+))\"}
#livecheck.regex        {buildbot-slave\/(\d+\.\d+(?:\.\d+)(?:b\d))}

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

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