PortSystem 1.0

name            runit
version         2.1.2
revision        1
categories      sysutils
platforms       darwin
maintainers     nomaintainer
license         BSD

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 \
                size    110916

worksrcdir      admin/${worksrcdir}

patchfiles      implicit.patch

use_configure   no

variant universal {}

configure.cflags-append -Wall
configure.ldflags-append -Xlinker -x

build.cmd       package/compile
build.target

post-patch {
    # Per the installation instructions at
    # http://smarden.org/runit/install.html
    # but using the right compiler and adding MacPorts flags.
    system -W ${worksrcpath} "echo ${configure.cc} ${configure.cflags} [get_canonical_archflags cc] > src/conf-cc"
    system -W ${worksrcpath} "echo ${configure.cc} ${configure.ldflags} [get_canonical_archflags ld] > 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
}

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 644 -W ${worksrcpath}/man chpst.8 runit-init.8 runit.8 runsv.8 \
        runsvchdir.8 runsvdir.8 sv.8 svlogd.8 utmpset.8 \
        ${destroot}${prefix}/share/man/man8
}

notes "
Create ${prefix}/var/service, then add service subdirectories as required;\
the startup item will then supervise these services by default.
"

livecheck.url       ${homepage}install.html
