PortSystem 1.0

name            runit
version         2.1.2
categories      sysutils
platforms       darwin
maintainers     nomaintainer
description     collection of tools for managing UNIX services
long_description    runit is a cross-platform Unix init scheme with service supervision, \
                    fashioned after daemontools.  It includes tools for starting, \
                    restarting, stopping, monitoring and logging any services \
                    that you might wish to run.

homepage        http://smarden.org/runit/
master_sites    http://smarden.org/runit/

checksums       rmd160  cc9535d17e42707a2fb6e9d0a19f19596788ed77 \
                sha256  6fd0160cb0cf1207de4e66754b6d39750cff14bb0aa66ab49490992c0c47ba18

worksrcdir      admin/${worksrcdir}
use_configure   no

build.cmd       package/compile
build.target

pre-build       {
    system "cd ${worksrcpath} && echo 'cc -Xlinker -x' >src/conf-ld"
    reinplace "s| -static||g" ${worksrcpath}/src/Makefile
    # Force use of select() rather than broken poll()
    file copy -force ${worksrcpath}/src/iopause.h1 ${worksrcpath}/src/iopause.h2
}
post-build  {
    system "cd ${workpath}/${worksrcdir}/man && gzip *.8"
}

startupitem.create      yes
startupitem.name        ${name}
startupitem.executable  sh -c "PATH=\"${prefix}/sbin:${prefix}/bin:\$PATH\" exec '${prefix}/sbin/runsvdir' '${prefix}/var/service' 'log: ...........................................................................................................................................................................................................................................................................................................................................................................................................'"

destroot    {
    xinstall -m 755 -s -W ${worksrcpath}/command runsv runsvdir sv svlogd utmpset chpst runsvchdir \
        ${destroot}${prefix}/sbin
    xinstall -m 755 -d ${destroot}${prefix}/share/doc/${name}
    xinstall -m 644 -W ${worksrcpath}/doc benefits.html chpst.8.html dependencies.html \
                 faq.html index.html install.html replaceinit.html runit-init.8.html runit.8.html \
                 runlevels.html runscripts.html runsv.8.html runsvchdir.8.html runsvdir.8.html sv.8.html \
                 svlogd.8.html upgrade.html usedietlibc.html useinit.html utmpset.8.html \
        ${destroot}${prefix}/share/doc/${name}

    xinstall -m 755 -d ${destroot}${prefix}/share/man/man8
    xinstall -m 644 -W ${worksrcpath}/man chpst.8.gz runit-init.8.gz runit.8.gz runsv.8.gz \
                 runsvchdir.8.gz runsvdir.8.gz sv.8.gz svlogd.8.gz utmpset.8.gz \
        ${destroot}${prefix}/share/man/man8
}

post-install    {
    ui_msg "\nCreate ${prefix}/var/service, then add service subdirectories as required; \
                the startup item will then supervise these services by default."
}

livecheck.url       ${homepage}install.html