45 lines
1.7 KiB
Ruby
45 lines
1.7 KiB
Ruby
class Geoip < Formula
|
|
desc "This library is for the GeoIP Legacy format (dat)"
|
|
homepage "https://github.com/maxmind/geoip-api-c"
|
|
url "https://github.com/maxmind/geoip-api-c/releases/download/v1.6.12/GeoIP-1.6.12.tar.gz"
|
|
sha256 "1dfb748003c5e4b7fd56ba8c4cd786633d5d6f409547584f6910398389636f80"
|
|
|
|
head "https://github.com/maxmind/geoip-api-c.git"
|
|
|
|
bottle do
|
|
sha256 "f6a895c01acdcc30efb1efe0b6a663e89cd86ce93a1543fb4e39b37c9f2ab2b0" => :high_sierra
|
|
sha256 "00d3f48b250bddd07224b7d3422d36fa5374e27130ec6002f321146920ce711b" => :sierra
|
|
sha256 "9bf37c2b6e7fa5971cd5a029fd6390a830a063b746b0556384019fced6dff534" => :el_capitan
|
|
end
|
|
|
|
depends_on "geoipupdate" => :optional
|
|
|
|
def install
|
|
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", "https://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
|