aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Formula/geoipupdate.rb
blob: 337c53924faa5b57f00f64440b52b3db72a28a1f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
require 'formula'

class Geoipupdate < Formula
  homepage 'https://github.com/maxmind/geoipupdate'

  stable do
    url "https://github.com/maxmind/geoipupdate/releases/download/v2.0.1/geoipupdate-2.0.1.tar.gz"
    sha1 "11048de992e21bc99b22caa781ae27625e6a62dc"
  end

  head 'https://github.com/maxmind/geoipupdate.git'

  # Because the patch requires regenerating the configure script;
  # move these back to the head spec on next release
  depends_on 'autoconf' => :build
  depends_on 'automake' => :build
  depends_on 'libtool' => :build

  option :universal

  def install
    ENV.universal_binary if build.universal?

    # Download free databases by default
    # See https://github.com/maxmind/geoip-api-c#150
    inreplace 'conf/GeoIP.conf.default', 'YOUR_USER_ID_HERE', '999999'
    inreplace 'conf/GeoIP.conf.default', 'YOUR_LICENSE_KEY_HERE', '000000000000'
    inreplace 'conf/GeoIP.conf.default', /^ProductIds .*$/, 'ProductIds 506 533'

    system "./bootstrap"

    system "./configure", "--disable-dependency-tracking",
                          "--disable-silent-rules",
                          "--datadir=#{var}",
                          "--prefix=#{prefix}"
    system "make", "install"
  end

  def post_install
    (var/"GeoIP").mkpath
  end

  test do
    system "#{bin}/geoipupdate", "-v"
  end
end