description="GeoLite2 IP geolocation databases compiled by MaxMind"
url="http://www.maxmind.com/app/c"

packager="Great-OS Team"
maintainer="sipo"

name=geoip-database
version=20250129

source=(https://sources.archlinux.org/other/packages/$name/$version/GeoIP.dat.gz
	https://sources.archlinux.org/other/packages/$name/$version/GeoIPv6.dat.gz
        https://sources.archlinux.org/other/packages/$name/$version/GeoIPCity.dat.gz
        https://sources.archlinux.org/other/packages/$name/$version/GeoIPCityv6.dat.gz
        https://sources.archlinux.org/other/packages/$name/$version/GeoIPASNum.dat.gz
        https://sources.archlinux.org/other/packages/$name/$version/GeoIPASNumv6.dat.gz)

prepare() {
  for file in *.dat.gz
  do
    gzip -d $file
    file=${file//.dat.gz/.dat}
    mv -v $file ${file//.dat/-"$version".dat}
  done

  rename -v -- "-$version" '' *.dat

}

build() {
  install -d "$PKG/usr/share/GeoIP"

  install -m644 -t "$PKG/usr/share/GeoIP" GeoIP{,v6}.dat

  install -d "$PKG/usr/share/GeoIP"

  install -m644 -t "$PKG/usr/share/GeoIP" GeoIPCity{,v6}.dat GeoIPASNum{,v6}.dat
}
