# $Id: PKGBUILD 163822 2012-07-20 22:15:57Z foutrelis $
# Maintainer: Evangelos Foutras <evangelos@foutrelis.com>

pkgname=geoip-database
pkgver=20120706
pkgrel=1
pkgdesc="GeoLite country geolocation database compiled by MaxMind"
arch=('any')
url="http://www.maxmind.com/app/ip-location"
license=('custom:OPEN DATA LICENSE')
source=(GeoIP-$pkgver.dat.gz::http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz
        GeoIPv6-$pkgver.dat.gz::http://geolite.maxmind.com/download/geoip/database/GeoIPv6.dat.gz
        http://geolite.maxmind.com/download/geoip/database/LICENSE.txt)
noextract=(GeoIP-$pkgver.dat.gz
           GeoIPv6-$pkgver.dat.gz)

build() {
  cd "$srcdir"

  for _database_name in GeoIP GeoIPv6; do
    gunzip -c $_database_name-$pkgver.dat.gz >$_database_name.dat
  done
}

check() {
  cd "$srcdir"

  for _database in {GeoIP,GeoIPv6}.dat; do
    if ! grep -q 'MaxMind Inc All Rights Reserved' $_database; then
      error "Copyright notice is missing from $_database; something is fishy!"
      return 1
    fi
  done
}

package() {
  cd "$srcdir"

  install -d "$pkgdir/usr/share/GeoIP"
  install -m644 -t "$pkgdir/usr/share/GeoIP" GeoIP.dat GeoIPv6.dat

  install -Dm644 LICENSE.txt "$pkgdir/usr/share/licenses/$pkgname/LICENSE.txt"
}

# vim:set ts=2 sw=2 et:
md5sums=('1bfcf1600cabcae5ff37fbddf82ba231'
         '586740960300f6c5018eef279214d2b8'
         'a1381bd1aa0a0c91dc31b3f1e847cf4a')