geoip: add geoipupdate option and fix data directory

Previous versions of geoip had geoipupdate bundled. It’s now a separate
project, but most users who upgrade will be surprised it’s gone, and
most new installs will want it.

geoip and geoipupdate need to share a data directory, which is
/usr/local/share/GeoIP by default. This doesn’t work with Homebrew,
since it can’t link into both cellar locations. I’ve manually specified
a reasonable location as the default.

Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
This commit is contained in:
Nicholas Sivo authored and Mike McQuaid committed 2013-11-28 10:12:48 +00:00
1 parent ea0fe99d1e
commit e7cda7f451
1 file changed
+18 -1
+18 -1
View File
@@ -9,6 +9,7 @@ class Geoip < Formula
depends_on 'autoconf' => :build
depends_on 'automake' => :build
depends_on 'libtool' => :build
depends_on 'geoipupdate' => :optional
option :universal
@@ -30,11 +31,27 @@ class Geoip < Formula
system "./configure", "--disable-dependency-tracking",
"--disable-silent-rules",
"--datadir=#{var}",
"--prefix=#{prefix}"
system "make", "check"
system "make", "install"
end
def post_install
geoip_data = Pathname.new "#{var}/GeoIP"
geoip_data.mkpath
# Since default data directory moved, copy existing DBs
legacy_data = Pathname.new "#{HOMEBREW_PREFIX}/share/GeoIP"
cp Dir.glob("#{legacy_data}/*"), geoip_data if legacy_data.exist?
["City", "Country"].each do |type|
full = Pathname.new "#{geoip_data}/GeoIP#{type}.dat"
next if full.exist? or full.symlink?
ln_s "GeoLite#{type}.dat", full
end
end
test do
system "curl", "-O", "http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz"
system "gunzip", "GeoIP.dat.gz"
@@ -49,7 +66,7 @@ index 30fc0f9..f20f095 100755
+++ b/bootstrap
@@ -1,5 +1,14 @@
#!/bin/sh
+# dl the dat file if needed
+DIR="$( cd "$( dirname "$0" )" && pwd )"
+