# Template file for 'geoip-data'
pkgname=geoip-data
version=20171002
revision=2
create_wrksrc=yes
short_desc="Non-DNS IP-to-country resolver C library and utilities (data files)"
maintainer="Enno Boland <gottox@voidlinux.org>"
license="CC-BY-SA-4.0"
homepage="https://dev.maxmind.com/geoip/legacy/geolite/"
archs=noarch

do_fetch() {
	$XBPS_FETCH_CMD http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz
	$XBPS_FETCH_CMD http://geolite.maxmind.com/download/geoip/database/GeoIPv6.dat.gz
	$XBPS_FETCH_CMD http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
	$XBPS_FETCH_CMD http://geolite.maxmind.com/download/geoip/database/GeoLiteCityv6-beta/GeoLiteCityv6.dat.gz
	$XBPS_FETCH_CMD http://download.maxmind.com/download/geoip/database/asnum/GeoIPASNum.dat.gz
	$XBPS_FETCH_CMD http://download.maxmind.com/download/geoip/database/asnum/GeoIPASNumv6.dat.gz
}

do_install() {
	local f
	vmkdir usr/share/GeoIP
	for f in GeoIP GeoIPv6 GeoLiteCity GeoLiteCityv6 GeoIPASNum GeoIPASNumv6; do
		zcat ../${f}.dat.gz > ${f}.dat
		rm -f ../${f}.dat.gz
		vinstall ${f}.dat 644 usr/share/GeoIP
	done
}
