# Contributor: Jakob Gruber <jakob.gruber@gmail.com>
# Contributor: Geoffroy Carrier <geoffroy.carrier@koon.fr>
# Contributor: Filip Dvorak <fila@pruda.com>

pkgname=firehol
pkgver=1.294
pkgrel=2
pkgdesc="The iptables stateful packet filtering firewall builder"
url="http://firehol.sourceforge.net"
arch=('any')
license=('GPL')
depends=('iptables' 'gawk' 'iproute')
makedepends=('cvs')
backup=('etc/firehol/firehol.conf')
install='firehol.install'
source=('disable-kernel-vercheck.patch')
md5sums=('73a8ae701f82af98e56a4b2f436fb399')

build() {
  cd ${srcdir}
  msg "Fetching sources from CVS ..."
  cvs -z3 -d:pserver:anonymous@firehol.cvs.sourceforge.net:/cvsroot/firehol co -D 20110125 firehol

  cd ${srcdir}/${pkgname}

  # the sed command for minimum kernel version is broken, and since it
  # only ensures we are using a kernel > 2.3, we can safely skip it entirely
  # https://bugs.archlinux.org/task/25917
  patch -p1 < ${srcdir}/disable-kernel-vercheck.patch
}

package() {
  cd ${srcdir}/${pkgname}

  install -d ${pkgdir}/etc/firehol{,/examples}
  install -d ${pkgdir}/usr/share/man/man{1,5}

  install -D -m744 firehol.sh ${pkgdir}/etc/rc.d/firehol
  install -D -m744 get-iana.sh ${pkgdir}/etc/firehol/
  install -D -m744 check-iana.sh ${pkgdir}/etc/firehol/
  install -D -m744 adblock.sh ${pkgdir}/etc/firehol/

  install -D -m644 examples/*.conf ${pkgdir}/etc/firehol/examples

  install -D -m644 man/firehol.1 ${pkgdir}/usr/share/man/man1/
  install -D -m644 man/firehol.conf.5 ${pkgdir}/usr/share/man/man5/

  # backup does not work if the file is not contained in the package
  # plus, creating it in post_install will set 777 permissions and we dont want that

  touch ${pkgdir}/etc/firehol/firehol.conf
  chmod 600 ${pkgdir}/etc/firehol/firehol.conf
}
