forked from Homebrew/homebrew-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharangodb.rb
131 lines (111 loc) · 3.98 KB
/
arangodb.rb
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
class Arangodb < Formula
desc "The Multi-Model NoSQL Database"
homepage "https://www.arangodb.com/"
url "https://download.arangodb.com/Source/ArangoDB-3.4.7.tar.gz"
sha256 "4775030dd0640a7f84256ac0403e63d6236cb59e5d3d42bfd36e4d9ba545524b"
head "https://github.com/arangodb/arangodb.git", :branch => "devel"
bottle do
sha256 "23ad200e20d181e21993d2f3721be8ea6c7c177289eeba407e7a784740a6ed3b" => :mojave
sha256 "5b919fd78d0115a35510b87fd4b652a2af71ba8704f42a29ba151201d6f5e61d" => :high_sierra
sha256 "545e7f811927874b6767132c933c05374147d40e78d7d7285b85706f12791ef3" => :sierra
end
depends_on "cmake" => :build
depends_on "go" => :build
depends_on :macos => :yosemite
depends_on "openssl"
# see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87665
fails_with :gcc => "7"
# the ArangoStarter is in a separate github repository;
# it is used to easily start single server and clusters
# with a unified CLI
resource "starter" do
url "https://github.com/arangodb-helper/arangodb.git",
:revision => "1e8c10c8669495a6996cc8063b9956f3e99127bc"
end
def install
ENV.cxx11
resource("starter").stage do
ENV.append "GOPATH", Dir.pwd + "/.gobuild"
system "make", "deps"
# use commit-id as projectBuild
commit = `git rev-parse HEAD`.chomp
system "go", "build", "-ldflags", "-X main.projectVersion=0.14.5 -X main.projectBuild=#{commit}",
"-o", "arangodb",
"github.com/arangodb-helper/arangodb"
bin.install "arangodb"
end
mkdir "build" do
args = std_cmake_args + %W[
-DHOMEBREW=ON
-DUSE_OPTIMIZE_FOR_ARCHITECTURE=OFF
-DASM_OPTIMIZATIONS=OFF
-DCMAKE_INSTALL_DATADIR=#{share}
-DCMAKE_INSTALL_DATAROOTDIR=#{share}
-DCMAKE_INSTALL_SYSCONFDIR=#{etc}
-DCMAKE_INSTALL_LOCALSTATEDIR=#{var}
-DCMAKE_OSX_DEPLOYMENT_TARGET=#{MacOS.version}
]
if ENV.compiler == "gcc-6"
ENV.append "V8_CXXFLAGS", "-O3 -g -fno-delete-null-pointer-checks"
end
system "cmake", "..", *args
system "make", "install"
%w[arangod arango-dfdb arangosh foxx-manager].each do |f|
inreplace etc/"arangodb3/#{f}.conf", pkgshare, opt_pkgshare
end
end
end
def post_install
(var/"lib/arangodb3").mkpath
(var/"log/arangodb3").mkpath
end
def caveats
s = <<~EOS
An empty password has been set. Please change it by executing
#{opt_sbin}/arango-secure-installation
EOS
s
end
plist_options :manual => "#{HOMEBREW_PREFIX}/opt/arangodb/sbin/arangod"
def plist; <<~EOS
<?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>
<true/>
<key>Label</key>
<string>#{plist_name}</string>
<key>Program</key>
<string>#{opt_sbin}/arangod</string>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
EOS
end
test do
require "pty"
testcase = "require('@arangodb').print('it works!')"
output = shell_output("#{bin}/arangosh --server.password \"\" --javascript.execute-string \"#{testcase}\"")
assert_equal "it works!", output.chomp
ohai "#{bin}/arangodb --starter.instance-up-timeout 1m --starter.mode single"
PTY.spawn("#{bin}/arangodb", "--starter.instance-up-timeout", "1m",
"--starter.mode", "single", "--starter.disable-ipv6",
"--server.arangod", "#{sbin}/arangod",
"--server.js-dir", "#{share}/arangodb3/js") do |r, _, pid|
begin
loop do
available = IO.select([r], [], [], 60)
assert_not_equal available, nil
line = r.readline.strip
ohai line
break if line.include?("Your single server can now be accessed")
end
ensure
Process.kill "SIGINT", pid
ohai "shuting down #{pid}"
end
end
end
end