70 lines
2.1 KiB
Cheetah
70 lines
2.1 KiB
Cheetah
# Homebrew Formula Template. Built by Makefile: `make fomula`
|
|
class {{Class}} < Formula
|
|
desc "{{Desc}}"
|
|
homepage "{{URL}}"
|
|
url "{{URL}}/archive/v{{Version}}.tar.gz"
|
|
sha256 "{{SHA256}}"
|
|
head "{{URL}}"
|
|
|
|
depends_on "go" => :build
|
|
depends_on "dep"
|
|
|
|
def install
|
|
ENV["GOPATH"] = buildpath
|
|
|
|
bin_path = buildpath/"src/github.com/{{GHREPO}}"
|
|
# Copy all files from their current location (GOPATH root)
|
|
# to $GOPATH/src/github.com/{{GHREPO}}
|
|
bin_path.install Dir["*",".??*"]
|
|
cd bin_path do
|
|
system "dep", "ensure", "--vendor-only"
|
|
system "make", "install", "VERSION=#{version}", "ITERATION={{Iter}}", "PREFIX=#{prefix}", "ETC=#{etc}"
|
|
# If this fails, the user gets a nice big warning about write permissions on their
|
|
# #{var}/log folder. The alternative could be letting the app silently fail
|
|
# to start when it cannot write logs. This is better. Fix perms; reinstall.
|
|
touch("#{var}/log/#{name}.log")
|
|
end
|
|
end
|
|
|
|
def caveats
|
|
<<-EOS
|
|
Edit the config file at #{etc}/#{name}/{{CONFIG_FILE}} then start #{name} with
|
|
brew services start #{name} ~ log file: #{var}/log/#{name}.log
|
|
The manual explains the config file options: man #{name}
|
|
EOS
|
|
end
|
|
|
|
plist_options :startup => false
|
|
|
|
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>ProgramArguments</key>
|
|
<array>
|
|
<string>#{bin}/#{name}</string>
|
|
<string>-c</string>
|
|
<string>#{etc}/#{name}/{{CONFIG_FILE}}</string>
|
|
</array>
|
|
<key>RunAtLoad</key>
|
|
<true/>
|
|
<key>KeepAlive</key>
|
|
<true/>
|
|
<key>StandardErrorPath</key>
|
|
<string>#{var}/log/#{name}.log</string>
|
|
<key>StandardOutPath</key>
|
|
<string>#{var}/log/#{name}.log</string>
|
|
</dict>
|
|
</plist>
|
|
EOS
|
|
end
|
|
|
|
test do
|
|
assert_match "#{name} v#{version}", shell_output("#{bin}/#{name} -v 2>&1", 2)
|
|
end
|
|
end
|