# -*- 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-0.8
version                 0.8.14
revision                1
checksums               rmd160  24f50e94f78cbfee31448f348365e4aa86322550 \
                        sha256  331efd07bd7522c222a8fb258801e8d78332c88d778ee76416b9e1028676e964 \
                        size    4840110

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

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 version 0.8.x of the \
                        master part of the system. Subsequent versions have \
                        a redesigned architecture and are available in the \
                        buildbot port.

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

python.default_version  27

depends_lib-append      port:py${python.version}-dateutil \
                        port:py${python.version}-jinja2 \
                        port:py${python.version}-sqlalchemy \
                        port:py${python.version}-sqlalchemy-migrate \
                        port:py${python.version}-twisted

patchfiles-append       patch-allowRecent_SQA_Migrate.diff \
                        patch-buildbot-status-web-console.py.diff \
                        patch-buildbot-status-web-grid.py.diff \
                        patch-buildbot-status-web-waterfall.py.diff \
                        fix-github-webhook-payload-url.patch \
                        setHeader.patch

build.env               NO_INSTALL_REQS=1

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

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} README COPYING CREDITS NEWS UPGRADING \
        ${destroot}${docdir}
    xinstall -d ${destroot}${sharedir}
    xinstall -m 0755 ${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             buildbot.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 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
"
