homebrew-core/Formula/server-go.rb

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.65",
revision: "e7416e34d01b6989ad395339edd00ae6ac954460"
license "MIT"
livecheck do
url :stable
strategy :github_latest
end
bottle do
sha256 cellar: :any_skip_relocation, big_sur: "f09c3b2830df79c8fed0ea4da8dd56d0dedb343996b9d1518a9627caece24279"
sha256 cellar: :any_skip_relocation, catalina: "ee8a6a8d3bdb8528614ebd6e5d696804b92bb014f46fe894309c50d59abb13ad"
sha256 cellar: :any_skip_relocation, mojave: "9adaf7d94669982fc6d151fc1b11f0bf9dfde8640eaaf8f8b09e1f071442bd90"
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