app=sysklogd
version=1.5
build=1sml
homepage="https://github.com/troglobit/sysklogd"
download="https://github.com/troglobit/sysklogd/archive/refs/tags/v1.5.0.tar.gz"
desc="Linux system logging utilities"
requires="musl"

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

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

  # Use memmove() instead of strcpy() in syslogd.c
  applypatch $srcdir/use_memmove_not_strcpy.diff
  applypatch $srcdir/fix-includes.patch
  sleep 1

  make all syslog_tst CC="$CC -static"

  # install binaries
  install -Dm 755 klogd $pkg/bin/klogd
  install -Dm 755 syslog_tst $pkg/bin/syslog_tst
  install -Dm 755 syslogd $pkg/bin/syslogd

  # install man pages
  install -Dm 644 syslog.conf.5 $pkg/share/man/man5/syslog.conf.5
  install -Dm 644 klogd.8 $pkg/share/man/man8/klogd.8
  install -Dm 644 sysklogd.8 $pkg/share/man/man8/sysklogd.8

  # install conf files
  install -Dm 644 $srcdir/syslog.conf.new $pkg/etc/syslog.conf.new
  install -Dm 644 $srcdir/syslog.logrotate $pkg/etc/logrotate.d/syslog.new

  cp ANNOUNCE CHANGES COPYING MANIFEST NEWS README* $pkgdocs/

  mkdir -p $pkg/var/log
  for i in cron debug maillog messages secure spooler syslog ; do
    touch $pkg/var/log/$i.new
    chmod 640 $pkg/var/log/$i.new
  done

  preprunitservice syslogd finish
  preprunitservice klogd finish
  chmod 755 $pkg/etc/service/{klogd,syslogd/finish}

  mkfinalpkg
}

sha512sums="
c4d3057b1e6ed67379bffe2a801d17e036ee6907e5166b80ece5b99f25526e9de1e9f9f22b2105f3130a9fcb928f1527f7d3d3cb714a03f0c6bc1aa150689840  sysklogd-1.5.tar.lz
0208662a0158ecb6b0a387bd1bf467c866105dac02767209aeaaaeb02762d6c2b814a2707315f8f6cd40f46c4b7744b74653e30973c31354998c27cd7c966dbd  fix-includes.patch
90b990cdc52f908889f51a1f24cee1cc29c72369c2900d4dd6397440ee73e52fcc52dd5b8f59bb9d227d2238f8330ff0fb98ff1814062ecf1e0f4743f429bea6  use_memmove_not_strcpy.diff
"
