homebrew-core/Formula/tor.rb
Jack Nagel 6ce735db99 Add and use plist helper methods
These will be used to unify the label namespaces in embedded plists,
i.e. 'homebrew.mxcl.<formula>'.

plist_path returns the full path to a plist file located at the top
level of the keg; plist_path.basename can be used if just the filename
is needed.

c.f. Homebrew/homebrew#9346.

Signed-off-by: Jack Nagel <jacknagel@gmail.com>
2012-02-03 19:50:58 -06:00

51 lines
1.3 KiB
Ruby

require 'formula'
class Tor < Formula
url 'https://www.torproject.org/dist/tor-0.2.2.35.tar.gz'
homepage 'https://www.torproject.org/'
md5 'dcecf699c4b929319d5f1ce0358d4835'
depends_on 'libevent'
def install
system "./configure", "--disable-debug", "--disable-dependency-tracking",
"--prefix=#{prefix}"
system "make install"
plist_path.write startup_plist
plist_path.chmod 0644
end
def startup_plist
return <<-EOPLIST
<?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>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
<key>UserName</key>
<string>#{`whoami`.chomp}</string>
<key>ProgramArguments</key>
<array>
<string>#{HOMEBREW_PREFIX}/bin/tor</string>
</array>
<key>WorkingDirectory</key>
<string>#{HOMEBREW_PREFIX}</string>
</dict>
</plist>
EOPLIST
end
def caveats; <<-EOS.undent
You can start tor automatically on login with:
mkdir -p ~/Library/LaunchAgents
cp #{plist_path} ~/Library/LaunchAgents/
launchctl load -w ~/Library/LaunchAgents/#{plist_path.basename}
EOS
end
end