app=dcron
version=4.5
build=2sml
homepage="http://www.jimpryor.net/linux/dcron.html"
download="http://www.jimpryor.net/linux/releases/dcron-$version.tar.gz"
desc="Dillons Cron daemon"
requires="musl"

build() {
  mkandenterbuilddir
  rm -rf $app-$version

  tar xf $srcdir/$app-$version.tar.?z*
  cd $app-$version
  fixbuilddirpermissions

  applypatch $srcdir/0002-README-var-spool-cron-crontabs-root.patch
  applypatch $srcdir/0006-Fixed-a-bug-whereby-syncs-killed-all-waiting-jobs.patch
  applypatch $srcdir/0007-Update-main.c.patch
  applypatch $srcdir/crontab.c.O_EXCL.diff

  make PREFIX="" BINDIR=/bin SBINDIR=/bin CRONTAB_GROUP=root 

  install -Dm 755 crond $pkg/bin/crond
  install -Dm 4711 crontab $pkg/bin/crontab
  install -Dm 755 $srcdir/run-parts $pkg/bin/run-parts

  install -Dm 644 crontab.1 $pkg/share/man/man1/crontab.1
  install -Dm 644 crond.8 $pkg/share/man/man8/crond.8
  install -Dm 644 $srcdir/run-parts.8 $pkg/share/man/man8/run-parts.8

  # Create some other stuff we need
  mkdir -p $pkg/etc/cron.{hourly,daily,weekly,monthly}
  install -dm 0751 $pkg/var/spool/cron
  install -dm 750 $pkg/var/spool/cron/crontabs 
  install -dm 750 $pkg/var/spool/cron/cronstamps
  install -Dm 600 $srcdir/crontab.root $pkg/var/spool/cron/crontabs/root.new

  # dcron will whine about "unable to scan this directory", so we'll create it
  mkdir -p $pkg/etc/cron.d

  mkfinalpkg
}
sha512sums="
08521391d16ba5adf80278ec2a734319c26c48841fd94b119c0b27d744c2cfb3562b1a3630135a03d1c43b1668d49262713abb20ff5f7ecd397a2a19a2f6105a  dcron-4.5.tar.gz
687ba63afc4bf6028a7a4f0debfcb8b8758aaacd1ddb317136d55dfae7c57c572d81edf340b4b36476280a38b71b740f23e9f56a02a95ebd0f0aacdcba735c59  0002-README-var-spool-cron-crontabs-root.patch
faf6ecee8f678298b1a8cd27f42f42e3e3396062d73ea4bfff14f930ae71e99613354d9ec234407936e19c05b1de9cec46fffbf6df9ef71d4294d8b32bdad74d  0006-Fixed-a-bug-whereby-syncs-killed-all-waiting-jobs.patch
534628dfaad83a0d746731b67756fff3dd6a5b305efb07e00e3a7acb6bac9138e7ee3cae22d1314ee3041b22b9dd3574c1342e26af39198d6d0685964318876d  0007-Update-main.c.patch
a56862ea0fc1aa2f5fa77c2d341c2e35bb5d2ac5d9942c3dee25662eac6c9078fdd293835ec471ece22b2add4ae21db596cb0d41fb765ee92fb9aa53a4252287  crontab.c.O_EXCL.diff
"
