62 lines
2.1 KiB
Ruby
62 lines
2.1 KiB
Ruby
class ServerGo < Formula
|
|
desc "Server for OpenIoTHub"
|
|
homepage "https://github.com/OpenIoTHub/server-go"
|
|
url "https://github.com/OpenIoTHub/server-go.git",
|
|
tag: "v1.1.63",
|
|
revision: "3a39ca0e628119fa303d1d2ab202eba4e9c10897"
|
|
license "MIT"
|
|
|
|
livecheck do
|
|
url :stable
|
|
strategy :github_latest
|
|
end
|
|
|
|
bottle do
|
|
sha256 cellar: :any_skip_relocation, big_sur: "f58211fa3930e3fdc4d07204f995f8295db85e9d052f6e5e466899882a3f3733"
|
|
sha256 cellar: :any_skip_relocation, catalina: "316b6227256a8ebe3d79a54279ce9c39db0b592836229608a2848198584b4bbf"
|
|
sha256 cellar: :any_skip_relocation, mojave: "92a60704673640d7b30e6a5727bc6799a26f0160b84e20a4778b07d513945c13"
|
|
end
|
|
|
|
depends_on "go" => :build
|
|
|
|
def install
|
|
(etc/"server-go").mkpath
|
|
system "go", "build", "-mod=vendor", "-ldflags",
|
|
"-s -w -X main.version=#{version} -X main.commit=#{Utils.git_head} -X main.builtBy=homebrew", *std_go_args
|
|
etc.install "server-go.yaml" => "server-go/server-go.yaml"
|
|
end
|
|
|
|
plist_options manual: "server-go -c #{HOMEBREW_PREFIX}/etc/server-go/server-go.yaml"
|
|
|
|
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>Label</key>
|
|
<string>#{plist_name}</string>
|
|
<key>KeepAlive</key>
|
|
<true/>
|
|
<key>ProgramArguments</key>
|
|
<array>
|
|
<string>#{opt_bin}/server-go</string>
|
|
<string>-c</string>
|
|
<string>#{etc}/server-go/server-go.yaml</string>
|
|
</array>
|
|
<key>StandardErrorPath</key>
|
|
<string>#{var}/log/server-go.log</string>
|
|
<key>StandardOutPath</key>
|
|
<string>#{var}/log/server-go.log</string>
|
|
</dict>
|
|
</plist>
|
|
EOS
|
|
end
|
|
|
|
test do
|
|
assert_match version.to_s, shell_output("#{bin}/server-go -v 2>&1")
|
|
assert_match "config created", shell_output("#{bin}/server-go init --config=server.yml 2>&1")
|
|
assert_predicate testpath/"server.yml", :exist?
|
|
end
|
|
end
|