git » geoip-database.git » main » tree

[main] / PKGBUILD

# Maintainer: Evangelos Foutras <evangelos@foutrelis.com>

pkgname=('geoip-database' 'geoip-database-extra')
pkgver=20240406
pkgrel=1
arch=('any')
url="https://mailfud.org/geoip-legacy/"
license=('custom:GeoLite2 End User License Agreement')
makedepends=('util-linux')
#checkdepends=('geoip')
_source_base=https://sources.archlinux.org/other/packages/$pkgname/$pkgver
source=(GeoIP-$pkgver.dat.gz::$_source_base/GeoIP.dat.gz
        GeoIPv6-$pkgver.dat.gz::$_source_base/GeoIPv6.dat.gz
        GeoIPCity-$pkgver.dat.gz::$_source_base/GeoIPCity.dat.gz
        GeoIPCityv6-$pkgver.dat.gz::$_source_base/GeoIPCityv6.dat.gz
        GeoIPASNum-$pkgver.dat.gz::$_source_base/GeoIPASNum.dat.gz
        GeoIPASNumv6-$pkgver.dat.gz::$_source_base/GeoIPASNumv6.dat.gz
        GeoLite2-End-User-License-Agreement.pdf)
sha256sums=('e7c1faffa75ab591d6badc795ce78e504abde0faa2acacd292bf9d5a386bad12'
            '9cc26c1426ffd7249337b140e8b8f529cf19d6c965e43aa98f99f0afb31e5f79'
            '3c0040eec0bc264b901278b2f20a67d60c59cd87ec363d309036eeb7232e6c34'
            '2178c8809332b43419c5165d6195f9d73080b01e7a46e0cecebf2624ac730c86'
            '04dca95519abfc2fc183710c712559da6cb9f006663fe42cf23b012ef408b30a'
            '6566543843f24864b966d55b60916283f9af41810a145b1fc7901840c36a41bd'
            'b9c7fbfcdd5b682b5635592281d72006df89d73f163308b7ef35a59f293b036e')

prepare() {
  cd "$srcdir"
  rename -v -- "-$pkgver" '' *.dat
}

check() {
  return 0
  cd "$srcdir"

  if [[ $(geoiplookup -f GeoIP.dat archlinux.org) != *'FI, Finland' ]]; then
    echo >&2 'Unable to resolve IPv4 address to country.'
    return 1
  fi

  if [[ $(geoiplookup6 -f GeoIPv6.dat archlinux.org) != *'FI, Finland' ]]; then
    echo >&2 'Unable to resolve IPv6 address to country.'
    return 1
  fi

  if [[ $(geoiplookup -f GeoIPCity.dat archlinux.org) != *'FI, 18, N/A, Helsinki'* ]]; then
    echo >&2 'Unable to resolve IPv4 address to city.'
    return 1
  fi

  if [[ $(geoiplookup6 -f GeoIPCityv6.dat archlinux.org) != *'FI, 18, Helsinki'* ]]; then
    echo >&2 'Unable to resolve IPv6 address to city.'
    return 1
  fi

  if [[ $(geoiplookup -f GeoIPASNum.dat archlinux.org) != *'AS24940 Hetzner Online GmbH' ]]; then
    echo >&2 'Unable to resolve IPv4 address to ASN.'
    return 1
  fi

  if [[ $(geoiplookup6 -f GeoIPASNumv6.dat archlinux.org) != *'AS24940 Hetzner Online GmbH' ]]; then
    echo >&2 'Unable to resolve IPv6 address to ASN.'
    return 1
  fi
}

package_geoip-database() {
  pkgdesc="GeoIP legacy country database (based on GeoLite2 data created by MaxMind)"
  install=$pkgname.install

  cd "$srcdir"

  install -Dm644 -t "$pkgdir/usr/share/GeoIP" GeoIP{,v6}.dat
  install -Dm644 -t "$pkgdir/usr/share/licenses/$pkgname" GeoLite2-End-User-License-Agreement.pdf
}

package_geoip-database-extra() {
  pkgdesc="GeoIP legacy city/ASN databases (based on GeoLite2 data created by MaxMind)"
  install=$pkgname.install

  cd "$srcdir"

  install -Dm644 -t "$pkgdir/usr/share/GeoIP" GeoIPCity{,v6}.dat GeoIPASNum{,v6}.dat
  install -Dm644 -t "$pkgdir/usr/share/licenses/$pkgname" GeoLite2-End-User-License-Agreement.pdf
}

# vim:set ts=2 sw=2 et: