2015-04-16 03:05:46 +00:00
|
|
|
require "language/go"
|
2014-07-07 23:43:44 +00:00
|
|
|
|
|
|
|
class Cayley < Formula
|
|
|
|
homepage "https://github.com/google/cayley"
|
2015-05-25 00:41:09 +00:00
|
|
|
url "https://github.com/google/cayley/archive/v0.4.1.tar.gz"
|
|
|
|
sha256 "d61f969128bcff1bce1e14e0afa68b9f25e4f3ab8e5f77930a384426f3b3bbce"
|
2014-07-07 23:43:44 +00:00
|
|
|
head "https://github.com/google/cayley.git"
|
|
|
|
|
2014-07-08 18:04:56 +00:00
|
|
|
bottle do
|
2015-05-25 01:37:10 +00:00
|
|
|
cellar :any
|
|
|
|
sha256 "999dbf6a51615becf310f6cb5cdd71c9939fc93cc6e743234d2511d20a561641" => :yosemite
|
|
|
|
sha256 "56395b48c4025e8242cbbe1e365a67a639bdb3b350799db0ad0e495c7d6c59f0" => :mavericks
|
|
|
|
sha256 "1a96db8eb29e1e985a430970f84bb31db44024dd9ab264ac1f83ad7e1c9251ab" => :mountain_lion
|
2014-07-08 18:04:56 +00:00
|
|
|
end
|
|
|
|
|
2014-07-07 23:43:44 +00:00
|
|
|
depends_on "bazaar" => :build
|
|
|
|
depends_on :hg => :build
|
|
|
|
depends_on "go" => :build
|
|
|
|
|
|
|
|
option "without-samples", "Disable installing sample data"
|
|
|
|
|
2015-04-16 03:05:46 +00:00
|
|
|
# Go dependencies
|
|
|
|
go_resource "github.com/badgerodon/peg" do
|
|
|
|
url "https://github.com/badgerodon/peg.git", :revision => "9e5f7f4d07ca576562618c23e8abadda278b684f"
|
|
|
|
end
|
|
|
|
|
|
|
|
go_resource "github.com/barakmich/glog" do
|
|
|
|
url "https://github.com/barakmich/glog.git", :revision => "fafcb6128a8a2e6360ff034091434d547397d54a"
|
|
|
|
end
|
|
|
|
|
|
|
|
go_resource "github.com/cznic/mathutil" do
|
|
|
|
url "https://github.com/cznic/mathutil.git", :revision => "f9551431b78e71ee24939a1e9d8f49f43898b5cd"
|
|
|
|
end
|
|
|
|
|
|
|
|
go_resource "github.com/julienschmidt/httprouter" do
|
|
|
|
url "https://github.com/julienschmidt/httprouter.git", :revision => "b59a38004596b696aca7aa2adccfa68760864d86"
|
|
|
|
end
|
|
|
|
|
|
|
|
go_resource "github.com/petar/GoLLRB/llrb" do
|
|
|
|
url "https://github.com/petar/GoLLRB.git", :revision => "53be0d36a84c2a886ca057d34b6aa4468df9ccb4"
|
|
|
|
end
|
|
|
|
|
|
|
|
go_resource "github.com/peterh/liner" do
|
|
|
|
url "https://github.com/peterh/liner.git", :revision => "1bb0d1c1a25ed393d8feb09bab039b2b1b1fbced"
|
|
|
|
end
|
|
|
|
|
|
|
|
go_resource "github.com/robertkrimen/otto" do
|
|
|
|
url "https://github.com/robertkrimen/otto.git", :revision => "d1b4d8ef0e0e4b088c8328c95ca63ab9ebd8fc9d"
|
|
|
|
end
|
|
|
|
|
|
|
|
go_resource "github.com/syndtr/gosnappy" do
|
|
|
|
url "https://github.com/syndtr/gosnappy.git", :revision => "156a073208e131d7d2e212cb749feae7c339e846"
|
|
|
|
end
|
|
|
|
|
|
|
|
go_resource "github.com/shurcooL/sanitized_anchor_name" do
|
|
|
|
url "https://github.com/shurcooL/sanitized_anchor_name.git", :revision => "8e87604bec3c645a4eeaee97dfec9f25811ff20d"
|
|
|
|
end
|
|
|
|
|
|
|
|
go_resource "github.com/russross/blackfriday" do
|
|
|
|
url "https://github.com/russross/blackfriday.git", :revision => "17bb7999de6cfb791d4f8986cc00b3309b370cdb"
|
|
|
|
end
|
|
|
|
|
|
|
|
go_resource "github.com/syndtr/goleveldb" do
|
|
|
|
url "https://github.com/syndtr/goleveldb.git", :revision => "4875955338b0a434238a31165cb87255ab6e9e4a"
|
|
|
|
end
|
|
|
|
|
|
|
|
go_resource "github.com/boltdb/bolt" do
|
|
|
|
url "https://github.com/boltdb/bolt.git", :revision => "3b449559cf34cbcc74460b59041a4399d3226e5a"
|
|
|
|
end
|
|
|
|
|
2015-05-25 00:41:09 +00:00
|
|
|
# It looks for both unstable and stable mgo in GOPATH during compile.
|
2015-04-16 03:05:46 +00:00
|
|
|
go_resource "gopkg.in/mgo.v2" do
|
|
|
|
url "https://github.com/go-mgo/mgo.git", :revision => "c6a7dce14133ccac2dcac3793f1d6e2ef048503a"
|
|
|
|
end
|
|
|
|
|
2015-05-25 00:41:09 +00:00
|
|
|
go_resource "gopkg.in/mgo.v2-unstable" do
|
|
|
|
url "https://github.com/go-mgo/mgo.git", :revision => "7a4943433e00707e38099a2b2e904d96681d14bc"
|
|
|
|
end
|
|
|
|
|
|
|
|
go_resource "code.google.com/p/go-uuid" do
|
|
|
|
url "https://code.google.com/p/go-uuid/", :revision => "35bc42037350", :using => :hg
|
|
|
|
end
|
|
|
|
|
2014-07-07 23:43:44 +00:00
|
|
|
def install
|
|
|
|
# Prepare for Go build
|
|
|
|
ENV["GOPATH"] = buildpath
|
2015-04-16 03:05:46 +00:00
|
|
|
Language::Go.stage_deps resources, buildpath/"src"
|
2014-07-07 23:43:44 +00:00
|
|
|
|
|
|
|
# To avoid re-downloading Cayley, symlink its source from the tarball so that Go can find it
|
|
|
|
mkdir_p "src/github.com/google/"
|
|
|
|
ln_s buildpath, "src/github.com/google/cayley"
|
|
|
|
|
|
|
|
# Build
|
|
|
|
system "go", "build", "-o", "cayley"
|
|
|
|
|
|
|
|
# Create sample configuration that uses the Homebrew-based directories
|
2014-07-09 16:22:08 +00:00
|
|
|
inreplace "cayley.cfg.example", "/tmp/cayley_test", "#{var}/cayley"
|
2014-07-07 23:43:44 +00:00
|
|
|
|
|
|
|
# Install binary and configuration
|
|
|
|
bin.install "cayley"
|
|
|
|
etc.install "cayley.cfg.example" => "cayley.conf"
|
|
|
|
|
2014-07-09 16:22:08 +00:00
|
|
|
# Copy over the static web assets
|
2015-05-25 00:41:09 +00:00
|
|
|
(share/"cayley/assets").install "docs", "static", "templates"
|
2014-07-07 23:43:44 +00:00
|
|
|
|
|
|
|
if build.with? "samples"
|
2015-05-25 00:41:09 +00:00
|
|
|
system "gzip", "-d", "data/30kmoviedata.nq.gz"
|
2014-07-07 23:43:44 +00:00
|
|
|
|
|
|
|
# Copy over sample data
|
2015-05-25 00:41:09 +00:00
|
|
|
(share/"cayley/samples").install "data/testdata.nq", "data/30kmoviedata.nq"
|
2014-07-07 23:43:44 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-07-09 16:22:08 +00:00
|
|
|
def post_install
|
|
|
|
unless File.exist? "#{var}/cayley"
|
|
|
|
# Create data directory
|
|
|
|
(var/"cayley").mkpath
|
|
|
|
|
|
|
|
# Initialize the Cayley database
|
|
|
|
system "#{bin}/cayley", "init", "--config=#{etc}/cayley.conf"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
plist_options :manual => "cayley http --assets=#{HOMEBREW_PREFIX}/share/cayley/assets --config=#{HOMEBREW_PREFIX}/etc/cayley.conf"
|
2014-07-07 23:43:44 +00:00
|
|
|
|
|
|
|
def plist; <<-EOS.undent
|
|
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
|
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
|
|
<plist version="1.0">
|
|
|
|
<dict>
|
|
|
|
<key>KeepAlive</key>
|
|
|
|
<dict>
|
|
|
|
<key>SuccessfulExit</key>
|
|
|
|
<false/>
|
|
|
|
</dict>
|
|
|
|
<key>Label</key>
|
|
|
|
<string>#{plist_name}</string>
|
|
|
|
<key>ProgramArguments</key>
|
|
|
|
<array>
|
|
|
|
<string>#{opt_bin}/cayley</string>
|
2014-07-09 16:22:08 +00:00
|
|
|
<string>http</string>
|
|
|
|
<string>--assets=#{share}/cayley/assets</string>
|
2014-07-07 23:43:44 +00:00
|
|
|
<string>--config=#{etc}/cayley.conf</string>
|
|
|
|
</array>
|
|
|
|
<key>RunAtLoad</key>
|
|
|
|
<true/>
|
|
|
|
<key>WorkingDirectory</key>
|
|
|
|
<string>#{var}/cayley</string>
|
|
|
|
<key>StandardErrorPath</key>
|
|
|
|
<string>#{var}/log/cayley.log</string>
|
|
|
|
<key>StandardOutPath</key>
|
|
|
|
<string>#{var}/log/cayley.log</string>
|
|
|
|
</dict>
|
|
|
|
</plist>
|
|
|
|
EOS
|
|
|
|
end
|
|
|
|
|
|
|
|
test do
|
2014-08-28 14:39:26 +00:00
|
|
|
result = pipe_output("#{bin}/cayley version")
|
|
|
|
assert result.include?("Cayley snapshot")
|
2014-07-07 23:43:44 +00:00
|
|
|
end
|
|
|
|
end
|