# Template file for 'runit'
pkgname=runit
version=2.1.1
revision=2
wrksrc="admin"
short_desc="A UNIX init scheme with service supervision"
maintainer="Juan RP <xtraeme@gmail.com>"
license="BSD"
homepage="http://smarden.org/runit/"
distfiles="http://smarden.org/runit/runit-$version.tar.gz"
checksum=ffcf2d27b32f59ac14f2d4b0772a3eb80d9342685a2042b7fbbc472c07cf2a2c

do_build() {
  cd ${pkgname}-${version}/src

  sed -e 's,sbin/runit,usr/bin/runit,g' -i runit.h

  echo "$CC -D_GNU_SOURCE $CFLAGS" >conf-cc
  echo "$CC $LDFLAGS -Wl,-z -Wl,noexecstack" >conf-ld
  # set default service path to /var/service
  sed -i -e 's:^char \*varservice ="/service/";$:char \*varservice ="/var/service/";:' sv.c

  make ${makejobs}
}

do_install() {
  cd ${pkgname}-${version}/src

  # default services
  vmkdir var
  ln -s ../run/runit/runsvdir/current ${DESTDIR}/var/service

  vmkdir usr/bin
  install -m0755 {chpst,runit,runit-init,runsv,runsvchdir,runsvdir,sv,svlogd,utmpset} ${DESTDIR}/usr/bin

  cd ..
  vmkdir usr/share/man/man8
  install -m0644 man/* ${DESTDIR}/usr/share/man/man8

  vmkdir usr/share/doc/runit
  install -m0644 doc/*.html ${DESTDIR}/usr/share/doc/runit
}
