diff options
| author | Nicholas Sivo | 2013-11-24 17:59:44 -0800 | 
|---|---|---|
| committer | Mike McQuaid | 2013-11-28 10:12:48 +0000 | 
| commit | e7cda7f451614884dfd0b3b192ae2c71242e87ad (patch) | |
| tree | 8e1adf877031ff28289bc97d35b6d0a700b60336 /Library/Formula/geoip.rb | |
| parent | ea0fe99d1e3d14dfd9f0636e292b8c2937f1ea68 (diff) | |
| download | homebrew-e7cda7f451614884dfd0b3b192ae2c71242e87ad.tar.bz2 | |
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>
Diffstat (limited to 'Library/Formula/geoip.rb')
| -rw-r--r-- | Library/Formula/geoip.rb | 19 | 
1 files changed, 18 insertions, 1 deletions
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  )"  +  | 
