From e7cda7f451614884dfd0b3b192ae2c71242e87ad Mon Sep 17 00:00:00 2001 From: Nicholas Sivo Date: Sun, 24 Nov 2013 17:59:44 -0800 Subject: 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 --- Library/Formula/geoip.rb | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'Library') diff --git a/Library/Formula/geoip.rb b/Library/Formula/geoip.rb index 2e3ade95c..1aeb95215 100644 --- a/Library/Formula/geoip.rb +++ b/Library/Formula/geoip.rb @@ -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 )" + -- cgit v1.2.3