51 lines
2 KiB
Ruby
51 lines
2 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
|
|
cellar :any
|
|
rebuild 1
|
|
sha256 "8cac6d2fe351dbae2398e8c18906b06cd01d4b5db20c6a886f0551eee358d785" => :catalina
|
|
sha256 "311704d07adf7fa502e60bd0e462ba26f6830838c09461f8bbac38ccb5da77f1" => :mojave
|
|
sha256 "17db912ce8ffcd831d775f22c1ea428faf55d7ecb4dd19cdba6ab3234874417c" => :high_sierra
|
|
sha256 "166b2195350b830ddcaea41a24dbdbcea48b9d42f96673088dd3d51b8d5774d7" => :sierra
|
|
end
|
|
|
|
resource "database" do
|
|
url "https://src.fedoraproject.org/lookaside/pkgs/GeoIP/GeoIP.dat.gz/4bc1e8280fe2db0adc3fe48663b8926e/GeoIP.dat.gz"
|
|
sha256 "7fd7e4829aaaae2677a7975eeecd170134195e5b7e6fc7d30bf3caf34db41bcd"
|
|
end
|
|
|
|
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
|
|
resource("database").stage do
|
|
output = shell_output("#{bin}/geoiplookup -f GeoIP.dat 8.8.8.8")
|
|
assert_match "GeoIP Country Edition: US, United States", output
|
|
end
|
|
end
|
|
end
|