description="Rotates system logs automatically"
url="https://github.com/logrotate/logrotate"

packager="spiky <spiky@nutyx.org>"
contributors="Greg,Rems"

makedepends=(popt gzip acl systemd)

name=logrotate
version=3.21.0

source=(https://github.com/logrotate/logrotate/releases/download/$version/$name-$version.tar.xz
        logrotate.conf)

build() {
cd $name-$version

./configure \
--prefix=/usr \
--mandir=/usr/share/man \
--with-compress-command=/usr/bin/gzip \
--with-uncompress-command=/usr/bin/gunzip \
--with-default-mail-command=/usr/bin/mail \
--with-acl

make
}

package() {
cd $name-$version
make DESTDIR=$PKG install
mkdir -p $PKG/etc/$name.d
mkdir -p $PKG/var/state/logrotate
install -D -m 640 ../$name.conf $PKG/etc/$name.conf
cat > $PKG/etc/logrotate.d/sys.log << EOF
/var/log/sys.log {
   # If the log file is larger than 100kb, rotate it
   size   100k
   rotate 5
   weekly
   postrotate
      /bin/killall -HUP syslogd
   endscript
}
EOF

chmod -v 0644 $PKG/etc/logrotate.d/sys.log

}

uptodate() {
feed=https://github.com/$name/$name/releases/.atom 
exec="lynx -read_timeout=20 -dump -listonly -nonumbers $feed"
ligne=1 # nombre de notification ? afficher
$exec $feed | grep title | \
sed "s@<title>@@" | \
sed "s@</title>@@" | \
sed "s@logrotate-@@" | \
head -n $(($ligne+1)) | \
tail -n $(($ligne))
}


