# -*- 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
version             3.10.1
revision            0
checksums           rmd160  e820a850aba7e6f43026a9bcb7207e9a38c1585f \
                    sha256  fc9e235a821910e6d264ac34e086fa87802f26d7cdc33c28cd1bbe8057a4d439 \
                    size    2520857

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

description         buildmaster 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 master part of the system. \
                    The legacy version is available in the buildbot-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

if {${subport} eq ${name}} {

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

depends_run-append  port:py${python.version}-alembic \
                    port:py${python.version}-autobahn \
                    port:py${python.version}-dateutil \
                    port:py${python.version}-jinja2 \
                    port:py${python.version}-jwt \
                    port:py${python.version}-sqlalchemy \
                    port:py${python.version}-sqlalchemy-migrate \
                    port:py${python.version}-treq \
                    port:py${python.version}-twisted \
                    port:py${python.version}-txaio \
                    port:py${python.version}-yaml \
                    port:py${python.version}-zopeinterface

depends_test-append port:py${python.version}-boto3 \
                    port:py${python.version}-enchant \
                    port:py${python.version}-flake8 \
                    port:py${python.version}-isort \
                    port:py${python.version}-lz4 \
                    port:py${python.version}-mock \
                    port:py${python.version}-pylint \
                    port:py${python.version}-treq \
                    port:py${python.version}-txrequests
#                   port:py${python.version}-moto \
#                   port:py${python.version}-pyjade \
#                   port:py${python.version}-setuptools-trial \

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

post-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}
}

# currently defunct due to missing dependencies
test.run            yes

post-destroot {
    xinstall -d ${destroot}${docdir}
    xinstall -m 0644 -W ${worksrcpath} README.rst COPYING CREDITS NEWS UPGRADING \
        ${destroot}${docdir}
    xinstall -d ${destroot}${sharedir}
    xinstall -m 0755 ${worksrcpath}/macports/${plistfile} \
        ${destroot}${sharedir}
}

variant angularjs description {Include old AngularJS-based web UI server} {
    depends_run-append \
                    port:buildbot-console-view \
                    port:buildbot-grid-view \
                    port:buildbot-waterfall-view \
                    port:buildbot-www
}

variant react description {Include new React-based web UI server} {
    depends_run-append \
                    port:buildbot-www-react
}

default_variants    +angularjs +react

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

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

}
