blob: 6de09ed65535e98212782db3997efbd73cc02c8b (
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
 | class CouchdbLucene < Formula
  homepage "https://github.com/rnewson/couchdb-lucene"
  url "https://github.com/rnewson/couchdb-lucene/archive/v1.0.2.tar.gz"
  sha1 "75e0c55a87f47903c6cd122286ea3e4568809f7e"
  bottle do
    sha1 "6df93e1cf958760cd4d822822728693092d2289f" => :yosemite
    sha1 "ae4d677f930935654b3cc727650c4c21dffbc501" => :mavericks
    sha1 "2248e7029a5a565e151c52f67cc2bfeae12e2bdd" => :mountain_lion
  end
  depends_on "couchdb"
  depends_on "maven" => :build
  depends_on :java
  def install
    system "mvn"
    system "tar", "-xzf", "target/couchdb-lucene-#{version}-dist.tar.gz", "--strip", "1"
    prefix.install_metafiles
    rm_rf Dir["bin/*.bat"]
    libexec.install Dir["*"]
    Dir.glob("#{libexec}/bin/*") do |path|
      bin_name = File.basename(path)
      cmd = "cl_#{bin_name}"
      (bin/cmd).write shim_script(bin_name)
      (libexec/"clbin").install_symlink bin/cmd => bin_name
    end
    ini_path.write(ini_file) unless ini_path.exist?
  end
  def shim_script(target); <<-EOS.undent
    #!/bin/bash
    export CL_BASEDIR=#{libexec}/bin
    exec "$CL_BASEDIR/#{target}" "$@"
    EOS
  end
  def ini_path
    etc/"couchdb/local.d/couchdb-lucene.ini"
  end
  def ini_file; <<-EOS.undent
    [httpd_global_handlers]
    _fti = {couch_httpd_proxy, handle_proxy_req, <<"http://127.0.0.1:5985">>}
    EOS
  end
  plist_options :manual => "#{HOMEBREW_PREFIX}/opt/couchdb-lucene/bin/cl_run"
  def plist; <<-EOS.undent
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
      "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
      <dict>
        <key>Label</key>
        <string>#{plist_name}</string>
        <key>EnvironmentVariables</key>
        <dict>
          <key>HOME</key>
          <string>~</string>
        </dict>
        <key>ProgramArguments</key>
        <array>
          <string>#{opt_bin}/cl_run</string>
        </array>
        <key>StandardOutPath</key>
        <string>/dev/null</string>
        <key>StandardErrorPath</key>
        <string>/dev/null</string>
        <key>RunAtLoad</key>
        <true/>
        <key>KeepAlive</key>
        <true/>
      </dict>
    </plist>
    EOS
  end
  def caveats; <<-EOS.undent
    All commands have been installed with the prefix 'cl_'.
    If you really need to use these commands with their normal names, you
    can add a "clbin" directory to your PATH from your bashrc like:
        PATH="#{opt_libexec}/clbin:$PATH"
    EOS
  end
  test do
    io = IO.popen("#{bin}/cl_run")
    sleep 2
    Process.kill("SIGINT", io.pid)
    Process.wait(io.pid)
    io.read !~ /Exception/
  end
end
 |