2014-07-20 18:49:32 +00:00
|
|
|
require "formula"
|
2009-10-03 02:09:26 +00:00
|
|
|
|
2011-03-10 05:11:03 +00:00
|
|
|
class Geoip < Formula
|
2014-07-20 18:49:32 +00:00
|
|
|
homepage "https://github.com/maxmind/geoip-api-c"
|
2014-03-19 17:07:50 +00:00
|
|
|
|
|
|
|
stable do
|
2014-07-20 18:49:32 +00:00
|
|
|
url "https://github.com/maxmind/geoip-api-c/archive/v1.6.2.tar.gz"
|
|
|
|
sha1 "aa9a91b61667b605f62964c613e15400cbca2cae"
|
2014-03-19 17:07:50 +00:00
|
|
|
|
|
|
|
# Download test data so `make check` works. Fixed in HEAD.
|
|
|
|
# See https://github.com/maxmind/geoip-api-c/commit/722707cc3a0adc06aec3e98bc36e7262f67ec0da
|
|
|
|
patch :DATA
|
|
|
|
end
|
|
|
|
|
2014-07-20 18:49:32 +00:00
|
|
|
head "https://github.com/maxmind/geoip-api-c.git"
|
2009-10-03 02:09:26 +00:00
|
|
|
|
2014-02-23 12:04:53 +00:00
|
|
|
bottle do
|
|
|
|
cellar :any
|
2014-08-13 13:46:45 +00:00
|
|
|
revision 1
|
|
|
|
sha1 "3ebd898cb31012b641b471b4cf5cd537f9226afd" => :mavericks
|
|
|
|
sha1 "d3798825d01b45a40e6015e637f82965dbe49fdc" => :mountain_lion
|
|
|
|
sha1 "ba096b834f4c251c2b6c6d63349574aab3a336fb" => :lion
|
2014-02-23 12:04:53 +00:00
|
|
|
end
|
|
|
|
|
2014-07-20 18:49:32 +00:00
|
|
|
depends_on "autoconf" => :build
|
|
|
|
depends_on "automake" => :build
|
|
|
|
depends_on "libtool" => :build
|
|
|
|
depends_on "geoipupdate" => :optional
|
2012-04-03 01:55:58 +00:00
|
|
|
|
2012-08-10 04:47:59 +00:00
|
|
|
option :universal
|
2010-10-17 15:52:14 +00:00
|
|
|
|
2009-10-03 02:09:26 +00:00
|
|
|
def install
|
2012-08-10 04:47:59 +00:00
|
|
|
ENV.universal_binary if build.universal?
|
2012-04-03 01:55:58 +00:00
|
|
|
|
|
|
|
# Fixes a build error on Lion when configure does a variant of autoreconf
|
|
|
|
# that results in a botched Makefile, causing this error:
|
|
|
|
# No rule to make target '../libGeoIP/libGeoIP.la', needed by 'geoiplookup'
|
|
|
|
# This works on Snow Leopard also when it tries but fails to run autoreconf.
|
2013-11-24 00:29:26 +00:00
|
|
|
# Also fixes the tests by downloading required data file
|
|
|
|
system "./bootstrap"
|
2012-04-03 01:55:58 +00:00
|
|
|
|
2012-08-10 04:47:59 +00:00
|
|
|
system "./configure", "--disable-dependency-tracking",
|
2013-11-24 00:29:26 +00:00
|
|
|
"--disable-silent-rules",
|
2013-11-25 01:59:44 +00:00
|
|
|
"--datadir=#{var}",
|
2012-08-10 04:47:59 +00:00
|
|
|
"--prefix=#{prefix}"
|
2013-11-24 00:29:26 +00:00
|
|
|
system "make", "check"
|
|
|
|
system "make", "install"
|
2009-10-03 02:09:26 +00:00
|
|
|
end
|
2013-01-27 22:37:52 +00:00
|
|
|
|
2013-11-25 01:59:44 +00:00
|
|
|
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"
|
2014-05-30 17:38:30 +00:00
|
|
|
cp Dir["#{legacy_data}/*"], geoip_data if legacy_data.exist?
|
2013-11-25 01:59:44 +00:00
|
|
|
|
2014-08-12 07:48:13 +00:00
|
|
|
full = Pathname.new "#{geoip_data}/GeoIP.dat"
|
|
|
|
ln_s "GeoLiteCountry.dat", full unless full.exist? or full.symlink?
|
|
|
|
full = Pathname.new "#{geoip_data}/GeoIPCity.dat"
|
|
|
|
ln_s "GeoLiteCity.dat", full unless full.exist? or full.symlink?
|
2013-11-25 01:59:44 +00:00
|
|
|
end
|
|
|
|
|
2013-01-27 22:37:52 +00:00
|
|
|
test do
|
2013-11-24 00:29:26 +00:00
|
|
|
system "curl", "-O", "http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz"
|
|
|
|
system "gunzip", "GeoIP.dat.gz"
|
|
|
|
system "#{bin}/geoiplookup", "-f", "GeoIP.dat", "8.8.8.8"
|
2013-01-27 22:37:52 +00:00
|
|
|
end
|
2009-10-03 02:09:26 +00:00
|
|
|
end
|
2013-11-24 00:29:26 +00:00
|
|
|
|
|
|
|
__END__
|
|
|
|
diff --git a/bootstrap b/bootstrap
|
|
|
|
index 30fc0f9..f20f095 100755
|
|
|
|
--- a/bootstrap
|
|
|
|
+++ b/bootstrap
|
|
|
|
@@ -1,5 +1,14 @@
|
|
|
|
#!/bin/sh
|
2013-11-25 01:59:44 +00:00
|
|
|
|
2013-11-24 00:29:26 +00:00
|
|
|
+# dl the dat file if needed
|
|
|
|
+DIR="$( cd "$( dirname "$0" )" && pwd )"
|
|
|
|
+
|
|
|
|
+# download geolite database for the tests
|
|
|
|
+mkdir -p $DIR/data
|
|
|
|
+if [ ! -f $DIR/data/GeoIP.dat ]; then
|
|
|
|
+ curl http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz | gzip -d > $DIR/data/GeoIP.dat
|
|
|
|
+fi
|
|
|
|
+
|
|
|
|
# make sure to use the installed libtool
|
|
|
|
rm -f ltmain.sh
|
|
|
|
autoreconf -fiv
|