# -*- 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-worker
version             3.10.1
revision            0
checksums           rmd160  0823a82cbd1eb32aaa478b50dcaccc8065f2ceb1 \
                    sha256  8e28403c4cde7a05046bf059f770deefbdbc2178cbec192bc1f3e4e46eab9d4c \
                    size    130603

categories          devel
maintainers         {ryandesign @ryandesign} {rajdeep @rajdeepbh} openmaintainer
license             GPL-2
supported_archs     noarch
platforms           {darwin any}

description         build worker 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 the worker part of the system. \
                    The legacy version is available in the buildbot-slave-0.8 port.

homepage            https://buildbot.net

# Can't update to 311 due to missing dependency:
# https://trac.macports.org/ticket/67849
python.default_version \
                    310

depends_build-append \
                    port:py${python.version}-setuptools

depends_run-append  port:py${python.version}-autobahn \
                    port:py${python.version}-future \
                    port:py${python.version}-msgpack \
                    port:py${python.version}-twisted

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

build.env           NO_INSTALL_REQS=1

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

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}
    reinplace -locale C "s|@PYTHONVER@|${python.branch}|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/${name}.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         buildbot_worker.test

notes "
An example launchd plist file is available in ${sharedir}. After you have\
created your build worker, 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
"
