class Geoip < Formula desc "GeoIP databases in a number of formats" homepage "https://github.com/maxmind/geoip-api-c" url "https://github.com/maxmind/geoip-api-c/releases/download/v1.6.7/GeoIP-1.6.7.tar.gz" sha256 "18f3713146b6196f85b57a92bcfdc9aea3345e2d836531a6ac4a630ffc7fa559" head "https://github.com/maxmind/geoip-api-c.git" bottle do cellar :any sha256 "5007ba7a919e80d07e574d7e3d6b386b9961cbe048a00cdca83d98eb14e4678b" => :el_capitan sha256 "2969446d080958c831a017fc5343a126cdd76fde9695cfd012733f8ba4e84aaa" => :yosemite sha256 "c17cecf7bc7064fe2bbb30168824f6383314668def98b325b16830cca29eeb1a" => :mavericks end depends_on "geoipupdate" => :optional option :universal def install ENV.universal_binary if build.universal? 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["#{legacy_data}/*"], geoip_data if legacy_data.exist? full = Pathname.new "#{geoip_data}/GeoIP.dat" ln_s "GeoLiteCountry.dat", full unless full.exist? || full.symlink? full = Pathname.new "#{geoip_data}/GeoIPCity.dat" ln_s "GeoLiteCity.dat", full unless full.exist? || full.symlink? end test do 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" end end