require 'formula' class PerforceProxy < Formula homepage 'http://www.perforce.com/' if MacOS.prefer_64_bit? url 'http://filehost.perforce.com/perforce/r12.1/bin.darwin90x86_64/p4p' md5 '0b35652a8a0d51021ed88a81acb84448' version '2012.1.459601-x86_64' else url 'http://filehost.perforce.com/perforce/r12.1/bin.darwin90x86/p4p' md5 '745bacd461d69b4f441a6f14adedec28' version '2012.1.459601-x86' end def install sbin.install 'p4p' (var+"p4p").mkpath plist_path.write startup_plist plist_path.chmod 0644 end def caveats; <<-EOS.undent To use the Perforce proxy to access your Perforce server, set your P4PORT environment variable to "localhost:1666". To launch on startup: * if this is your first install: mkdir -p ~/Library/LaunchAgents cp #{plist_path} ~/Library/LaunchAgents/ launchctl load -w ~/Library/LaunchAgents/#{plist_path.basename} * if this is an upgrade and you already have the #{plist_path.basename} loaded: launchctl unload -w ~/Library/LaunchAgents/#{plist_path.basename} cp #{plist_path} ~/Library/LaunchAgents/ launchctl load -w ~/Library/LaunchAgents/#{plist_path.basename} Before starting the proxy server, you probably need to edit the plist to use the correct host and port for your Perforce server (replacing the default perforce:1666). EOS end def startup_plist; <<-EOPLIST.undent Label #{plist_name} ProgramArguments #{HOMEBREW_PREFIX}/sbin/p4p -p 1666 -r #{var}/p4p -t perforce:1666 RunAtLoad KeepAlive UserName #{`whoami`.chomp} WorkingDirectory #{var}/p4p EOPLIST end end