# $Id: PKGBUILD 70436 2012-05-06 13:53:34Z lfleischer $
# Maintainer: Lukas Fleischer <archlinux at cryptocrack dot de>
# Contributor: Jaroslav Lichtblau <dragonlord@aur.archlinux.org>
# Contributor: Pierre Schmitz <pierre@archlinux.de>

pkgname=rkhunter
pkgver=1.4.0
pkgrel=1
pkgdesc='Checks machines for the presence of rootkits and other unwanted tools.'
arch=('any')
url='http://rkhunter.sourceforge.net/'
license=('GPL')
depends=('bash' 'perl' 'wget')
optdepends=('unhide')
backup=('etc/rkhunter.conf')
source=("http://downloads.sourceforge.net/sourceforge/${pkgname}/${pkgname}-${pkgver}.tar.gz"{,.asc})
md5sums=('37b1ceb79a5ff3debca335d6550ac6b0'
         'e83221c3eb3f417357059731c809a9de')

package() {
  cd "${srcdir}/${pkgname}-${pkgver}"

  # fix installer for x86_64
  sed -i -e "s/lib64/lib/g" installer.sh

  # install to "/usr"
  install -dm0755 "${pkgdir}/usr"
  ./installer.sh --layout custom "${pkgdir}/usr" --striproot "${pkgdir}" --install

  # fix paths
  mv "${pkgdir}/usr/etc" "${pkgdir}"
  mv "${pkgdir}/usr/var" "${pkgdir}"

  sed -i -e "s#/usr/etc/rkhunter.conf#/etc/rkhunter.conf#g" "${pkgdir}/usr/bin/${pkgname}"
  sed -i -e "s#/usr/etc/rkhunter.conf#/etc/rkhunter.conf#g" "${pkgdir}/etc/${pkgname}.conf"
  sed -i -e "s#/usr/var/lib/rkhunter/db#/var/lib/rkhunter/db#g" "${pkgdir}/etc/${pkgname}.conf"
  sed -i -e "s#/usr/var/lib/rkhunter/tmp#/var/lib/rkhunter/tmp#g" "${pkgdir}/etc/${pkgname}.conf"

  # cleanup
  rm -f "${pkgdir}/var/lib/${pkgname}/tmp/"{group,passwd}

  # we trust in udev
  sed -i 's|^#ALLOWHIDDENDIR=/dev/.udev$|ALLOWHIDDENDIR=/dev/.udev|' \
    "${pkgdir}/etc/${pkgname}.conf"
}
